users: Don't show Create User form to non-admin users

For non-admin users, the subsubmenu containing both Edit and Create forms is
shown. Removed the subsubmenu so that only the update form is shown.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-06-21 20:34:46 +05:30 committed by James Valleroy
parent f0157f7d3e
commit 15c7202a6b
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -123,6 +123,13 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
"""Return the URL to redirect to in case of successful updation."""
return reverse('users:edit', kwargs={'slug': self.object.username})
def get_context_data(self, **kwargs):
"""Use self.title and the module-level subsubmenu"""
context = super(UserUpdate, self).get_context_data(**kwargs)
if not is_user_admin(self.request):
del context['subsubmenu']
return context
class UserDelete(ContextMixin, DeleteView):
"""Handle deleting users, showing a confirmation dialog first.