Commit 362ad450 authored by Nicolas Dandrimont's avatar Nicolas Dandrimont

[settings,accueil] Filtrage de la page d'accueil selon les droits

parent 6c618457
......@@ -31,7 +31,12 @@ from django.contrib.auth.decorators import login_required
def view(request):
'''Affiche toutes les applications disponibles en fonction des
droits de la personne connectée.'''
session = request.session
apps = list(settings.INTRANET_APPS)
apps.sort(lambda x,y: cmp(x['category'], y['category']))
apps = []
for app in settings.INTRANET_APPS:
if 'test' in app:
if app['test'](request.user):
apps.append(app)
else:
apps.append(app)
apps.sort(key = lambda x: (x['category'], x['name']))
return django.shortcuts.render_to_response("accueil.html", locals(), context_instance=RequestContext(request))
......@@ -113,9 +113,21 @@ AUTHENTICATION_BACKENDS = (
INTRANET_APPS = (
{'name':'dummy', 'category':'Beta'},
{'name':'prises', 'category':'Administration'},
{'name':'impression', 'category': 'Services'},
{
'name':'dummy',
'category':'Beta',
'test': lambda u: u.groups.filter(name='crans_nounou'),
},
{
'name':'prises',
'category':'Administration',
'test': (lambda u: u.has_perm('prises.can_view')),
},
{
'name':'impression',
'category': 'Services',
'test': (lambda u: u.groups.filter(name='crans_nounou') or u.groups.filter(name='crans_apprenti')),
},
)
INSTALLED_APPS = (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment