Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
f1nality committed Dec 6, 2016
2 parents 18d30a3 + 078d720 commit 3acd309
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jet/dashboard/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3acd309

Please sign in to comment.