|
|
@ -78,7 +78,7 @@ class VracoopPointRetrait(models.Model): |
|
|
|
('dimanche', 6, 0, 'dim.'), |
|
|
|
] |
|
|
|
for rec in self: |
|
|
|
my_datetime = datetime.today() |
|
|
|
today_datetime = datetime.today() |
|
|
|
return_slot_list = [] |
|
|
|
vals = [] |
|
|
|
exclure_days_nb = rec.vracoop_retrait_time_ids.search_count([ |
|
|
@ -112,83 +112,53 @@ class VracoopPointRetrait(models.Model): |
|
|
|
hour = time_available_week.strftime("%H") |
|
|
|
minute = time_available_week.strftime("%M") |
|
|
|
interval = int(hour)*60 + int(minute) |
|
|
|
|
|
|
|
if week.day == my_datetime.day: |
|
|
|
first_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_morning_heure) |
|
|
|
last_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_morning_heure) |
|
|
|
first_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_noon_heure) |
|
|
|
last_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_noon_heure) |
|
|
|
today_hour_available = my_datetime + timedelta( |
|
|
|
hours=corresponding_line.preparation_time) |
|
|
|
if (today_hour_available > first_morning_hour_week) and (today_hour_available < last_morning_hour_week): |
|
|
|
dtstart_morning = today_hour_available |
|
|
|
dtstart_noon = first_noon_hour_week |
|
|
|
elif (today_hour_available > first_noon_hour_week) and (today_hour_available < last_noon_hour_week): |
|
|
|
dtstart_morning = today_hour_available |
|
|
|
dtstart_noon = today_hour_available |
|
|
|
elif (today_hour_available > last_morning_hour_week) and (today_hour_available < first_noon_hour_week): |
|
|
|
dtstart_morning = today_hour_available |
|
|
|
dtstart_noon = first_noon_hour_week |
|
|
|
else: |
|
|
|
dtstart_morning = today_hour_available |
|
|
|
dtstart_noon = today_hour_available |
|
|
|
|
|
|
|
list_slot_per_day_morning = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, |
|
|
|
interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=dtstart_morning, |
|
|
|
until=last_morning_hour_week)) |
|
|
|
list_slot_per_day_noon = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, |
|
|
|
interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=dtstart_noon, |
|
|
|
until=last_noon_hour_week)) |
|
|
|
else: |
|
|
|
first_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_morning_heure) |
|
|
|
last_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_morning_heure) |
|
|
|
first_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_noon_heure) |
|
|
|
last_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_noon_heure) |
|
|
|
list_slot_per_day_morning = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, |
|
|
|
interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=first_morning_hour_week, |
|
|
|
until=last_morning_hour_week)) |
|
|
|
list_slot_per_day_noon = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=first_noon_hour_week, |
|
|
|
until=last_noon_hour_week)) |
|
|
|
|
|
|
|
first_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_morning_heure) |
|
|
|
last_morning_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_morning_heure) |
|
|
|
first_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.first_noon_heure) |
|
|
|
last_noon_hour_week = datetime( |
|
|
|
week.year, week.month, week.day) + timedelta( |
|
|
|
hours=corresponding_line.last_noon_heure) |
|
|
|
|
|
|
|
list_slot_per_day_morning = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, |
|
|
|
interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=first_morning_hour_week, |
|
|
|
until=last_morning_hour_week)) |
|
|
|
list_slot_per_day_noon = list( |
|
|
|
rrule( |
|
|
|
MINUTELY, interval=interval, |
|
|
|
byweekday=byweekday, |
|
|
|
dtstart=first_noon_hour_week, |
|
|
|
until=last_noon_hour_week)) |
|
|
|
slots = [] |
|
|
|
nb_sale_slot = 0 |
|
|
|
for slot_per_day_morning in list_slot_per_day_morning: |
|
|
|
first_slot = slot_per_day_morning.strftime("%H:%M") |
|
|
|
slot_per_day_morning = slot_per_day_morning + timedelta( |
|
|
|
|
|
|
|
today_hour_available = today_datetime + timedelta( |
|
|
|
hours=corresponding_line.preparation_time) |
|
|
|
|
|
|
|
for slot_elem in list_slot_per_day_morning: |
|
|
|
first_slot = slot_elem.strftime("%H:%M") |
|
|
|
slot_elem_last = slot_elem + timedelta( |
|
|
|
hours=corresponding_line.availability_time) |
|
|
|
last_slot = slot_per_day_morning.strftime("%H:%M") |
|
|
|
|
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem.date() == today_datetime.date(): |
|
|
|
if (today_hour_available > slot_elem_last): |
|
|
|
continue |
|
|
|
if slot_elem_last >= last_morning_hour_week: |
|
|
|
slot_elem_last = last_morning_hour_week |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem >= last_morning_hour_week: |
|
|
|
continue |
|
|
|
# Check number of maximum withdrawal not reached |
|
|
|
first_slot_hour = first_slot.split(":") |
|
|
|
first_slot_float = float( |
|
|
|
'%s.%s' % (first_slot_hour[0], first_slot_hour[1])) |
|
|
@ -199,13 +169,20 @@ class VracoopPointRetrait(models.Model): |
|
|
|
if nb_sale_slot < rec.nb_max_retrait: |
|
|
|
slots.append((first_slot, last_slot)) |
|
|
|
|
|
|
|
nb_sale_slot = 0 |
|
|
|
for slot_per_day_noon in list_slot_per_day_noon: |
|
|
|
first_slot = slot_per_day_noon.strftime("%H:%M") |
|
|
|
slot_per_day_noon = slot_per_day_noon + timedelta( |
|
|
|
for slot_elem in list_slot_per_day_noon: |
|
|
|
first_slot = slot_elem.strftime("%H:%M") |
|
|
|
slot_elem_last = slot_elem + timedelta( |
|
|
|
hours=corresponding_line.availability_time) |
|
|
|
last_slot = slot_per_day_noon.strftime("%H:%M") |
|
|
|
|
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if week.date() == today_datetime.date(): |
|
|
|
if (today_hour_available > slot_elem_last): |
|
|
|
continue |
|
|
|
if slot_elem_last >= last_noon_hour_week: |
|
|
|
slot_elem_last = last_noon_hour_week |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem >= last_noon_hour_week: |
|
|
|
continue |
|
|
|
# Check number of maximum withdrawal not reached |
|
|
|
first_slot_hour = first_slot.split(":") |
|
|
|
first_slot_float = float( |
|
|
|
'%s.%s' % (first_slot_hour[0], first_slot_hour[1])) |
|
|
|