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.InlineRadioSelect) 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"))
class ParametersForm(param_forms.AdminParametersForm): """Global parameters.""" app = "modoboa_radicale" server_settings = form_utils.SeparatorField( label=ugettext_lazy("Server settings")) server_location = forms.CharField( label=ugettext_lazy("Server URL"), help_text=ugettext_lazy("The URL of your Radicale server. " "It will be used to construct calendar URLs."), widget=forms.TextInput(attrs={"class": "form-control"})) rights_management_sep = form_utils.SeparatorField( label=ugettext_lazy("Rights management")) rights_file_path = forms.CharField( label=ugettext_lazy("Rights file's path"), initial="/etc/modoboa_radicale/rights", help_text=ugettext_lazy( "Path to the file that contains rights definition"), widget=forms.TextInput(attrs={"class": "form-control"})) allow_calendars_administration = form_utils.YesNoField( label=ugettext_lazy("Allow calendars administration"), initial=False, help_text=ugettext_lazy( "Allow domain administrators to manage user calendars " "(read and write)"))
class ParametersForm(param_forms.AdminParametersForm): """Stats global parameters.""" app = "maillog" general_sep = form_utils.SeparatorField(label=ugettext_lazy("General")) logfile = forms.CharField( label=ugettext_lazy("Path to the log file"), initial="/var/log/mail.log", help_text=ugettext_lazy("Path to log file used to collect statistics"), widget=forms.TextInput(attrs={"class": "form-control"})) rrd_rootdir = forms.CharField( label=ugettext_lazy("Directory to store RRD files"), initial="/tmp/modoboa", help_text=ugettext_lazy( "Path to directory where RRD files are stored"), widget=forms.TextInput(attrs={"class": "form-control"})) greylist = form_utils.YesNoField( label=ugettext_lazy("Show greylisted messages"), initial=False, help_text=ugettext_lazy( "Differentiate between hard and soft rejects (greylisting)")) def __init__(self, *args, **kwargs): """Check RRDtool version.""" super().__init__(*args, **kwargs) rrd_version = parse_version(rrdtool.lib_version()) required_version = parse_version("1.6.0") test_mode = getattr(settings, "RRDTOOL_TEST_MODE", False) if rrd_version < required_version and not test_mode: del self.fields["greylist"]
class ParametersForm(param_forms.AdminParametersForm): """IMAP migration settings.""" app = "modoboa_imap_migration" sep1 = form_utils.SeparatorField(label=_("Connection settings")) server_address = forms.CharField( label=_("Server address"), initial="127.0.0.1", help_text=_("Address of your IMAP server") ) secured = form_utils.YesNoField( label=_("Use a secured connection"), initial=False, help_text=_("Use a secured connection to access IMAP server") ) server_port = forms.IntegerField( label=_("Server port"), initial=143, help_text=_("Listening port of your IMAP server") ) sep2 = form_utils.SeparatorField(label=_("OfflineIMAP settings")) max_sync_accounts = forms.IntegerField( label=_("Concurrent sync jobs"), initial=1, help_text=_("The maximum number of concurrent synchronization jobs") )
class ParametersForm(param_forms.AdminParametersForm): app = "modoboa_sievefilters" sep1 = form_utils.SeparatorField( label=ugettext_lazy("ManageSieve settings")) server = forms.CharField( label=ugettext_lazy("Server address"), initial="127.0.0.1", help_text=ugettext_lazy("Address of your MANAGESIEVE server"), widget=forms.TextInput(attrs={"class": "form-control"})) port = forms.IntegerField( label=ugettext_lazy("Server port"), initial=4190, help_text=ugettext_lazy("Listening port of your MANAGESIEVE server"), widget=forms.TextInput(attrs={"class": "form-control"})) starttls = form_utils.YesNoField( label=ugettext_lazy("Connect using STARTTLS"), initial=False, help_text=ugettext_lazy("Use the STARTTLS extension")) authentication_mech = forms.ChoiceField( label=ugettext_lazy("Authentication mechanism"), choices=supported_auth_mechs(), initial="auto", help_text=ugettext_lazy("Prefered authentication mechanism"), widget=forms.Select(attrs={"class": "form-control"})) sep2 = form_utils.SeparatorField(label=ugettext_lazy("IMAP settings")) imap_server = forms.CharField( label=ugettext_lazy("Server address"), initial="127.0.0.1", help_text=ugettext_lazy("Address of your IMAP server")) imap_secured = form_utils.YesNoField( label=ugettext_lazy("Use a secured connection"), initial=False, help_text=ugettext_lazy( "Use a secured connection to access IMAP server")) imap_port = forms.IntegerField( label=ugettext_lazy("Server port"), initial=143, help_text=ugettext_lazy("Listening port of your IMAP server"))
class UserSettings(param_forms.UserParametersForm): """User settings.""" app = "modoboa_contacts" sep1 = form_utils.SeparatorField(label=_("Synchronization")) enable_carddav_sync = form_utils.YesNoField( initial=False, label=_("Synchonize address book using CardDAV"), help_text=_( "Choose to synchronize or not your address book using CardDAV. " "You will be able to access your contacts from the outside.")) sync_frequency = forms.IntegerField( initial=300, label=_("Synchronization frequency"), help_text=_("Interval in seconds between 2 synchronization requests")) visibility_rules = {"sync_frequency": "enable_carddav_sync=True"} def clean_sync_frequency(self): """Make sure frequency is a positive integer.""" if self.cleaned_data["sync_frequency"] < 60: raise forms.ValidationError(_("Minimum allowed value is 60s")) return self.cleaned_data["sync_frequency"] def save(self, *args, **kwargs): """Create remote cal if necessary.""" super(UserSettings, self).save(*args, **kwargs) if not self.cleaned_data["enable_carddav_sync"]: return abook = self.user.addressbook_set.first() if abook.last_sync: return request = lib_signals.get_request() tasks.create_cdav_addressbook( abook, cryptutils.decrypt(request.session["password"])) if not abook.contact_set.exists(): abook.last_sync = timezone.now() abook.save(update_fields=["last_sync"])
class ParametersForm(param_forms.AdminParametersForm): """IMAP migration settings.""" app = "modoboa_imap_migration" sep2 = form_utils.SeparatorField(label=_("OfflineIMAP settings")) max_sync_accounts = forms.IntegerField( label=_("Concurrent sync jobs"), initial=1, help_text=_("The maximum number of concurrent synchronization jobs") ) sep2 = form_utils.SeparatorField(label=_("OfflineIMAP Filter settings")) create_folders = form_utils.YesNoField( label=_("Create Folders"), initial=True, help_text=_("Allow Creation of missing folders during sync") ) folder_filter_exclude = forms.CharField( required=False, label=_("Folder Filter Exclusions"), initial="", help_text=_( "Use a regular expression to explicitly include folders in sync. " "Example: ^Trash$|Del" ) ) folder_filter_include = forms.CharField( required=False, label=_("Folder Filter Inclusions"), initial="", help_text=_( "A comma seperated list of folders to explicitly include in sync " "even if filtered by the Folder Filter Exclusions. Example: " "debian.user, debian.personal " ) )
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']
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 ParametersForm(param_forms.AdminParametersForm): """Admin parameters form.""" app = "modoboa_pdfcredentials" docstore = form_utils.SeparatorField(label=_("Documents storage")) storage_dir = forms.CharField( label=_("Directory to save documents into"), initial="/var/lib/modoboa/pdf_credentials", help_text=_("Path to a directory where PDF documents will be saved"), ) security = form_utils.SeparatorField(label=_("Security options")) delete_first_dl = form_utils.YesNoField( label=_("Delete documents after the first download"), initial=True, help_text=_( "Automatically delete a document just after its first download " "from this interface")) generate_at_creation = form_utils.YesNoField( label=_("Generate documents only at account creation"), initial=True, help_text=_( "Generate a new document only when a new account is created. " "If set to no, a new document will be created each time a " "password is updated.")) customization = form_utils.SeparatorField(label=_("Customization options")) title = forms.CharField(label=_("Title"), initial=_("Personal account information"), help_text=_("The document's title")) webpanel_url = forms.URLField(label=_("Web panel url"), help_text=_("URL of the Modoboa web panel")) custom_message = forms.CharField( label=_("Custom message"), help_text=_( "A custom message that will appear at the end of documents"), required=False) include_connection_settings = form_utils.YesNoField( label=_("Include mail client connection settings"), initial=False, help_text=_("Include required SMTP and IMAP connection information to " "configure a mail client, a tablet or a phone")) smtp_server_address = forms.CharField( label=_("SMTP server address"), help_text=_("Address of the SMTP server (hostname or IP)")) smtp_server_port = forms.IntegerField( label=_("SMTP server port"), initial=587, help_text=_("Listening port of the SMTP server")) smtp_connection_security = forms.ChoiceField( label=_("SMTP connection security"), choices=constants.CONNECTION_SECURITY_MODES, initial="starttls", help_text=_("Connection security mechanism")) imap_server_address = forms.CharField( label=_("IMAP server address"), help_text=_("Address of the IMAP server (hostname or IP)")) imap_server_port = forms.IntegerField( label=_("IMAP server port"), initial=143, help_text=_("Listening port of the IMAP server")) imap_connection_security = forms.ChoiceField( label=_("IMAP connection security"), choices=constants.CONNECTION_SECURITY_MODES, initial="starttls", help_text=_("Connection security mechanism")) visibility_rules = { "smtp_server_address": "include_connection_settings=True", "smtp_server_port": "include_connection_settings=True", "smtp_connection_security": "include_connection_settings=True", "imap_server_address": "include_connection_settings=True", "imap_server_port": "include_connection_settings=True", "imap_connection_security": "include_connection_settings=True", } @cached_property def hostname(self): """Return local hostname.""" return sites_models.Site.objects.get_current().domain def __init__(self, *args, **kwargs): """Set initial values.""" super(ParametersForm, self).__init__(*args, **kwargs) if not self.fields["webpanel_url"].initial: url = "https://{}{}".format(self.hostname, settings.LOGIN_URL) self.fields["webpanel_url"].initial = url if not self.fields["smtp_server_address"].initial: self.fields["smtp_server_address"].initial = self.hostname if not self.fields["imap_server_address"].initial: self.fields["imap_server_address"].initial = self.hostname