diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-13 21:23:05 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-01-13 21:23:05 +0100 |
commit | 9cce347134cffb8e3e920d94768306c2156dddee (patch) | |
tree | 8c119eb15cac2eaac99fbf0548ffe7c116127fc4 /module/web/ajax | |
parent | queue template + view (diff) | |
download | pyload-9cce347134cffb8e3e920d94768306c2156dddee.tar.xz |
some webinterface improvements, closed #40
Diffstat (limited to 'module/web/ajax')
-rw-r--r-- | module/web/ajax/urls.py | 1 | ||||
-rw-r--r-- | module/web/ajax/views.py | 20 |
2 files changed, 16 insertions, 5 deletions
diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py index 2a7e109c3..4decc27b1 100644 --- a/module/web/ajax/urls.py +++ b/module/web/ajax/urls.py @@ -12,6 +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'^status$', 'views.status'), (r'^links$', 'views.links'), #currently active links (r'^queue$', 'views.queue'), diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 08d87c30e..ea092745f 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -30,7 +30,7 @@ class JsonResponse(HttpResponse): object, indent=2, cls=json.DjangoJSONEncoder, ensure_ascii=False) super(JsonResponse, self).__init__( - content)#, content_type='application/json') #@TODO uncomment + content, content_type='application/json') #@TODO uncomment self['Cache-Control'] = 'no-cache, must-revalidate' @@ -38,14 +38,17 @@ class JsonResponse(HttpResponse): def add_package(request): name = request.POST['add_name'] + if name == None or name == "": return HttpResponseServerError() - links = request.POST['add_links'].split("\n") + links = request.POST['add_links'].replace(" ","\n").split("\n") try: f = request.FILES['add_file'] + print f fpath = join(settings.DL_ROOT, f.name) + print fpath destination = open(fpath, 'wb') for chunk in f.chunks(): destination.write(chunk) @@ -54,12 +57,19 @@ def add_package(request): except: pass - links = filter(lambda x: x is not "", links) - - settings.PYLOAD.add_package(name, links) + links = filter(lambda x: x != "", links) + settings.PYLOAD.add_package(name, links) + return JsonResponse("success") +@permission('pyload.can_add_dl') +def remove_link(request, id): + try: + settings.PYLOAD.del_links([int(id)]) + return JsonResponse("sucess") + except: + return HttpResponseServerError() @permission('pyload.can_see_dl') def status(request): |