I forgot those modifications from 1.0.1 :p

This commit is contained in:
Antoine Nguyen
2013-11-04 09:29:59 +01:00
parent 0029cdc00c
commit c9103bd0e0
5 changed files with 18 additions and 17 deletions
+1 -1
View File
@@ -52,4 +52,4 @@ def unset_default_topredirection(extension):
"""
topredirection = parameters.get_admin("DEFAULT_TOP_REDIRECTION")
if topredirection == extension.name:
parameters.save_admin("DEFAULT_TOP_REDIRECTION", "userprefs")
parameters.save_admin("DEFAULT_TOP_REDIRECTION", "core")
+10 -3
View File
@@ -19,7 +19,7 @@ def enabled_applications():
from modoboa.core.models import Extension
from modoboa.lib.dbutils import db_table_exists
result = [("core", "core")]
result = [("user", "user")]
if db_table_exists("core_extension"):
exts = Extension.objects.filter(enabled=True)
result += [(ext.name, ext.name) for ext in exts]
@@ -98,7 +98,7 @@ class GeneralParametersForm(parameters.AdminParametersForm):
label=ugettext_lazy("Bind password"),
initial='',
help_text=ugettext_lazy("The password to use when binding to the LDAP server (with 'Bind DN')"),
widget=forms.PasswordInput,
widget=forms.PasswordInput(render_value=True),
required=False
)
@@ -152,7 +152,7 @@ class GeneralParametersForm(parameters.AdminParametersForm):
default_top_redirection = forms.ChoiceField(
label=ugettext_lazy("Default top redirection"),
choices=[],
initial="core",
initial="user",
help_text=ugettext_lazy("The default redirection used when no application is specified")
)
@@ -176,6 +176,13 @@ class GeneralParametersForm(parameters.AdminParametersForm):
super(GeneralParametersForm, self).__init__(*args, **kwargs)
self.fields["default_top_redirection"].choices = enabled_applications()
def clean_secret_key(self):
if len(self.cleaned_data["secret_key"]) not in [16, 24, 32]:
raise forms.ValidationError(
_("Key must be either 16, 24, or 32 bytes long")
)
return self.cleaned_data["secret_key"]
def clean_ldap_user_dn_template(self):
tpl = self.cleaned_data["ldap_user_dn_template"]
try:
+1 -1
View File
@@ -35,7 +35,7 @@ def dologin(request):
nextlocation = request.POST.get("next", None)
if nextlocation is None or nextlocation == "None":
if user.group != "SimpleUsers":
if user.group == "SimpleUsers":
nextlocation = reverse("modoboa.lib.webutils.topredirection")
else:
nextlocation = reverse("domains")
+1 -1
View File
@@ -20,7 +20,7 @@
"model": "lib.parameter",
"fields": {
"name": "general.DEFAULT_TOP_REDIRECTION",
"value": "userprefs"
"value": "user"
}
},
{
+5 -11
View File
@@ -138,27 +138,21 @@ def size2integer(value):
@login_required
def topredirection(request):
"""Simple view to redirect the request when no application is specified
"""Simple view to redirect the request when no application is specified.
The default "top redirection" can be specified in the *Admin >
Settings* panel. It is the application that will be launched by
default. Users that are not allowed to access this application
will be redirected to the "User preferences" application.
This feature only applies to simple users.
:param request: a Request object
"""
from modoboa.lib import parameters
from modoboa.core.extensions import exts_pool
topredir = parameters.get_admin("DEFAULT_TOP_REDIRECTION", app="core")
if not topredir in ["core"]:
infos = exts_pool.get_extension_infos(topredir)
path = infos["url"] if infos["url"] else infos["name"]
else:
path = "admin" # topredir
if topredir in ["core", "stats"] and \
request.user.belongs_to_group('SimpleUsers'):
path = "userprefs"
infos = exts_pool.get_extension_infos(topredir)
path = infos["url"] if infos["url"] else infos["name"]
return HttpResponseRedirect(path)