Don't apply default top redirection to admins.

This commit is contained in:
Antoine Nguyen
2013-12-10 12:55:50 +01:00
parent bebf52bf6e
commit 65e9289b08
+11 -7
View File
@@ -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)