Commit 16c72327 by Dányi Bence

store: ajax delete files

parent ffd2f97b
...@@ -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'),
) )
...@@ -118,7 +118,16 @@ $(function(){ ...@@ -118,7 +118,16 @@ $(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){
}
};
}
}
self.files(viewData);
}
self.currentPath=ko.observable('/');
self.download=function(item){
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: 'dl='+self.currentPath()+item.originalName, data: 'dl='+self.currentPath()+item.originalName,
...@@ -129,12 +138,17 @@ $(function(){ ...@@ -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()); loadFolder(self.currentPath());
} }
var model=new Model(); var model=new Model();
......
...@@ -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>
......
...@@ -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 = '/'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment