Project

General

Profile

Download (897 Bytes) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / agenda / views.py @ 0f0cacbb

1
import ipdb
2
import datetime
3

    
4
from django.shortcuts import redirect
5

    
6
from calebasse.cbv import TemplateView
7
from calebasse.personnes.models import Worker
8
from calebasse.ressources.models import WorkerType
9

    
10
def redirect_today(request, service):
11
    '''If not date is given we redirect on the agenda for today'''
12
    return redirect('agenda', date=datetime.date.today().strftime('%Y-%m-%d'),
13
            service=service)
14

    
15
class AgendaHomepageView(TemplateView):
16

    
17
    template_name = 'agenda/index.html'
18

    
19
    def get_context_data(self, **kwargs):
20
        context = super(AgendaHomepageView, self).get_context_data(**kwargs)
21
        context['workers_types'] = []
22
        for worker_type in WorkerType.objects.all():
23
            data = {'type': worker_type.name, 'workers': Worker.objects.for_service(self.service, worker_type) }
24
            context['workers_types'].append(data)
25
        return context
(7-7/7)