From 65e9289b08a5f48e0da3f0439e2bcb9c1a60844f Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 10 Dec 2013 12:55:50 +0100 Subject: [PATCH] Don't apply default top redirection to admins. --- modoboa/lib/webutils.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modoboa/lib/webutils.py b/modoboa/lib/webutils.py index ec9ed7313..df578c2e1 100644 --- a/modoboa/lib/webutils.py +++ b/modoboa/lib/webutils.py @@ -6,9 +6,10 @@ This module contains extra functions/shortcuts used to render HTML. import sys import re import json +from django.core.urlresolvers import reverse from django.http import HttpResponse, HttpResponseRedirect from django.contrib.auth.decorators import login_required -from django.shortcuts import render, render_to_response +from django.shortcuts import render from django.template.loader import render_to_string from django import template from django.conf import settings @@ -140,9 +141,9 @@ def topredirection(request): """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. + Settings* panel. It is the application that will be + launched. Those not allowed to access the application will be + redirected to their preferences page. This feature only applies to simple users. @@ -151,9 +152,12 @@ def topredirection(request): from modoboa.lib import parameters from modoboa.core.extensions import exts_pool - topredir = parameters.get_admin("DEFAULT_TOP_REDIRECTION", app="core") - infos = exts_pool.get_extension_infos(topredir) - path = infos["url"] if infos["url"] else infos["name"] + if request.user.group == 'SimpleUsers': + topredir = parameters.get_admin("DEFAULT_TOP_REDIRECTION", app="core") + infos = exts_pool.get_extension_infos(topredir) + path = infos["url"] if infos["url"] else infos["name"] + else: + path = reverse("domains") return HttpResponseRedirect(path)