Leave if the old group and the one are equals.

fix #354
This commit is contained in:
Antoine Nguyen
2012-12-25 10:14:10 +01:00
parent e9730097cb
commit f50c2904e2
+14 -11
View File
@@ -421,17 +421,20 @@ class AccountFormGeneral(forms.ModelForm):
role = self.cleaned_data["role"]
elif self.user.group == "DomainAdmins" and self.user != account:
role = "SimpleUsers"
if role is not None:
account.groups.clear()
if role == "SuperAdmins":
account.is_superuser = True
self.give_all_accesses(account)
else:
if account.is_superuser:
ObjectAccess.objects.filter(user=account).delete()
account.is_superuser = False
account.groups.add(Group.objects.get(name=role))
account.save()
if role is None or account.group == role:
return account
account.groups.clear()
if role == "SuperAdmins":
account.is_superuser = True
self.give_all_accesses(account)
else:
if account.is_superuser:
ObjectAccess.objects.filter(user=account).delete()
account.is_superuser = False
account.groups.add(Group.objects.get(name=role))
account.save()
return account
class AccountFormMail(forms.Form, DynamicForm):