mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
context_processor: Cache whether user is admin (Closes: #781)
This commit is contained in:
1 parent
0adfae26d8
commit
6a53dd015e
5 files changed
+15
-7
No files matched your search
@@ -171,7 +171,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, forms.ModelForm):
|
||||
|
||||
super(UserUpdateForm, self).__init__(*args, **kwargs)
|
||||
|
||||
if not is_user_admin(request.user):
|
||||
if not is_user_admin(request):
|
||||
self.fields['is_active'].widget = forms.HiddenInput()
|
||||
self.fields['groups'].disabled = True
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Handle a request and return a HTTP response."""
|
||||
if self.request.user.get_username() != self.kwargs['slug'] \
|
||||
and not is_user_admin(self.request.user):
|
||||
and not is_user_admin(self.request):
|
||||
raise PermissionDenied
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
@@ -156,7 +156,7 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Handle a request and return a HTTP response."""
|
||||
if self.request.user.get_username() != self.kwargs['slug'] \
|
||||
and not is_user_admin(self.request.user):
|
||||
and not is_user_admin(self.request):
|
||||
raise PermissionDenied
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
Reference in new issue
Block a user