Project

General

Profile

Download (1.47 KB) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / views.py @ 87abc503

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
from calebasse.middleware.request import get_request
10
from calebasse.utils import is_validator
11

    
12

    
13
APPLICATIONS = (
14
        (u'Gestion des dossiers', 'dossiers', False),
15
        (u'Agenda', 'agenda', False),
16
#        (u'Saisie des actes', 'actes', True),
17
#        (u'Facturation et décompte', 'facturation', True),
18
        (u'Gestion des personnes', 'personnes', True),
19
        (u'Gestion des ressources', 'ressources', True),
20
)
21

    
22
def redirect_to_homepage(request):
23
    service_name = request.COOKIES.get(HOME_SERVICE_COOKIE, 'cmpp').lower()
24
    return redirect('homepage', service=service_name)
25

    
26
class Homepage(TemplateView):
27
    template_name='calebasse/homepage.html'
28

    
29
    def get_context_data(self, **kwargs):
30
        services = Service.objects.values_list('name', 'slug')
31
        services = sorted(services, key=lambda tup: tup[0])
32
        ctx = super(Homepage, self).get_context_data(**kwargs)
33
        applications = list(APPLICATIONS)
34
#        user = get_request().user
35
#        if not is_validator(user):
36
#            applications.pop(3)
37
#            applications.pop(4)
38
        ctx.update({
39
            'applications': applications,
40
            'services': services,
41
            'service_name': self.service.name,
42
        })
43
        return ctx
44

    
45
homepage = Homepage.as_view()
(12-12/13)