1
|
# -*- coding: utf-8 -*-
|
2
|
|
3
|
from django.shortcuts import render, redirect
|
4
|
from django.template.defaultfilters import slugify
|
5
|
|
6
|
from cbv import HOME_SERVICE_COOKIE, TemplateView
|
7
|
|
8
|
from calebasse.ressources.models import Service
|
9
|
|
10
|
APPLICATIONS = (
|
11
|
(u'Gestion des dossiers', 'dossiers'),
|
12
|
(u'Agenda', 'agenda'),
|
13
|
(u'Saisie des actes', 'actes'),
|
14
|
(u'Facturation et décompte', 'facturation'),
|
15
|
(u'Gestion des personnes', 'personnes'),
|
16
|
(u'Gestion des ressources', 'ressources'),
|
17
|
)
|
18
|
|
19
|
def redirect_to_homepage(request):
|
20
|
service_name = request.COOKIES.get(HOME_SERVICE_COOKIE, 'cmpp').lower()
|
21
|
return redirect('homepage', service=service_name)
|
22
|
|
23
|
class Homepage(TemplateView):
|
24
|
template_name='calebasse/homepage.html'
|
25
|
|
26
|
def get_context_data(self, **kwargs):
|
27
|
services = Service.objects.values_list('name', 'slug')
|
28
|
services = sorted(services, key=lambda tup: tup[0])
|
29
|
ctx = super(Homepage, self).get_context_data(**kwargs)
|
30
|
ctx.update({
|
31
|
'applications': APPLICATIONS,
|
32
|
'services': services,
|
33
|
'service_name': self.service.name,
|
34
|
})
|
35
|
return ctx
|
36
|
|
37
|
homepage = Homepage.as_view()
|