class Meta: model = Policy fields = ("bypass_virus_checks", "bypass_spam_checks", "spam_tag2_level", "spam_subject_tag2", "spam_kill_level", "bypass_banned_checks") widgets = { "bypass_virus_checks": form_utils.HorizontalRadioSelect(), "bypass_spam_checks": form_utils.HorizontalRadioSelect(), "spam_tag2_level": forms.TextInput(attrs={"class": "form-control"}), "spam_kill_level": forms.TextInput(attrs={"class": "form-control"}), "spam_subject_tag2": forms.TextInput(attrs={"class": "form-control"}), "bypass_banned_checks": form_utils.HorizontalRadioSelect(), }
class UserSettings(param_forms.UserParametersForm): app = "modoboa_sievefilters" sep1 = form_utils.SeparatorField(label=ugettext_lazy("General")) editor_mode = forms.ChoiceField( initial="gui", label=ugettext_lazy("Editor mode"), choices=[("raw", "raw"), ("gui", "simplified")], help_text=ugettext_lazy( "Select the mode you want the editor to work in"), widget=form_utils.HorizontalRadioSelect()) sep2 = form_utils.SeparatorField(label=ugettext_lazy("Mailboxes")) trash_folder = forms.CharField( initial="Trash", label=ugettext_lazy("Trash folder"), help_text=ugettext_lazy("Folder where deleted messages go")) sent_folder = forms.CharField( initial="Sent", label=ugettext_lazy("Sent folder"), help_text=ugettext_lazy("Folder where copies of sent messages go")) drafts_folder = forms.CharField( initial="Drafts", label=ugettext_lazy("Drafts folder"), help_text=ugettext_lazy("Folder where drafts go")) @staticmethod def has_access(**kwargs): return hasattr(kwargs.get("user"), "mailbox")
class ParametersForm(param_forms.AdminParametersForm): app = "modoboa_webmail" sep3 = form_utils.SeparatorField(label=_("General")) max_attachment_size = forms.CharField( label=_("Maximum attachment size"), initial="2048", help_text=_( "Maximum attachment size in bytes (or KB, MB, GB if specified)")) sep1 = form_utils.SeparatorField(label=_("IMAP settings")) imap_server = forms.CharField(label=_("Server address"), initial="127.0.0.1", help_text=_("Address of your IMAP server")) imap_secured = form_utils.YesNoField( label=_("Use a secured connection"), initial=False, help_text=_("Use a secured connection to access IMAP server")) imap_port = forms.IntegerField( label=_("Server port"), initial=143, help_text=_("Listening port of your IMAP server")) sep2 = form_utils.SeparatorField(label=_("SMTP settings")) smtp_server = forms.CharField(label=_("Server address"), initial="127.0.0.1", help_text=_("Address of your SMTP server")) smtp_secured_mode = forms.ChoiceField( label=_("Secured connection mode"), choices=[("none", _("None")), ("starttls", "STARTTLS"), ("ssl", "SSL/TLS")], initial="none", help_text=_("Use a secured connection to access SMTP server"), widget=form_utils.HorizontalRadioSelect()) smtp_port = forms.IntegerField( label=_("Server port"), initial=25, help_text=_("Listening port of your SMTP server")) smtp_authentication = form_utils.YesNoField( label=_("Authentication required"), initial=False, help_text=_("Server needs authentication"))
def __init__(self, conditions, actions, request, *args, **kwargs): super(FilterForm, self).__init__(*args, **kwargs) self.field_widths = {"match_type": 8} self.fields["name"] = forms.CharField(label=_("Name")) self.fields["match_type"] = forms.ChoiceField( label=_("Match type"), choices=[("allof", _("All of the following")), ("anyof", _("Any of the following")), ("all", _("All messages"))], initial="anyof", widget=form_utils.HorizontalRadioSelect()) self.conds_cnt = 0 for c in conditions: getattr(self, "_build_%s_field" % c[0])(c[1], c[2]) self.actions_cnt = 0 for a in actions: getattr(self, "_build_%s_field" % a[0])(request, *a[1:])
class ParametersForm(param_forms.AdminParametersForm): """Extension settings.""" app = "modoboa_amavis" amavis_settings_sep = form_utils.SeparatorField( label=ugettext_lazy("Amavis settings")) localpart_is_case_sensitive = form_utils.YesNoField( label=ugettext_lazy("Localpart is case sensitive"), initial=False, help_text=ugettext_lazy("Value should match amavisd.conf variable %s" % "$localpart_is_case_sensitive")) recipient_delimiter = forms.CharField( label=ugettext_lazy("Recipient delimiter"), initial="", help_text=ugettext_lazy("Value should match amavisd.conf variable %s" % "$recipient_delimiter"), widget=forms.TextInput(attrs={"class": "form-control"}), required=False) qsettings_sep = form_utils.SeparatorField( label=ugettext_lazy("Quarantine settings")) max_messages_age = forms.IntegerField( label=ugettext_lazy("Maximum message age"), initial=14, help_text=ugettext_lazy( "Quarantine messages maximum age (in days) before deletion")) sep1 = form_utils.SeparatorField(label=ugettext_lazy("Messages releasing")) released_msgs_cleanup = form_utils.YesNoField( label=ugettext_lazy("Remove released messages"), initial=False, help_text=ugettext_lazy( "Remove messages marked as released while cleaning up " "the database")) am_pdp_mode = forms.ChoiceField( label=ugettext_lazy("Amavis connection mode"), choices=[("inet", "inet"), ("unix", "unix")], initial="unix", help_text=ugettext_lazy("Mode used to access the PDP server"), widget=form_utils.HorizontalRadioSelect()) am_pdp_host = forms.CharField( label=ugettext_lazy("PDP server address"), initial="localhost", help_text=ugettext_lazy("PDP server address (if inet mode)"), widget=forms.TextInput(attrs={"class": "form-control"})) am_pdp_port = forms.IntegerField( label=ugettext_lazy("PDP server port"), initial=9998, help_text=ugettext_lazy("PDP server port (if inet mode)")) am_pdp_socket = forms.CharField( label=ugettext_lazy("PDP server socket"), initial="/var/amavis/amavisd.sock", help_text=ugettext_lazy( "Path to the PDP server socket (if unix mode)")) user_can_release = form_utils.YesNoField( label=ugettext_lazy("Allow direct release"), initial=False, help_text=ugettext_lazy( "Allow users to directly release their messages")) self_service = form_utils.YesNoField( label=ugettext_lazy("Enable self-service mode"), initial=False, help_text=ugettext_lazy("Activate the 'self-service' mode")) notifications_sender = forms.EmailField( label=ugettext_lazy("Notifications sender"), initial="*****@*****.**", help_text=ugettext_lazy( "The e-mail address used to send notitications")) lsep = form_utils.SeparatorField(label=ugettext_lazy("Manual learning")) manual_learning = form_utils.YesNoField( label=ugettext_lazy("Enable manual learning"), initial=True, help_text=ugettext_lazy( "Allow super administrators to manually train Spamassassin")) sa_is_local = form_utils.YesNoField( label=ugettext_lazy("Is Spamassassin local?"), initial=True, help_text=ugettext_lazy( "Tell if Spamassassin is running on the same server than modoboa")) default_user = forms.CharField( label=ugettext_lazy("Default user"), initial="amavis", help_text=ugettext_lazy( "Name of the user owning the default bayesian database")) spamd_address = forms.CharField( label=ugettext_lazy("Spamd address"), initial="127.0.0.1", help_text=ugettext_lazy("The IP address where spamd can be reached")) spamd_port = forms.IntegerField( label=ugettext_lazy("Spamd port"), initial=783, help_text=ugettext_lazy("The TCP port spamd is listening on")) domain_level_learning = form_utils.YesNoField( label=ugettext_lazy("Enable per-domain manual learning"), initial=False, help_text=ugettext_lazy( "Allow domain administrators to train Spamassassin " "(within dedicated per-domain databases)")) user_level_learning = form_utils.YesNoField( label=ugettext_lazy("Enable per-user manual learning"), initial=False, help_text=ugettext_lazy( "Allow simple users to personally train Spamassassin " "(within a dedicated database)")) visibility_rules = { "am_pdp_host": "am_pdp_mode=inet", "am_pdp_port": "am_pdp_mode=inet", "am_pdp_socket": "am_pdp_mode=unix", "sa_is_local": "manual_learning=True", "default_user": "******", "spamd_address": "sa_is_local=False", "spamd_port": "sa_is_local=False", "domain_level_learning": "manual_learning=True", "user_level_learning": "manual_learning=True" }
class UserSettings(param_forms.UserParametersForm): app = "modoboa_webmail" sep1 = form_utils.SeparatorField(label=_("Display")) displaymode = forms.ChoiceField( initial="plain", label=_("Default message display mode"), choices=[("html", "html"), ("plain", "text")], help_text=_("The default mode used when displaying a message"), widget=form_utils.HorizontalRadioSelect()) enable_links = form_utils.YesNoField( initial=False, label=_("Enable HTML links display"), help_text=_("Enable/Disable HTML links display")) messages_per_page = forms.IntegerField( initial=40, label=_("Number of displayed emails per page"), help_text=_("Sets the maximum number of messages displayed in a page")) refresh_interval = forms.IntegerField( initial=300, label=_("Listing refresh rate"), help_text=_("Automatic folder refresh rate (in seconds)")) mboxes_col_width = forms.IntegerField( initial=200, label=_("Folder container's width"), help_text=_("The width of the folder list container")) sep2 = form_utils.SeparatorField(label=_("Folders")) trash_folder = forms.CharField( initial="Trash", label=_("Trash folder"), help_text=_("Folder where deleted messages go")) sent_folder = forms.CharField( initial="Sent", label=_("Sent folder"), help_text=_("Folder where copies of sent messages go")) drafts_folder = forms.CharField(initial="Drafts", label=_("Drafts folder"), help_text=_("Folder where drafts go")) junk_folder = forms.CharField( initial="Junk", label=_("Junk folder"), help_text=_("Folder where junk messages should go")) sep3 = form_utils.SeparatorField(label=_("Composing messages")) editor = forms.ChoiceField( initial="plain", label=_("Default editor"), choices=[("html", "html"), ("plain", "text")], help_text=_("The default editor to use when composing a message"), widget=form_utils.HorizontalRadioSelect()) signature = forms.CharField(initial="", label=_("Signature text"), help_text=_("User defined email signature"), required=False, widget=CKEditorUploadingWidget()) visibility_rules = {"enable_links": "displaymode=html"} @staticmethod def has_access(**kwargs): return hasattr(kwargs.get("user"), "mailbox") def clean_mboxes_col_width(self): """Check if the entered value is a positive integer. It must also be different from 0. """ if self.cleaned_data['mboxes_col_width'] <= 0: raise forms.ValidationError( _('Value must be a positive integer (> 0)')) return self.cleaned_data['mboxes_col_width']