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
Commit
16c72327
authored
Jan 31, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: ajax delete files
parent
ffd2f97b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
13 deletions
+55
-13
cloud/urls.py
+1
-0
one/static/cloud.js
+24
-10
one/templates/home.html
+9
-3
store/views.py
+21
-0
No files found.
cloud/urls.py
View file @
16c72327
...
@@ -29,4 +29,5 @@ urlpatterns = patterns('',
...
@@ -29,4 +29,5 @@ urlpatterns = patterns('',
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'
),
url
(
r'^ajax/store/download$'
,
'store.views.ajax_download'
,
name
=
'store_ajax_download'
),
url
(
r'^ajax/store/delete$'
,
'store.views.ajax_delete'
,
name
=
'store_ajax_delete'
),
)
)
one/static/cloud.js
View file @
16c72327
...
@@ -118,16 +118,7 @@ $(function(){
...
@@ -118,16 +118,7 @@ $(function(){
type
:
'fájl'
,
type
:
'fájl'
,
mTime
:
d
.
MTIME
,
mTime
:
d
.
MTIME
,
getTypeClass
:
'name filetype-text'
,
getTypeClass
:
'name filetype-text'
,
clickHandler
:
function
(
item
){
clickHandler
:
function
(
item
,
event
){
$
.
ajax
({
type
:
'POST'
,
data
:
'dl='
+
self
.
currentPath
()
+
item
.
originalName
,
url
:
'/ajax/store/download'
,
dataType
:
'json'
,
success
:
function
(
data
){
window
.
location
.
href
=
data
.
url
;
}
})
}
}
};
};
}
}
...
@@ -135,6 +126,29 @@ $(function(){
...
@@ -135,6 +126,29 @@ $(function(){
self
.
files
(
viewData
);
self
.
files
(
viewData
);
}
}
self
.
currentPath
=
ko
.
observable
(
'/'
);
self
.
currentPath
=
ko
.
observable
(
'/'
);
self
.
download
=
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
;
}
})
}
self
.
delete
=
function
(
item
){
$
.
ajax
({
type
:
'POST'
,
data
:
'rm='
+
self
.
currentPath
()
+
item
.
originalName
,
url
:
'/ajax/store/delete'
,
dataType
:
'json'
,
success
:
function
(
data
){
loadFolder
(
self
.
currentPath
());
}
})
}
loadFolder
(
self
.
currentPath
());
loadFolder
(
self
.
currentPath
());
}
}
var
model
=
new
Model
();
var
model
=
new
Model
();
...
...
one/templates/home.html
View file @
16c72327
...
@@ -209,9 +209,15 @@
...
@@ -209,9 +209,15 @@
<div
class=
"name"
data-bind=
"text: name, attr: {class: getTypeClass}"
></div>
<div
class=
"name"
data-bind=
"text: name, attr: {class: getTypeClass}"
></div>
<div
class=
"info"
data-bind=
"text: size"
></div>
<div
class=
"info"
data-bind=
"text: size"
></div>
<div
class=
"actions"
>
<div
class=
"actions"
>
<a
href=
"#"
><img
src=
"/static/icons/pencil.png"
alt=
"rename"
/></a>
<a
href=
"#"
>
<a
href=
"#"
><img
src=
"/static/icons/minus-circle.png"
alt=
"delete"
/></a>
<img
src=
"/static/icons/pencil.png"
alt=
"rename"
/>
<a
href=
"#"
data-bind=
"click: clickHandler"
><img
src=
"/static/icons/download-cloud.png"
alt=
"download"
/></a>
</a>
<a
href=
"#"
data-bind=
"click: $parent.delete, clickBubble: false"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"delete"
/>
</a>
<a
href=
"#"
data-bind=
"click: $parent.download, clickBubble: false"
>
<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 @
16c72327
...
@@ -115,6 +115,27 @@ def ajax_download(request):
...
@@ -115,6 +115,27 @@ def ajax_download(request):
return
HttpResponse
(
'File not found!'
,
status_code
=
404
)
return
HttpResponse
(
'File not found!'
,
status_code
=
404
)
@login_required
@login_required
def
ajax_delete
(
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
:
rm
=
request
.
POST
[
'rm'
]
return
HttpResponse
(
json
.
dumps
({
'success'
:
StoreApi
.
requestremove
(
user
,
rm
)}))
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