1 |
1 |
# -*- coding: utf-8 -*-
|
2 |
2 |
import datetime
|
3 |
3 |
|
4 |
|
def get_acts_of_the_day(date):
|
|
4 |
def get_acts_of_the_day(date, service=None):
|
5 |
5 |
from models import EventAct
|
|
6 |
if service:
|
|
7 |
return EventAct.objects.filter(date__year=date.year,
|
|
8 |
date__month=date.month, date__day=date.day,
|
|
9 |
services__pk__icontains=service.pk).order_by('date')
|
6 |
10 |
return EventAct.objects.filter(date__year=date.year,
|
7 |
11 |
date__month=date.month, date__day=date.day).order_by('date')
|
8 |
12 |
|
9 |
13 |
|
10 |
|
def unlock_all_acts_of_the_day(date):
|
11 |
|
get_acts_of_the_day(date).update(validation_locked=False)
|
|
14 |
def unlock_all_acts_of_the_day(date, service=None):
|
|
15 |
get_acts_of_the_day(date, service).update(validation_locked=False)
|
12 |
16 |
|
13 |
|
def are_all_acts_of_the_day_locked(date):
|
14 |
|
for act in get_acts_of_the_day(date):
|
|
17 |
def are_all_acts_of_the_day_locked(date, service=None):
|
|
18 |
for act in get_acts_of_the_day(date, service):
|
15 |
19 |
if not act.validation_locked:
|
16 |
20 |
return False
|
17 |
21 |
return True
|
18 |
22 |
|
19 |
23 |
|
20 |
|
def get_acts_not_locked_of_the_day(date):
|
|
24 |
def get_acts_not_locked_of_the_day(date, service=None):
|
21 |
25 |
acts = []
|
22 |
|
for act in get_acts_of_the_day(date):
|
|
26 |
for act in get_acts_of_the_day(date, service):
|
23 |
27 |
if not act.validation_locked:
|
24 |
28 |
acts.append(act)
|
25 |
29 |
return acts
|
26 |
30 |
|
27 |
31 |
|
28 |
|
def get_days_with_acts_not_locked(start_day, end_day):
|
|
32 |
def get_days_with_acts_not_locked(start_day, end_day, service=None):
|
29 |
33 |
num_days = abs((start_day - end_day).days) + 1
|
30 |
34 |
days_list = [start_day + datetime.timedelta(days=x) \
|
31 |
35 |
for x in range(0, num_days)]
|
32 |
36 |
result = []
|
33 |
37 |
for day in days_list:
|
34 |
|
if not are_all_acts_of_the_day_locked(day):
|
|
38 |
if not are_all_acts_of_the_day_locked(day, service):
|
35 |
39 |
result.append(day)
|
36 |
40 |
return result
|
37 |
41 |
|
38 |
42 |
|
39 |
|
def get_days_with_all_acts_locked(start_day, end_day):
|
|
43 |
def get_days_with_all_acts_locked(start_day, end_day, service=None):
|
40 |
44 |
num_days = abs((start_day - end_day).days) + 1
|
41 |
45 |
days_list = [start_day + datetime.timedelta(days=x) \
|
42 |
46 |
for x in range(0, num_days)]
|
43 |
47 |
result = []
|
44 |
48 |
for day in days_list:
|
45 |
|
if are_all_acts_of_the_day_locked(day):
|
|
49 |
if are_all_acts_of_the_day_locked(day, service):
|
46 |
50 |
result.append(day)
|
47 |
51 |
return result
|
48 |
52 |
|
... | ... | |
56 |
60 |
nb_acts_annul_famille = 0
|
57 |
61 |
nb_acts_abs_ess_pps = 0
|
58 |
62 |
nb_acts_enf_hosp = 0
|
59 |
|
acts_of_the_day = get_acts_of_the_day(date)
|
|
63 |
acts_of_the_day = get_acts_of_the_day(date, service)
|
60 |
64 |
for act in acts_of_the_day:
|
61 |
65 |
if act.is_state('ABS_NON_EXC'):
|
62 |
66 |
nb_acts_abs_non_exc = nb_acts_abs_non_exc + 1
|
agenda: validation is now per service.