2014-10-27 13:29:02 +00:00
|
|
|
import os
|
2014-10-09 17:04:12 +00:00
|
|
|
import textwrap
|
|
|
|
|
2015-04-29 10:51:30 +00:00
|
|
|
from django.utils.functional import lazy
|
|
|
|
from django.utils.safestring import mark_safe
|
2014-10-09 17:04:12 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2014-08-22 15:31:44 +00:00
|
|
|
|
2015-05-04 19:52:53 +00:00
|
|
|
from orchestra.contrib.settings import Setting
|
2015-04-27 12:24:17 +00:00
|
|
|
from orchestra.core.validators import validate_name
|
2015-05-04 19:52:53 +00:00
|
|
|
from orchestra.settings import ORCHESTRA_BASE_DOMAIN
|
2014-08-22 15:31:44 +00:00
|
|
|
|
|
|
|
|
2015-04-28 15:23:57 +00:00
|
|
|
_names = ('name', 'username',)
|
|
|
|
_backend_names = _names + ('user', 'group', 'home')
|
2015-04-29 10:51:30 +00:00
|
|
|
mark_safe_lazy = lazy(mark_safe, str)
|
2015-04-27 14:54:17 +00:00
|
|
|
|
|
|
|
|
2015-04-27 12:24:17 +00:00
|
|
|
MAILBOXES_DOMAIN_MODEL = Setting('MAILBOXES_DOMAIN_MODEL', 'domains.Domain',
|
|
|
|
validators=[Setting.validate_model_label]
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2014-08-22 15:31:44 +00:00
|
|
|
|
2015-03-31 12:39:08 +00:00
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_HOME = Setting('MAILBOXES_HOME',
|
2015-04-28 16:07:16 +00:00
|
|
|
'/home/%(name)s',
|
2015-04-27 14:54:17 +00:00
|
|
|
help_text="Available fromat names: <tt>%s</tt>" % ', '.join(_names),
|
|
|
|
validators=[Setting.string_format_validator(_names)],
|
|
|
|
)
|
2014-08-22 15:31:44 +00:00
|
|
|
|
2014-10-06 14:57:02 +00:00
|
|
|
|
2015-04-26 13:53:00 +00:00
|
|
|
MAILBOXES_SIEVE_PATH = Setting('MAILBOXES_SIEVE_PATH',
|
2015-04-28 16:07:16 +00:00
|
|
|
os.path.join('%(home)s/Maildir/sieve/orchestra.sieve'),
|
2015-04-28 15:23:57 +00:00
|
|
|
help_text="Available fromat names: <tt>%s</tt>" % ', '.join(_names),
|
|
|
|
validators=[Setting.string_format_validator(_backend_names)],
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2014-10-27 13:29:02 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_SIEVETEST_PATH = Setting('MAILBOXES_SIEVETEST_PATH',
|
|
|
|
'/dev/shm'
|
|
|
|
)
|
2014-10-06 14:57:02 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_SIEVETEST_BIN_PATH = Setting('MAILBOXES_SIEVETEST_BIN_PATH',
|
|
|
|
'%(orchestra_root)s/bin/sieve-test',
|
2015-04-27 12:24:17 +00:00
|
|
|
validators=[Setting.string_format_validator(('orchestra_root',))]
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2014-08-22 15:31:44 +00:00
|
|
|
|
|
|
|
|
2015-04-26 13:53:00 +00:00
|
|
|
MAILBOXES_VIRTUAL_MAILBOX_MAPS_PATH = Setting('MAILBOXES_VIRTUAL_MAILBOX_MAPS_PATH',
|
2015-03-31 12:39:08 +00:00
|
|
|
'/etc/postfix/virtual_mailboxes'
|
|
|
|
)
|
|
|
|
|
2014-08-22 15:31:44 +00:00
|
|
|
|
2015-04-26 13:53:00 +00:00
|
|
|
MAILBOXES_VIRTUAL_ALIAS_MAPS_PATH = Setting('MAILBOXES_VIRTUAL_ALIAS_MAPS_PATH',
|
2015-03-31 12:39:08 +00:00
|
|
|
'/etc/postfix/virtual_aliases'
|
|
|
|
)
|
2014-08-22 15:31:44 +00:00
|
|
|
|
|
|
|
|
2015-04-26 13:53:00 +00:00
|
|
|
MAILBOXES_VIRTUAL_ALIAS_DOMAINS_PATH = Setting('MAILBOXES_VIRTUAL_ALIAS_DOMAINS_PATH',
|
2015-03-31 12:39:08 +00:00
|
|
|
'/etc/postfix/virtual_domains'
|
|
|
|
)
|
2014-08-22 15:31:44 +00:00
|
|
|
|
2014-10-06 14:57:02 +00:00
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_LOCAL_DOMAIN = Setting('MAILBOXES_LOCAL_DOMAIN',
|
|
|
|
ORCHESTRA_BASE_DOMAIN,
|
|
|
|
validators=[validate_name],
|
|
|
|
help_text="Defaults to <tt>ORCHESTRA_BASE_DOMAIN</tt>."
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2014-10-06 14:57:02 +00:00
|
|
|
|
2014-10-21 11:22:31 +00:00
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_PASSWD_PATH = Setting('MAILBOXES_PASSWD_PATH',
|
|
|
|
'/etc/dovecot/passwd'
|
|
|
|
)
|
2014-10-09 17:04:12 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_MAILBOX_FILTERINGS = Setting('MAILBOXES_MAILBOX_FILTERINGS',
|
|
|
|
{
|
|
|
|
# value: (verbose_name, filter)
|
|
|
|
'DISABLE': (_("Disable"), ''),
|
2015-04-29 21:35:56 +00:00
|
|
|
'REJECT': (mark_safe_lazy(_("Reject spam (Score≥9)")), textwrap.dedent("""
|
2015-04-27 14:54:17 +00:00
|
|
|
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
2015-04-29 10:51:30 +00:00
|
|
|
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
2015-04-27 14:54:17 +00:00
|
|
|
discard;
|
|
|
|
stop;
|
|
|
|
}""")),
|
2015-04-29 21:35:56 +00:00
|
|
|
'REDIRECT': (mark_safe_lazy(_("Archive spam (Score≥9)")), textwrap.dedent("""
|
2015-04-27 14:54:17 +00:00
|
|
|
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
2015-04-29 10:51:30 +00:00
|
|
|
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
2015-04-27 14:54:17 +00:00
|
|
|
fileinto "Spam";
|
|
|
|
stop;
|
|
|
|
}""")),
|
|
|
|
'CUSTOM': (_("Custom filtering"), lambda mailbox: mailbox.custom_filtering),
|
|
|
|
}
|
|
|
|
)
|
2014-10-09 17:04:12 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_MAILBOX_DEFAULT_FILTERING = Setting('MAILBOXES_MAILBOX_DEFAULT_FILTERING',
|
|
|
|
'REDIRECT',
|
2015-04-26 13:53:00 +00:00
|
|
|
choices=tuple((k, v[0]) for k,v in MAILBOXES_MAILBOX_FILTERINGS.items())
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2014-11-17 14:17:33 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_MAILDIRSIZE_PATH = Setting('MAILBOXES_MAILDIRSIZE_PATH',
|
|
|
|
'%(home)s/Maildir/maildirsize',
|
|
|
|
help_text="Available fromat names: <tt>%s</tt>" % ', '.join(_backend_names),
|
|
|
|
validators=[Setting.string_format_validator(_backend_names)],
|
|
|
|
)
|
2014-11-27 19:17:26 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_LOCAL_ADDRESS_DOMAIN = Setting('MAILBOXES_LOCAL_ADDRESS_DOMAIN',
|
|
|
|
ORCHESTRA_BASE_DOMAIN,
|
|
|
|
validators=[validate_name],
|
|
|
|
help_text="Defaults to <tt>ORCHESTRA_BASE_DOMAIN</tt>."
|
2015-03-31 12:39:08 +00:00
|
|
|
)
|
2015-04-05 18:02:36 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_MAIL_LOG_PATH = Setting('MAILBOXES_MAIL_LOG_PATH',
|
|
|
|
'/var/log/mail.log'
|
|
|
|
)
|
2015-04-09 14:32:10 +00:00
|
|
|
|
|
|
|
|
2015-04-27 14:54:17 +00:00
|
|
|
MAILBOXES_MOVE_ON_DELETE_PATH = Setting('MAILBOXES_MOVE_ON_DELETE_PATH',
|
|
|
|
'',
|
|
|
|
help_text="Available fromat names: <tt>%s</tt>" % ', '.join(_backend_names),
|
|
|
|
validators=[Setting.string_format_validator(_backend_names)],
|
|
|
|
)
|