Guest User

Untitled

a guest
Feb 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. def rights_needed(reguest):
  2. if request.user.groups.filter(Q(name='Admin')).exists():
  3. pass
  4. else:
  5. return HttpResponseRedirect('/account/log-in/')
  6.  
  7. @method_decorator(right_needed, name='dispatch')
  8. class AdminView(CreateView):
  9. model = Admin
  10. form_class = AdminForm
  11. def get_template_names(self):
  12. return 'clinic/visitform_list.html'
  13.  
  14. def dispatch(self, request):
  15. if request.user.groups.filter(Q(name='Admin')).exists():
  16. return super().dispatch(*args, **kwargs)
  17. else:
  18. return HttpResponseRedirect('/account/log-in/')
Add Comment
Please, Sign In to add comment