Skip to content

Commit

Permalink
Fix control of form initial.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti committed Oct 31, 2023
1 parent d8e7395 commit e3b6592
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions g3w-admin/usersmanage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,12 @@ def save(self, commit=True):

# Add gusers to the group
# -----------------------
gusers_to_remove = list(set(self.initial['guser']) - set(self.cleaned_data['gusers']))
gusers_to_add = list(set(self.cleaned_data['gusers']) - set(self.initial['guser']))
gusers_to_remove = []
gusers_to_add = self.cleaned_data['gusers']
if 'gusers'in self.initial:
gusers_to_remove = list(set(self.initial['guser']) - set(self.cleaned_data['gusers']))
gusers_to_add = list(set(self.cleaned_data['gusers']) - set(self.initial['guser']))

for gu in gusers_to_add:
instance.user_set.add(User.objects.get(pk=gu))
for gu in gusers_to_remove:
Expand Down

0 comments on commit e3b6592

Please sign in to comment.