Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신은섭(Shin Eun Seop)
/
2018-1-d.cloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Kangsubeen
2018-06-13 05:08:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
02357f2cdd709739d0ecea2aaf1cb2073747744e
02357f2c
1 parent
2299e497
upload
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
19 deletions
dcloud/website/templates/website/baseline.html
dcloud/website/templates/website/file_list.html
dcloud/website/templates/website/home.html
dcloud/website/urls.py
dcloud/website/views.py
dcloud/website/templates/website/baseline.html
View file @
02357f2
...
...
@@ -66,6 +66,6 @@
<script
src=
"https://code.jquery.com/jquery-3.1.1.min.js"
></script>
<script
src=
'{% static "js/bootstrap.js"%}'
></script>
<script
src=
'{% static "semantic/dist/semantic.min.js"%'
></script>
<script
src=
'{% static "semantic/dist/semantic.min.js"%
}
'
></script>
</body>
</html>
\ No newline at end of file
...
...
dcloud/website/templates/website/file_list.html
View file @
02357f2
...
...
@@ -6,22 +6,23 @@
</style>
<center>
<div>
<form
method=
"post"
,
action=
"{% url 'file_upload'
%}"
>
<form
method=
"post"
,
enctype=
"multipart/form-data"
,
action=
"{% url 'file_upload' path=path
%}"
>
{% csrf_token %}
<div
style=
"border: solid; display:inline-block; padding: 5px; border-color: skyblue"
>
<input
type=
"file"
>
<input
type=
"file"
name=
"file"
>
</div>
<button
style=
"margin-top: 10px"
class=
"ui primary button"
type=
"submit"
><i
class=
"upload icon"
></i>
업로드
</button>
</form>
</div>
</center>
<button
class=
"ui primary button"
style=
"margin-left: 2
4
%"
type=
"submit"
onclick=
"make_folder()"
><i
class=
"plus icon"
></i>
폴더 만들기
</button>
<button
class=
"ui primary button"
style=
"margin-left: 2
8
%"
type=
"submit"
onclick=
"make_folder()"
><i
class=
"plus icon"
></i>
폴더 만들기
</button>
<br>
<center>
<table
style=
"margin-top: 7px"
class=
"ui celled striped collapsing table"
>
<thead>
<tr><th
class=
"twelve wide"
>
/{{ user.username }}/
</th>
<tr><th
class=
"twelve wide"
>
/{{ path }}
</th>
<th>
복사
</th>
<th
>
이동
</th>
<th>
삭제
</th>
...
...
@@ -32,7 +33,9 @@
<tr>
<td
class=
"collapsing"
>
{% if file.type == "directory" %}
<a
href=
"#"
><i
class=
"folder icon"
></i>
{{file.name}}
</a>
{% with new_path=path|add:file.name|add:'/' %}
<a
href=
"{% url 'file_list' path=new_path %}"
><i
class=
"folder icon"
></i>
{{file.name}}
</a>
{% endwith %}
{% else %}
<i
class=
"file outline icon"
></i>
{{file.name}}
{% endif %}
...
...
@@ -43,6 +46,7 @@
<td
class=
"center aligned collapsing"
><i
onclick=
"make_folder()"
style=
"cursor: pointer;"
class=
"download icon"
></i></td>
</tr>
{% endfor %}
</tbody>
</table>
</center>
...
...
dcloud/website/templates/website/home.html
View file @
02357f2
...
...
@@ -18,7 +18,7 @@
<p
class=
"text-center"
>
D.cloud는 클라우드 사이트입니다.
</p>
<br>
{% if user.is_authenticated %}
<p
class=
"text-center"
><a
class=
"btn btn-primary btn-lg"
href=
"{% url 'file_list' %}"
role =
"button"
>
내 클라우드로 가기
</a></p>
<p
class=
"text-center"
><a
class=
"btn btn-primary btn-lg"
href=
"{% url 'file_list'
path=''
%}"
role =
"button"
>
내 클라우드로 가기
</a></p>
{% else %}
<p
class=
"text-center"
><a
class=
"btn btn-primary btn-lg"
href=
"{% url 'login' %}"
role =
"button"
>
내 클라우드로 가기
</a></p>
{% endif %}
...
...
dcloud/website/urls.py
View file @
02357f2
...
...
@@ -9,9 +9,9 @@ urlpatterns = [
url
(
r'^accounts/delete_account_success/$'
,
auth_views
.
delete_account_success
,
name
=
'delete_account_success'
),
# blog
url
(
r'^$'
,
views
.
home
),
url
(
r'^
files/
'
,
views
.
file_list
,
name
=
'file_list'
),
url
(
r'^upload/'
,
views
.
file_upload
,
name
=
'file_upload'
),
url
(
r'^$'
,
views
.
home
,
name
=
'home'
),
url
(
r'^
list/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$
'
,
views
.
file_list
,
name
=
'file_list'
),
url
(
r'^upload/
(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$
'
,
views
.
file_upload
,
name
=
'file_upload'
),
url
(
r'^make_folder/'
,
views
.
make_folder
,
name
=
'make_folder'
),
]
\ No newline at end of file
...
...
dcloud/website/views.py
View file @
02357f2
...
...
@@ -3,25 +3,36 @@ from django.utils import timezone
from
django.contrib.auth.decorators
import
login_required
from
django.views.generic
import
FormView
from
restful.models
import
File
from
django.views
import
View
from
django.core.files.base
import
ContentFile
from
django.middleware
import
csrf
import
requests
def
home
(
request
):
return
render
(
request
,
'website/home.html'
)
@login_required
def
file_list
(
request
):
def
file_list
(
request
,
path
):
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
files
=
requests
.
get
(
'http://localhost:8000/restapi/list/'
,
cookies
=
cookies
)
return
render
(
request
,
'website/file_list.html'
,
files
.
json
())
files
=
requests
.
get
(
'http://localhost:8000/restapi/list/'
+
path
,
cookies
=
cookies
)
ret
=
files
.
json
()
ret
[
'path'
]
=
path
return
render
(
request
,
'website/file_list.html'
,
ret
)
def
file_upload
(
request
):
@login_required
def
file_upload
(
request
,
path
):
file
=
request
.
FILES
.
get
(
'file'
)
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
requests
.
post
(
'http://localhost:8000/restapi/list/'
,
request
,
cookies
=
cookies
)
return
redirect
(
'file_list'
)
cookies
[
'csrftoken'
]
=
csrf
.
get_token
(
request
)
headers
=
{
'X-CSRFToken'
:
cookies
[
'csrftoken'
]}
print
(
cookies
)
requests
.
post
(
'http://localhost:8000/restapi/list/'
,
files
=
{
'file'
:
file
},
headers
=
headers
,
cookies
=
cookies
)
return
redirect
(
'file_list'
,
path
=
path
)
def
make_folder
(
request
):
def
make_folder
(
request
,
path
):
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
files
=
requests
.
put
(
'http://localhost:8000/restapi/list/'
,
cookies
=
cookies
)
return
redirect
(
'file_list'
)
files
=
requests
.
put
(
'http://localhost:8000/restapi/list/'
+
path
,
cookies
=
cookies
)
return
redirect
(
'file_list'
,
path
=
path
)
...
...
Please
register
or
login
to post a comment