groups: Consistent listing of groups

- Remove conditional registration of groups on module initialization.
- Create uninitialized groups on addition/update of groups for user.
- Remove group creation on setup/installation of a module.

Tested for:
- Multi registration of groups.
- Manual UI test to check visibility of groups irrespective of whether module is
  installed/enabled.

Signed-off-by: Aakanksha Saini <aakanksa@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Aakanksha Saini authored and Sunil Mohan Adapa committed 2018-01-12 14:42:43 +05:30
1 parent 834737d9dc
commit 0dea420ffe
7 files changed
+47 -13

No files matched your search

+2
View File
@@ -109,6 +109,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin, UserCreationForm):
for group in self.cleaned_data['groups']:
try:
users.create_group(group)
actions.superuser_run('users', [
'add-user-to-group',
user.get_username(), group
@@ -205,6 +206,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, forms.ModelForm):
for new_group in new_groups:
if new_group not in old_groups:
try:
users.create_group(new_group)
actions.superuser_run('users', [
'add-user-to-group',
user.get_username(), new_group