summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
Diffstat (limited to 'module/web')
-rw-r--r--module/web/ajax/urls.py2
-rw-r--r--module/web/ajax/views.py43
2 files changed, 22 insertions, 23 deletions
diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py
index 0db240578..d1c90aa21 100644
--- a/module/web/ajax/urls.py
+++ b/module/web/ajax/urls.py
@@ -16,4 +16,6 @@ urlpatterns = patterns('ajax',
(r'^status$', 'views.status'),
(r'^links$', 'views.links'),
(r'^queue$', 'views.queue'),
+ (r'^pause$', 'views.pause'),
+ (r'^unpause$', 'views.unpause'),
) \ No newline at end of file
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index c4395a659..05c91597f 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -6,28 +6,7 @@ from django.conf import settings
from django.shortcuts import render_to_response
from django.utils import simplejson
from django.core.serializers import json
-
-def check_server(function):
- def _dec(view_func):
- def _view(request, *args, **kwargs):
- try:
- version = settings.PYLOAD.get_server_version()
- except Exception, e:
- return HttpResponseServerError()
-
- return view_func(request, *args, **kwargs)
-
- _view.__name__ = view_func.__name__
- _view.__dict__ = view_func.__dict__
- _view.__doc__ = view_func.__doc__
-
- return _view
-
- if function is None:
- return _dec
- else:
- return _dec(function)
-
+
def permission(perm):
def _dec(view_func):
def _view(request, *args, **kwargs):
@@ -80,4 +59,22 @@ def queue(request):
return JsonResponse(settings.PYLOAD.get_queue())
except:
- return HttpResponseServerError() \ No newline at end of file
+ return HttpResponseServerError()
+
+
+@permission('pyload.can_change_satus')
+def pause(request):
+ try:
+ return JsonResponse(settings.PYLOAD.pause_server())
+
+ except:
+ return HttpResponseServerError()
+
+
+@permission('pyload.can_change_status')
+def unpause(request):
+ try:
+ return JsonResponse(settings.PYLOAD.unpause_server())
+
+ except:
+ return HttpResponseServerError()