From 6118bc30e5559de2a9e2a6d1be8f1caf00811b71 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 10 Dec 2020 11:28:10 +0100 Subject: [PATCH] manager: do without disabled add user button on users page (#45338) --- src/authentic2/manager/forms.py | 5 ++-- .../templates/authentic2/manager/users.html | 12 ++------ src/authentic2/manager/urls.py | 2 ++ src/authentic2/manager/user_views.py | 29 ++++++++++++++++++- tests/test_user_manager.py | 15 ++++++++++ 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/authentic2/manager/forms.py b/src/authentic2/manager/forms.py index 34362eb2..28f082eb 100644 --- a/src/authentic2/manager/forms.py +++ b/src/authentic2/manager/forms.py @@ -420,7 +420,7 @@ class OUSearchForm(FormWithRequest): # - show all if show_all_ou is True and user has ou_permission over all OUs or more than # one, # - show searchable OUs - # - show none if user has ou_permission over all OUs + # - show none if user has ou_permission over all OUs and show_none_ou is True # - when no choice is made, # - show all ou is show_all_ou is True (including None if user has ou_permission over all # OUs) @@ -431,6 +431,7 @@ class OUSearchForm(FormWithRequest): all_ou_label = kwargs.pop('all_ou_label', pgettext('organizational unit', 'All')) self.queryset = kwargs.pop('queryset', None) self.show_all_ou = kwargs.pop('show_all_ou', True) + self.show_none_ou = kwargs.pop('show_none_ou', True) request = kwargs['request'] self.ou_count = utils.get_ou_count() @@ -462,7 +463,7 @@ class OUSearchForm(FormWithRequest): choices.append(('all', all_ou_label)) for ou in self.ou_qs: choices.append((str(ou.pk), six.text_type(ou))) - if self.search_all_ous: + if self.show_none_ou and self.search_all_ous: choices.append(('none', pgettext('organizational unit', 'None'))) # if user does not have ou_permission over all OUs, select user OU as default selected diff --git a/src/authentic2/manager/templates/authentic2/manager/users.html b/src/authentic2/manager/templates/authentic2/manager/users.html index 7d4ff5be..a648a6b7 100644 --- a/src/authentic2/manager/templates/authentic2/manager/users.html +++ b/src/authentic2/manager/templates/authentic2/manager/users.html @@ -7,20 +7,12 @@ {{ block.super }} - {% if add_ou %} {% trans "Add user" %} - {% else %} - - {% trans "Add user" %} - - {% endif %} {% if extra_actions %}