Permalink
Browse files

Amavis extensions fixes.

  • Loading branch information...
tonioo committed Nov 10, 2014
1 parent f80141b commit 01d0641fd2a11074bdd83bb6ee6e02f5b2bc9e67
View
@@ -1 +1,2 @@
django-bower
django-debug-toolbar
@@ -18,8 +18,9 @@ class ParametersForm(AdminParametersForm):
max_messages_age = forms.IntegerField(
label=_("Maximum message age"),
initial=14,
help_text=_("Quarantine messages maximum age (in days) before deletion"),
widget=forms.TextInput(attrs={"class": "form-control"})
help_text=_(
"Quarantine messages maximum age (in days) before deletion"
)
)
sep1 = SeparatorField(label=_("Messages releasing"))
@@ -49,15 +50,13 @@ class ParametersForm(AdminParametersForm):
am_pdp_port = forms.IntegerField(
label=_("PDP server port"),
initial=9998,
help_text=_("PDP server port (if inet mode)"),
widget=forms.TextInput(attrs={"class": "form-control"})
help_text=_("PDP server port (if inet mode)")
)
am_pdp_socket = forms.CharField(
label=_("PDP server socket"),
initial="/var/amavis/amavisd.sock",
help_text=_("Path to the PDP server socket (if unix mode)"),
widget=forms.TextInput(attrs={"class": "form-control"})
help_text=_("Path to the PDP server socket (if unix mode)")
)
user_can_release = YesNoField(
@@ -75,8 +74,7 @@ class ParametersForm(AdminParametersForm):
notifications_sender = forms.EmailField(
label=_("Notifications sender"),
initial="notification@modoboa.org",
help_text=_("The e-mail address used to send notitications"),
widget=forms.TextInput(attrs={"class": "form-control"})
help_text=_("The e-mail address used to send notitications")
)
lsep = SeparatorField(label=_("Manual learning"))
@@ -160,6 +158,5 @@ class UserSettings(UserParametersForm):
messages_per_page = forms.IntegerField(
initial=40,
label=_("Number of displayed emails per page"),
help_text=_("Set the maximum number of messages displayed in a page"),
widget=forms.TextInput(attrs={"class": "form-control"})
help_text=_("Set the maximum number of messages displayed in a page")
)
@@ -9,7 +9,7 @@
create_user_and_use_policy, delete_user
)
from .lib import manual_learning_enabled
from .models import Users
from .models import Policy, Users
@events.observe("UserMenuDisplay")
@@ -76,7 +76,7 @@ def on_mailbox_deleted(mailbox):
"""Clean amavis database when a mailbox is removed."""
if parameters.get_admin("MANUAL_LEARNING") == "no":
return
delete_user_and_policy(mailbox.full_address)
delete_user_and_policy("@{0}".format(mailbox.full_address))
@events.observe("MailboxAliasCreated")
@@ -87,11 +87,15 @@ def on_mailboxalias_created(user, alias):
"""
if not manual_learning_enabled(user) or alias.type != "alias":
return
policy = Policy.objects.get(
policy_name=alias.mboxes.all()[0].full_address
)
email = alias.full_address
Users.objects.create(email=email, policy=policy, fullname=email)
try:
policy = Policy.objects.get(
policy_name=alias.mboxes.all()[0].full_address
)
except Policy.DoesNotExist:
return
else:
email = alias.full_address
Users.objects.create(email=email, policy=policy, fullname=email)
@events.observe("MailboxAliasDeleted")
@@ -248,7 +248,7 @@ def create_user_and_use_policy(name, policy_name, priority=7):
:param str name: user record name
:param str policy_name: policy name
"""
policy = Policy.objects.get(policy_name=policy_name[:32])
policy = Policy.objects.get(policy_name="@{0}".format(policy_name[:32]))
Users.objects.create(
email=name, fullname=name, priority=priority, policy=policy
)
@@ -21,7 +21,7 @@
var qm = new Quarantine({
deflocation: "listing/?sort_order=-date&reset_page=true",
defcallback: "listing_cb",
load_page_url: "{% url 'amavis:mail_page' %}"
load_page_url: "{% url 'amavis:mail_page' %}",
check_learning_rcpt: {{ check_learning_rcpt }},
learning_recipient_url: "{% url 'amavis:learning_recipient_set' %}"
});
@@ -116,7 +116,7 @@ def index(request):
domain_level_learning = parameters.get_admin(
"DOMAIN_LEVEL_LEARNING") == "yes"
if user_level_learning or domain_level_learning:
check_learning_rcpt = "true"
check_learning_rcpt = "true"
return render(request, "amavis/index.html", dict(
selection="quarantine", check_learning_rcpt=check_learning_rcpt
))

0 comments on commit 01d0641

Please sign in to comment.