diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-20 19:41:43 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-20 19:41:43 +0100 |
commit | 07f280a220ab5bc5c3fb510ea00aecedfcec7564 (patch) | |
tree | 0a902013984fa8aee01ce162e437ee2dfd988e84 /module/web/ajax | |
parent | webinterface - status icons (diff) | |
download | pyload-07f280a220ab5bc5c3fb510ea00aecedfcec7564.tar.xz |
queue page fully functional, some fixes
Diffstat (limited to 'module/web/ajax')
-rw-r--r-- | module/web/ajax/urls.py | 6 | ||||
-rw-r--r-- | module/web/ajax/views.py | 44 |
2 files changed, 44 insertions, 6 deletions
diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py index 7d63ef5a6..d50e7121e 100644 --- a/module/web/ajax/urls.py +++ b/module/web/ajax/urls.py @@ -12,7 +12,7 @@ urlpatterns = patterns('ajax', # Uncomment the next line to enable the admin: (r'^add_package$', 'views.add_package'), - (r'^remove_link/(\d+)$', 'views.remove_link'), + (r'^abort_link/(\d+)$', 'views.abort_link'), (r'^status$', 'views.status'), (r'^links$', 'views.links'), #currently active links (r'^queue$', 'views.queue'), @@ -22,4 +22,8 @@ urlpatterns = patterns('ajax', (r'^packages$', 'views.packages'), (r'^package/(\d+)$', 'views.package'), (r'^link/(\d+)$', 'views.link'), + (r'^remove_package/(\d+)$', 'views.remove_package'), + (r'^restart_package/(\d+)$', 'views.restart_package'), + (r'^remove_link/(\d+)$', 'views.remove_link'), + (r'^restart_link/(\d+)$', 'views.restart_link'), )
\ No newline at end of file diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 4f136cef9..4d9762ab4 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -39,16 +39,15 @@ def add_package(request): name = request.POST['add_name'] - if name == None or name == "": - return HttpResponseServerError() - links = request.POST['add_links'].replace(" ","\n").split("\n") try: f = request.FILES['add_file'] - print f + + if name == None or name == "": + name = f.name + fpath = join(settings.DL_ROOT, f.name) - print fpath destination = open(fpath, 'wb') for chunk in f.chunks(): destination.write(chunk) @@ -57,6 +56,9 @@ def add_package(request): except: pass + if name == None or name == "": + return HttpResponseServerError() + links = filter(lambda x: x != "", links) settings.PYLOAD.add_package(name, links) @@ -160,3 +162,35 @@ def link(request, id): except: return HttpResponseServerError() + +@permission('pyload.can_add_dl') +def remove_package(request, id): + try: + settings.PYLOAD.del_packages([int(id)]) + return JsonResponse("sucess") + except: + return HttpResponseServerError() + +@permission('pyload.can_add_dl') +def restart_package(request, id): + try: + settings.PYLOAD.restart_package(int(id)) + return JsonResponse("sucess") + except: + return HttpResponseServerError() + +@permission('pyload.can_add_dl') +def restart_link(request, id): + try: + settings.PYLOAD.restart_file(int(id)) + return JsonResponse("sucess") + except: + return HttpResponseServerError() + +@permission('pyload.can_add_dl') +def abort_link(request, id): + try: + settings.PYLOAD.stop_download("link", int(id)) + return JsonResponse("sucess") + except: + return HttpResponseServerError()
\ No newline at end of file |