From 15c7202a6b4bc8ee49a3239ee2658e0dca702157 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 21 Jun 2018 20:34:46 +0530 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/modules/users/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index 7dd977e7f..bd72bd2b0 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -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.