Revision ad9330e1
Added by Jérôme Schneider over 12 years ago
calebasse/agenda/managers.py | ||
---|---|---|
82 | 82 |
|
83 | 83 |
class OccurrenceManager(models.Manager): |
84 | 84 |
|
85 |
def daily_occurrences(self, date=None, participants=None, services=None): |
|
85 |
def daily_occurrences(self, date=None, participants=None, services=None, |
|
86 |
event_type=None): |
|
86 | 87 |
''' |
87 | 88 |
Returns a queryset of for instances that have any overlap with a |
88 | 89 |
particular day. |
... | ... | |
113 | 114 |
if participants: |
114 | 115 |
qs = qs.filter(event__participants__in=participants) |
115 | 116 |
if services: |
116 |
qs = qs.filter(services__in=services) |
|
117 |
qs = qs.filter(event__services__in=services) |
|
118 |
if event_type: |
|
119 |
qs = qs.filter(event__event_type=event_type) |
|
117 | 120 |
return qs |
118 | 121 |
|
119 | 122 |
def daily_disponiblity(self, date, occurrences, participants): |
... | ... | |
145 | 148 |
start_datetime += timedelta(minutes=15) |
146 | 149 |
end_datetime += timedelta(minutes=15) |
147 | 150 |
return result |
151 |
|
calebasse/agenda/templates/agenda/service-activity.html | ||
---|---|---|
31 | 31 |
<tr> <th>Heure</th> <th>Durée</th> <th>Patient</th> <th>Thérapeute(s)</th> <th>Acte</th> </tr> |
32 | 32 |
</thead> |
33 | 33 |
<tbody> |
34 |
<tr class="hour-change"> <td class="hour" rowspan="2">08:00</td> <td>45m</td> <td>John Doe</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
35 |
<tr> <td>1h</td> <td>Bob Dilane</td> <td>Sylvain Mirouf</td> <td>Rééducation</td> </tr> |
|
36 |
<tr class="hour-change"> <td class="hour" >08:15</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
37 |
<tr class="hour-change"> <td class="hour" rowspan="4">09:00</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
38 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
39 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
40 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
41 |
<tr class="hour-change"> <td class="hour" rowspan="2">09:30</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
42 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
43 |
<tr class="hour-change"> <td class="hour" >09:45</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
44 |
<tr class="hour-change"> <td class="hour" rowspan="3">10:00</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
45 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
46 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
47 |
<tr class="hour-change"> <td class="hour" >10:15</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
48 |
<tr class="hour-change"> <td class="hour" rowspan="2">10:30</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
49 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
50 |
<tr class="hour-change"> <td class="hour" >10:45</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
51 |
<tr class="hour-change"> <td class="hour" rowspan="3">12:00</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
52 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
53 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
54 |
<tr class="hour-change"> <td class="hour" rowspan="4">14:00</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
55 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
56 |
<tr> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
57 |
<tr> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
58 |
<tr class="hour-change"> <td class="hour" >14:15</td> <td>45m</td> <td>Sabine Malouf</td> <td>Norbert Lecuisto</td> <td>Synthèse</td> </tr> |
|
59 |
<tr class="hour-change"> <td class="hour" >14:30</td> <td>45m</td> <td>Gomez Chavez</td> <td>Sylvie Legrand</td> <td>Bilan</td> </tr> |
|
34 |
{% for time, row_appointments in appointments_times.items %} |
|
35 |
<tr class="hour-change"> |
|
36 |
<td class="hour" rowspan="{{ row_appointments.row }}">{{ time }}</td> |
|
37 |
{% for appointment in row_appointments.appointments %} |
|
38 |
{% if forloop.counter != 1 %} |
|
39 |
<tr> |
|
40 |
{% endif %} |
|
41 |
<td>{{ appointment.length }}</td> |
|
42 |
<td>{{ appointment.patient }}</td> |
|
43 |
<td>{{ appointment.therapists }}</td> |
|
44 |
<td>{{ appointment.act }}</td> |
|
45 |
</tr> |
|
46 |
{% endfor %} |
|
47 |
</tr> |
|
48 |
{% endfor %} |
|
60 | 49 |
</tbody> |
61 | 50 |
</table> |
62 | 51 |
</div> |
calebasse/agenda/urls.py | ||
---|---|---|
2 | 2 |
|
3 | 3 |
from calebasse.cbv import TemplateView |
4 | 4 |
|
5 |
from views import redirect_today, AgendaHomepageView, NewAppointmentView, NewEventView |
|
5 |
from views import (redirect_today, AgendaHomepageView, NewAppointmentView, |
|
6 |
NewEventView, AgendaServiceActivityView) |
|
6 | 7 |
|
7 | 8 |
|
8 | 9 |
agenda_patterns = patterns('', |
... | ... | |
17 | 18 |
NewEventView.as_view(), |
18 | 19 |
name='new-event'), |
19 | 20 |
url(r'^activite-du-service/$', |
20 |
TemplateView.as_view(
|
|
21 |
AgendaServiceActivityView.as_view(
|
|
21 | 22 |
template_name='agenda/service-activity.html'), |
22 | 23 |
name='activite-du-service'), |
23 | 24 |
url(r'^validation-des-actes/$', |
calebasse/agenda/views.py | ||
---|---|---|
4 | 4 |
from django.shortcuts import redirect |
5 | 5 |
|
6 | 6 |
from calebasse.cbv import TemplateView, CreateView |
7 |
from calebasse.agenda.models import Occurrence |
|
7 |
from calebasse.agenda.models import Occurrence, Event, EventType
|
|
8 | 8 |
from calebasse.personnes.models import TimeTable |
9 |
from calebasse.actes.models import EventAct, Event
|
|
9 |
from calebasse.actes.models import EventAct |
|
10 | 10 |
from calebasse.agenda.appointments import get_daily_appointments |
11 | 11 |
from calebasse.personnes.models import Worker |
12 | 12 |
from calebasse.ressources.models import Service, WorkerType |
... | ... | |
65 | 65 |
occurrences_workers, workers) |
66 | 66 |
return context |
67 | 67 |
|
68 |
class AgendaServiceActivityView(TemplateView): |
|
69 |
|
|
70 |
template_name = 'agenda/service-activity.html' |
|
71 |
|
|
72 |
def get_context_data(self, **kwargs): |
|
73 |
context = super(AgendaServiceActivityView, self).get_context_data(**kwargs) |
|
74 |
|
|
75 |
appointments_times = dict() |
|
76 |
appoinment_type = EventType.objects.get(id=1) |
|
77 |
occurrences = Occurrence.objects.daily_occurrences(context['date'], |
|
78 |
services=[self.service], |
|
79 |
event_type=appoinment_type).order_by('start_time') |
|
80 |
for occurrence in occurrences: |
|
81 |
start_time = occurrence.start_time.strftime("%H:%M") |
|
82 |
if not appointments_times.has_key(start_time): |
|
83 |
appointments_times[start_time] = dict() |
|
84 |
appointments_times[start_time]['row'] = 0 |
|
85 |
appointments_times[start_time]['appointments'] = [] |
|
86 |
appointment = dict() |
|
87 |
length = occurrence.end_time - occurrence.start_time |
|
88 |
if length.seconds: |
|
89 |
length = length.seconds / 60 |
|
90 |
appointment['length'] = "%sm" % length |
|
91 |
event_act = occurrence.event.eventact |
|
92 |
appointment['patient'] = event_act.patient |
|
93 |
appointment['therapists'] = "" |
|
94 |
for participant in occurrence.event.participants.all(): |
|
95 |
appointment['therapists'] += str(participant) + "; " |
|
96 |
if appointment['therapists']: |
|
97 |
appointment['therapists'] = appointment['therapists'][:-2] |
|
98 |
appointment['act'] = event_act.act_type.name |
|
99 |
appointments_times[start_time]['row'] += 1 |
|
100 |
appointments_times[start_time]['appointments'].append(appointment) |
|
101 |
context['appointments_times'] = appointments_times |
|
102 |
print context['appointments_times'] |
|
103 |
return context |
|
104 |
|
|
105 |
|
|
68 | 106 |
class NewAppointmentView(CreateView): |
69 | 107 |
model = EventAct |
70 | 108 |
form_class = NewAppointmentForm |
Also available in: Unified diff
agenda: add display for service activity