Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
8 deletions
+50
-8
cloud/urls.py
+1
-0
one/static/cloud.js
+19
-5
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('',
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/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,7 +118,16 @@ $(function(){
type
:
'fájl'
,
mTime
:
d
.
MTIME
,
getTypeClass
:
'name filetype-text'
,
clickHandler
:
function
(
item
){
clickHandler
:
function
(
item
,
event
){
}
};
}
}
self
.
files
(
viewData
);
}
self
.
currentPath
=
ko
.
observable
(
'/'
);
self
.
download
=
function
(
item
){
$
.
ajax
({
type
:
'POST'
,
data
:
'dl='
+
self
.
currentPath
()
+
item
.
originalName
,
...
...
@@ -129,12 +138,17 @@ $(function(){
}
})
}
};
}
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
());
}
self
.
files
(
viewData
);
})
}
self
.
currentPath
=
ko
.
observable
(
'/'
);
loadFolder
(
self
.
currentPath
());
}
var
model
=
new
Model
();
...
...
one/templates/home.html
View file @
16c72327
...
...
@@ -209,9 +209,15 @@
<div
class=
"name"
data-bind=
"text: name, attr: {class: getTypeClass}"
></div>
<div
class=
"info"
data-bind=
"text: size"
></div>
<div
class=
"actions"
>
<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=
"#"
data-bind=
"click: clickHandler"
><img
src=
"/static/icons/download-cloud.png"
alt=
"download"
/></a>
<a
href=
"#"
>
<img
src=
"/static/icons/pencil.png"
alt=
"rename"
/>
</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
class=
"clear"
></div>
</div>
...
...
store/views.py
View file @
16c72327
...
...
@@ -115,6 +115,27 @@ def ajax_download(request):
return
HttpResponse
(
'File not found!'
,
status_code
=
404
)
@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
):
user
=
request
.
user
.
username
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