Exemple #1
0
class UserSettings(param_forms.UserParametersForm):
    app = "modoboa_sievefilters"

    sep1 = form_utils.SeparatorField(label=_("General"))

    editor_mode = forms.ChoiceField(
        initial="gui",
        label=_("Editor mode"),
        choices=[("raw", "raw"), ("gui", "simplified")],
        help_text=_("Select the mode you want the editor to work in"),
        widget=form_utils.InlineRadioSelect(attrs={"type": "checkbox"}))

    sep2 = form_utils.SeparatorField(label=_("Mailboxes"))

    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"))

    @staticmethod
    def has_access(**kwargs):
        return hasattr(kwargs.get("user"), "mailbox")
Exemple #2
0
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.InlineRadioSelect())

    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.InlineRadioSelect())

    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']