Browse Source

Add is_staff check

Denis K 8 years ago
parent
commit
078d720df5
1 changed files with 5 additions and 1 deletions
  1. 5 1
      jet/dashboard/views.py

+ 5 - 1
jet/dashboard/views.py

@@ -1,4 +1,5 @@
 from django.contrib import messages
+from django.core.exceptions import ValidationError
 from django.core.urlresolvers import reverse
 from django.forms.formsets import formset_factory
 from django.http import HttpResponseRedirect
@@ -211,11 +212,14 @@ def load_dashboard_module_view(request, pk):
     result = {'error': False}
 
     try:
+        if not request.user.is_authenticated() or not request.user.is_staff:
+            raise ValidationError('error')
+
         instance = UserDashboardModule.objects.get(pk=pk, user=request.user.pk)
         module_cls = instance.load_module()
         module = module_cls(model=instance, context={'request': request})
         result['html'] = module.render()
-    except UserDashboardModule.DoesNotExist:
+    except (ValidationError, UserDashboardModule.DoesNotExist):
         result['error'] = True
 
     return JsonResponse(result)