diff options
Diffstat (limited to 'module/web/ajax/views.py')
-rw-r--r-- | module/web/ajax/views.py | 44 |
1 files changed, 39 insertions, 5 deletions
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 |