From aea618c1bffe9ea6eb44b8555f17349b39dfe22b Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 16 Dec 2009 23:45:21 +0100 Subject: new functions for interacting with core --- module/web/ajax/views.py | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'module/web/ajax/views.py') 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() -- cgit v1.2.3