Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
ffd2f97b
authored
Jan 31, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: ajax download
parent
3268f041
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
cloud/urls.py
+1
-0
one/static/cloud.js
+11
-2
one/templates/home.html
+1
-1
store/views.py
+21
-1
No files found.
cloud/urls.py
View file @
ffd2f97b
...
@@ -28,4 +28,5 @@ urlpatterns = patterns('',
...
@@ -28,4 +28,5 @@ urlpatterns = patterns('',
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
url
(
r'^ajax/templateWizard$'
,
'one.views.ajax_template_wizard'
,
name
=
'ajax_template_wizard'
),
url
(
r'^ajax/templateWizard$'
,
'one.views.ajax_template_wizard'
,
name
=
'ajax_template_wizard'
),
url
(
r'^ajax/store/list$'
,
'store.views.ajax_listfolder'
,
name
=
'store_ajax_listfolder'
),
url
(
r'^ajax/store/list$'
,
'store.views.ajax_listfolder'
,
name
=
'store_ajax_listfolder'
),
url
(
r'^ajax/store/download$'
,
'store.views.ajax_download'
,
name
=
'store_ajax_download'
),
)
)
one/static/cloud.js
View file @
ffd2f97b
...
@@ -112,13 +112,22 @@ $(function(){
...
@@ -112,13 +112,22 @@ $(function(){
};
};
}
else
{
}
else
{
viewData
[
i
]
=
{
viewData
[
i
]
=
{
originalName
:
d
.
NAME
,
name
:
d
.
NAME
.
length
>
30
?(
d
.
NAME
.
substr
(
0
,
27
)
+
'...'
):
d
.
NAME
,
name
:
d
.
NAME
.
length
>
30
?(
d
.
NAME
.
substr
(
0
,
27
)
+
'...'
):
d
.
NAME
,
size
:
data
[
i
].
SIZE
+
'K'
,
size
:
data
[
i
].
SIZE
+
'K'
,
type
:
'fájl'
,
type
:
'fájl'
,
mTime
:
d
.
MTIME
,
mTime
:
d
.
MTIME
,
getTypeClass
:
'name filetype-text'
,
getTypeClass
:
'name filetype-text'
,
clickHandler
:
function
(){
clickHandler
:
function
(
item
){
$
.
ajax
({
type
:
'POST'
,
data
:
'dl='
+
self
.
currentPath
()
+
item
.
originalName
,
url
:
'/ajax/store/download'
,
dataType
:
'json'
,
success
:
function
(
data
){
window
.
location
.
href
=
data
.
url
;
}
})
}
}
};
};
}
}
...
...
one/templates/home.html
View file @
ffd2f97b
...
@@ -211,7 +211,7 @@
...
@@ -211,7 +211,7 @@
<div
class=
"actions"
>
<div
class=
"actions"
>
<a
href=
"#"
><img
src=
"/static/icons/pencil.png"
alt=
"rename"
/></a>
<a
href=
"#"
><img
src=
"/static/icons/pencil.png"
alt=
"rename"
/></a>
<a
href=
"#"
><img
src=
"/static/icons/minus-circle.png"
alt=
"delete"
/></a>
<a
href=
"#"
><img
src=
"/static/icons/minus-circle.png"
alt=
"delete"
/></a>
<a
href=
"#"
><img
src=
"/static/icons/download-cloud.png"
alt=
"download"
/></a>
<a
href=
"#"
data-bind=
"click: clickHandler"
><img
src=
"/static/icons/download-cloud.png"
alt=
"download"
/></a>
</div>
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
...
...
store/views.py
View file @
ffd2f97b
...
@@ -68,7 +68,6 @@ def index(request):
...
@@ -68,7 +68,6 @@ def index(request):
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
@csrf_exempt
@login_required
@login_required
def
ajax_listfolder
(
request
):
def
ajax_listfolder
(
request
):
user
=
request
.
user
.
username
user
=
request
.
user
.
username
...
@@ -95,6 +94,27 @@ def ajax_listfolder(request):
...
@@ -95,6 +94,27 @@ def ajax_listfolder(request):
return
HttpResponse
(
json
.
dumps
(
file_list
))
return
HttpResponse
(
json
.
dumps
(
file_list
))
@login_required
@login_required
def
ajax_download
(
request
):
user
=
request
.
user
.
username
try
:
details
=
request
.
user
.
userclouddetails_set
.
all
()[
0
]
password
=
details
.
smb_password
key_list
=
[]
for
key
in
request
.
user
.
sshkey_set
.
all
():
key_list
.
append
(
key
.
key
)
except
:
return
HttpResponse
(
'Can not acces to django database!'
,
status_code
=
404
)
if
StoreApi
.
userexist
(
user
)
!=
True
:
if
not
StoreApi
.
createuser
(
user
,
password
,
key_list
):
return
HttpResponse
(
'User does not exist on store! And could not create!'
,
status_code
=
404
)
try
:
dl
=
request
.
POST
[
'dl'
]
return
HttpResponse
(
json
.
dumps
({
'url'
:
StoreApi
.
requestdownload
(
user
,
dl
)}))
except
:
pass
return
HttpResponse
(
'File not found!'
,
status_code
=
404
)
@login_required
def
toplist
(
request
):
def
toplist
(
request
):
user
=
request
.
user
.
username
user
=
request
.
user
.
username
path
=
backpath
=
'/'
path
=
backpath
=
'/'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment