mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
+10
-5
@@ -37,9 +37,11 @@ class DomainAliasForm(ProxyForm):
|
||||
class MailboxForm(ProxyForm):
|
||||
quota = forms.IntegerField(label=_("Quota"), required=False,
|
||||
help_text=_("Mailbox quota in MB (default to domain quota if blank)"))
|
||||
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput,
|
||||
password1 = forms.CharField(label=_("Password"),
|
||||
widget=forms.PasswordInput(render_value=True),
|
||||
help_text=_("Password used to log in"))
|
||||
password2 = forms.CharField(label=_("Confirmation"), widget=forms.PasswordInput,
|
||||
password2 = forms.CharField(label=_("Confirmation"),
|
||||
widget=forms.PasswordInput(render_value=True),
|
||||
help_text=_("Password confirmation"))
|
||||
enabled = forms.BooleanField(label=gender("Enabled", "f"), required=False,
|
||||
initial=True,
|
||||
@@ -73,12 +75,15 @@ class MailboxForm(ProxyForm):
|
||||
raise forms.ValidationError(_("Passwords mismatch"))
|
||||
return self.cleaned_data["password2"]
|
||||
|
||||
def commit_save(self, mb):
|
||||
mb.save(enabled=self.cleaned_data["enabled"],
|
||||
password=self.cleaned_data["password1"],
|
||||
quota=self.cleaned_data["quota"])
|
||||
|
||||
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"],
|
||||
quota=self.cleaned_data["quota"])
|
||||
self.commit_save(m)
|
||||
return m
|
||||
|
||||
class AliasForm(ProxyForm):
|
||||
|
||||
+3
-5
@@ -299,7 +299,6 @@ def newmailbox(request, tplname="admin/adminform.html"):
|
||||
@login_required
|
||||
@good_domain
|
||||
@permission_required("admin.change_mailbox")
|
||||
@transaction.commit_manually
|
||||
def editmailbox(request, mbox_id=None, tplname="admin/adminform.html"):
|
||||
mb = Mailbox.objects.get(pk=mbox_id)
|
||||
commonctx = {"title" : _("Mailbox editing"),
|
||||
@@ -312,19 +311,18 @@ def editmailbox(request, mbox_id=None, tplname="admin/adminform.html"):
|
||||
error = None
|
||||
if form.is_valid():
|
||||
try:
|
||||
mb = form.save()
|
||||
mb = form.save(commit=False)
|
||||
except AdminError, inst:
|
||||
error = str(inst)
|
||||
else:
|
||||
if oldmb.rename_dir(mb.domain.name, mb.address):
|
||||
transaction.commit()
|
||||
form.commit_save(mb)
|
||||
events.raiseEvent("ModifyMailbox", mbox=mb, oldmbox=oldmb)
|
||||
messages.info(request, _("Mailbox modified"),
|
||||
fail_silently=True)
|
||||
return ajax_response(request, url=reverse(admin.views.mailboxes) + "?domid=%d" % mb.domain.id)
|
||||
error = _("Failed to rename mailbox, check permissions")
|
||||
if error is not None:
|
||||
transaction.rollback()
|
||||
|
||||
commonctx["form"] = form
|
||||
commonctx["error"] = error
|
||||
return ajax_response(request, status="ko", template=tplname, **commonctx)
|
||||
|
||||
@@ -3,6 +3,11 @@ from modoboa.admin.models import Mailbox
|
||||
from modoboa.lib import _check_password
|
||||
|
||||
class SimpleBackend:
|
||||
|
||||
supports_object_permissions = False
|
||||
supports_anonymous_user = False
|
||||
supports_inactive_user = False
|
||||
|
||||
def authenticate(self, username=None, password=None):
|
||||
try:
|
||||
user = User.objects.get(username=username)
|
||||
|
||||
Reference in New Issue
Block a user