users: Update Change Password menu for non-admin users

Don't show Create User menu item to non-admin users. Previously this
was fixed for the Edit User page, and this fixes it also for the
Change Password page.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy 2018-06-26 21:41:34 -04:00
parent 15c7202a6b
commit 4dc83f135a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -201,6 +201,13 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
update_session_auth_hash(self.request, form.user)
return super(UserChangePassword, self).form_valid(form)
def get_context_data(self, **kwargs):
"""Remove subsubmenu for non-admin users."""
context = super(UserChangePassword, self).get_context_data(**kwargs)
if not is_user_admin(self.request):
del context['subsubmenu']
return context
class FirstBootView(django.views.generic.CreateView):
"""Create user account and log the user in."""