mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-04 12:24:09 +01:00
Few fixes about master users.
This commit is contained in:
@@ -133,18 +133,6 @@ class AccountFormGeneral(forms.ModelForm):
|
|||||||
validate_utf8_email(uname)
|
validate_utf8_email(uname)
|
||||||
return uname
|
return uname
|
||||||
|
|
||||||
def clean_master_user(self):
|
|
||||||
"""Check role before allowing this mode."""
|
|
||||||
conditions = (
|
|
||||||
self.cleaned_data["master_user"],
|
|
||||||
self.cleaned_data["role"] != "SuperAdmins"
|
|
||||||
)
|
|
||||||
if all(conditions):
|
|
||||||
raise forms.ValidationError(
|
|
||||||
_("Only super administrators are allowed for this mode")
|
|
||||||
)
|
|
||||||
return self.cleaned_data["master_user"]
|
|
||||||
|
|
||||||
def clean_password2(self):
|
def clean_password2(self):
|
||||||
password1 = self.cleaned_data.get("password1", "")
|
password1 = self.cleaned_data.get("password1", "")
|
||||||
password2 = self.cleaned_data["password2"]
|
password2 = self.cleaned_data["password2"]
|
||||||
@@ -153,6 +141,22 @@ class AccountFormGeneral(forms.ModelForm):
|
|||||||
_("The two password fields didn't match."))
|
_("The two password fields didn't match."))
|
||||||
return password2
|
return password2
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
"""Check master user mode."""
|
||||||
|
super(AccountFormGeneral, self).clean()
|
||||||
|
if self.errors:
|
||||||
|
return self.cleaned_data
|
||||||
|
condition = (
|
||||||
|
self.cleaned_data.get("master_user") and
|
||||||
|
self.cleaned_data["role"] != "SuperAdmins"
|
||||||
|
)
|
||||||
|
if condition:
|
||||||
|
self.add_error(
|
||||||
|
"master_user",
|
||||||
|
_("Only super administrators are allowed for this mode")
|
||||||
|
)
|
||||||
|
return self.cleaned_data
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
account = super(AccountFormGeneral, self).save(commit=False)
|
account = super(AccountFormGeneral, self).save(commit=False)
|
||||||
if self.user == account and not self.cleaned_data["is_active"]:
|
if self.user == account and not self.cleaned_data["is_active"]:
|
||||||
|
|||||||
@@ -436,7 +436,8 @@ Identities.prototype = {
|
|||||||
});
|
});
|
||||||
$("#id_email").addClass("disabled")
|
$("#id_email").addClass("disabled")
|
||||||
.attr("readonly", "")
|
.attr("readonly", "")
|
||||||
.autocompleter("unbind");
|
.autocompleter("unbind");
|
||||||
|
this.toggle_master_user();
|
||||||
},
|
},
|
||||||
|
|
||||||
normal_mode: function(group) {
|
normal_mode: function(group) {
|
||||||
|
|||||||
Reference in New Issue
Block a user