mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-20 06:08:35 +02:00
see #103
Work in progress: * New domains admin page, all menus are now at the same level, * Views, models and forms partial refactoring (better code organization).
This commit is contained in:
+16
-1
@@ -32,7 +32,7 @@ class MailboxForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Mailbox
|
||||
fields = ('name', 'address')
|
||||
fields = ('domain', 'name', 'address')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MailboxForm, self).__init__(*args, **kwargs)
|
||||
@@ -49,6 +49,13 @@ class MailboxForm(forms.ModelForm):
|
||||
raise forms.ValidationError(_("Passwords mismatch"))
|
||||
return self.cleaned_data["password2"]
|
||||
|
||||
def save(self, force_insert=False, force_update=False, commit=True):
|
||||
m = super(MailboxForm, self).save(commit=False)
|
||||
if commit:
|
||||
m.save(enabled=self.cleaned_data["enabled"],
|
||||
password=self.cleaned_data["password1"])
|
||||
return m
|
||||
|
||||
class AliasForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
domain = None
|
||||
@@ -70,6 +77,14 @@ class AliasForm(forms.ModelForm):
|
||||
return self.cleaned_data["address"].rsplit("@", 1)[0]
|
||||
return self.cleaned_data["address"]
|
||||
|
||||
def save(self, force_insert=False, force_update=False, commit=True):
|
||||
a = super(AliasForm, self).save(commit=False)
|
||||
if commit:
|
||||
domain = self.cleaned_data["mboxes"][0].domain
|
||||
a.full_address = "%s@%s" % (a.address, domain.name)
|
||||
a.save()
|
||||
return a
|
||||
|
||||
class SuperAdminForm(forms.Form):
|
||||
user = forms.ModelChoiceField([], label=_("User"), required=True,
|
||||
empty_label=_("Select a user"),
|
||||
|
||||
Reference in New Issue
Block a user