diff --git a/modoboa/admin/__init__.py b/modoboa/admin/__init__.py index 09093b61c..85571fdad 100644 --- a/modoboa/admin/__init__.py +++ b/modoboa/admin/__init__.py @@ -33,24 +33,29 @@ parameters.register_admin( help=ugettext_lazy("The backend used for authentication") ) parameters.register_admin( - "CREATE_DIRECTORIES", type="list_yesno", deflt="yes", - help=ugettext_lazy("Modoboa will handle mailbox creation on filesystem") + "LDA", type="list", deflt="dovecot", + values=[('dovecot', "Dovecot"), ('postfix', 'Postfix')], + help=ugettext_lazy("Local Delivery Agent") ) parameters.register_admin( "STORAGE_PATH", type="string", deflt="/var/vmail", + visible_if="LDA=postfix", help=ugettext_lazy("Path to the root directory where messages are stored") ) parameters.register_admin( "VIRTUAL_UID", type="string", deflt="vmail", modify_cb=update_uid, + visible_if="LDA=postfix", help=ugettext_lazy("UID of the virtual user which owns domains/mailboxes/messages on the filesystem") ) parameters.register_admin( "VIRTUAL_GID", type="string", deflt="vmail", modify_cb=update_gid, + visible_if="LDA=postfix", help=ugettext_lazy("GID of the virtual user which owns domains/mailboxes/messages on the filesystem") ) parameters.register_admin( "MAILBOX_TYPE", type="list", deflt="maildir", values=[("maildir", "maildir"), ("mbox", "mbox")], + visible_if="LDA=postfix", help=ugettext_lazy("Mailboxes storage format") ) parameters.register_admin( diff --git a/modoboa/admin/models.py b/modoboa/admin/models.py index 07634b07d..f35c65b72 100644 --- a/modoboa/admin/models.py +++ b/modoboa/admin/models.py @@ -549,21 +549,21 @@ class Domain(DatesAware): return [oa.user for oa in self.owners.filter(user__is_superuser=False)] def create_dir(self): - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": path = "%s/%s" % (parameters.get_admin("STORAGE_PATH"), self.name) return exec_as_vuser("mkdir -p %s" % path) return True def rename_dir(self, oldname): - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": stpath = parameters.get_admin("STORAGE_PATH") return exec_as_vuser("mv %s/%s %s/%s" \ % (stpath, oldname, stpath, self.name)) return True def delete_dir(self): - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": return exec_as_vuser("rm -r %s/%s" \ % (parameters.get_admin("STORAGE_PATH"), self.name)) @@ -716,7 +716,7 @@ class Mailbox(DatesAware): self.path = "%s/Inbox" % self.address else: self.path = "%s/" % self.address - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": relpath = "%s/%s" % (self.domain.name, self.address) abspath = os.path.join(parameters.get_admin("STORAGE_PATH"), relpath) if os.path.exists(abspath): @@ -736,7 +736,7 @@ class Mailbox(DatesAware): return True def rename_dir(self, newdomain, newaddress): - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": if self.domain.name == newdomain and newaddress == self.address: return True oldpath = "%s/%s" % (parameters.get_admin("STORAGE_PATH"), self.domain.name) @@ -753,7 +753,7 @@ class Mailbox(DatesAware): return True def delete_dir(self): - if parameters.get_admin("CREATE_DIRECTORIES") == "yes": + if parameters.get_admin("LDA") == "postfix": return exec_as_vuser("rm -r %s/%s/%s" \ % (parameters.get_admin("STORAGE_PATH"), self.domain.name, self.address)) diff --git a/modoboa/lib/fixtures/demo.json b/modoboa/lib/fixtures/demo.json index 96a4d9af4..87919d286 100644 --- a/modoboa/lib/fixtures/demo.json +++ b/modoboa/lib/fixtures/demo.json @@ -35,8 +35,8 @@ "pk": 5, "model": "lib.parameter", "fields": { - "name": "admin.CREATE_DIRECTORIES", - "value": "yes" + "name": "admin.LDA", + "value": "dovecot" } }, { diff --git a/modoboa/static/js/twocols_nav.js b/modoboa/static/js/twocols_nav.js index 4975fee1c..946159fce 100644 --- a/modoboa/static/js/twocols_nav.js +++ b/modoboa/static/js/twocols_nav.js @@ -47,15 +47,30 @@ TwocolsNav.prototype = { $('#' + this.options.divid + ' select').change(); }, + propagate_change: function($node) { + var $select = $node.find("select"); + if ($select.length) { + $select.change(); + } + }, + select_change: function(e) { + var instance = this; var $target = $(e.target); + var $parent = $target.parents("div.control-group"); $('div[data-visibility-field="' + $target.attr("id") + '"]').each(function(idx) { var $this = $(this); - if ($this.attr("data-visibility-value") == $target.attr("value")) { + + if ($parent.attr("disabled") === undefined && + $this.attr("data-visibility-value") == $target.attr("value")) { + $this.attr("disabled", null); $this.show(); + instance.propagate_change($this) } else { $this.hide(); + $this.attr("disabled", "disabled"); + instance.propagate_change($this); } }); },