Commit b7dc0d0a by Dányi Bence

store: ajax rename

parent 8196afc6
...@@ -34,4 +34,5 @@ urlpatterns = patterns('', ...@@ -34,4 +34,5 @@ urlpatterns = patterns('',
url(r'^ajax/store/delete$', 'store.views.ajax_delete', name='store_ajax_delete'), url(r'^ajax/store/delete$', 'store.views.ajax_delete', name='store_ajax_delete'),
url(r'^ajax/store/newFolder$', 'store.views.ajax_new_folder', name='store_ajax_new_folder'), url(r'^ajax/store/newFolder$', 'store.views.ajax_new_folder', name='store_ajax_new_folder'),
url(r'^ajax/store/quota$', 'store.views.ajax_quota', name='store_ajax_quota'), url(r'^ajax/store/quota$', 'store.views.ajax_quota', name='store_ajax_quota'),
url(r'^ajax/store/rename$', 'store.views.ajax_rename', name='store_ajax_rename'),
) )
...@@ -203,7 +203,16 @@ $(function() { ...@@ -203,7 +203,16 @@ $(function() {
<input type="submit" value="Átnevezés" />'); <input type="submit" value="Átnevezés" />');
$(e.target).parent().parent().parent().find('.name input[type=submit]').click(function() { $(e.target).parent().parent().parent().find('.name input[type=submit]').click(function() {
var newName = $(e.target).parent().parent().parent().find('.name input[type=text]').val(); var newName = $(e.target).parent().parent().parent().find('.name input[type=text]').val();
$.ajax({
type: 'POST',
data: 'path='+self.currentPath()+item.originalName+'&new='+newName,
url: '/ajax/store/rename',
dataType: 'json',
success: function(data){
console.log(data);
loadFolder(self.currentPath()); loadFolder(self.currentPath());
}
})
}) })
} }
self.uploadURL = ko.observable('/'); self.uploadURL = ko.observable('/');
......
...@@ -101,7 +101,11 @@ ...@@ -101,7 +101,11 @@
<div class="used" style="background-color: rgba(0,255,0,0.2)" data-bind="style: {width: quota.usedBar}"></div> <div class="used" style="background-color: rgba(0,255,0,0.2)" data-bind="style: {width: quota.usedBar}"></div>
<div class="softLimit" data-bind="style: {left: quota.softPos}"></div> <div class="softLimit" data-bind="style: {left: quota.softPos}"></div>
</div> </div>
<div class="name">Kvóta: <span data-bind="text: quota.used"></span>/<span data-bind="text: quota.hard"></span></div> <div class="name">
Kvóta: <span data-bind="text: quota.used"></span>/
<abbr data-bind="text: quota.soft" title="Soft limit"></abbr>
(<abbr title="Hard limit" data-bind="text: quota.hard"></abbr>)
</div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</li> </li>
......
...@@ -128,6 +128,16 @@ class StoreApi: ...@@ -128,6 +128,16 @@ class StoreApi:
else: else:
return False return False
@staticmethod @staticmethod
def requestrename(neptun, old_path, new_name):
url = settings['store_url']+'/'+neptun
payload = json.dumps({'CMD':'RENAME','NEW_NAME':new_name,'PATH':old_path})
headers = {'content-type': 'application/json'}
r = StoreApi.post_request(url, payload)
if r.status_code == requests.codes.ok:
return True
else:
return False
@staticmethod
def requestquota(neptun): def requestquota(neptun):
url = settings['store_url']+'/'+neptun url = settings['store_url']+'/'+neptun
r = StoreApi.get_request(url) r = StoreApi.get_request(url)
......
...@@ -149,6 +149,18 @@ def ajax_new_folder(request): ...@@ -149,6 +149,18 @@ def ajax_new_folder(request):
return HttpResponse('Error!', status_code=404) return HttpResponse('Error!', status_code=404)
@login_required @login_required
def ajax_rename(request):
user = request.user.username
try:
path = request.POST['path']
new = request.POST['new']
success = StoreApi.requestrename(user,path,new)
return HttpResponse(json.dumps({'success':success}))
except:
pass
return HttpResponse('Error!', 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