Skip to content

Commit

Permalink
Docs + tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Kysil authored and Roman Kysil committed Sep 18, 2024
1 parent 9e9fc29 commit c6ab84e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ extends =
eggs +=
Products.PrintingMailHost
design.plone.ioprenoto

23 changes: 15 additions & 8 deletions src/redturtle/prenotazioni/browser/prenotazioni_context_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,24 @@ def is_before_allowed_period(self, day, bypass_user_restrictions=False):

@memoize
def is_valid_day(self, day, bypass_user_restrictions=False):
"""Returns True if the day is valid"""
"""Returns True if the day is valid
Day is not valid in those conditions:
- day is out of validity range
(not applied to BookingManager if PrenotazioniFolder.bookins_manager_is_restricted_by_dates is False)
- day is vacation day
- day is out of PrenotazioniFolder.futures_day range
(not applied to BookingManager if PrenotazioniFolder.bookins_manager_is_restricted_by_dates is False)
- week day is not configured
"""

if isinstance(day, datetime):
day = day.date()

is_configured_day = self.is_configured_day(day)

if bypass_user_restrictions:
return True

if (
is_configured_day
and self.user_can_manage_prenotazioni
Expand All @@ -316,20 +327,16 @@ def is_valid_day(self, day, bypass_user_restrictions=False):
if self.is_vacation_day(day):
return False

if not bypass_user_restrictions and (
self.last_bookable_day and day > self.last_bookable_day
):
if self.last_bookable_day and day > self.last_bookable_day:
return False

if self.is_before_allowed_period(
day, bypass_user_restrictions=bypass_user_restrictions
):
if self.is_before_allowed_period(day, bypass_user_restrictions=False):
return False

if self.future_days_limit:
date_limit = date.today() + timedelta(days=self.future_days_limit)

if day >= date_limit and not bypass_user_restrictions:
if day >= date_limit:
return False

return is_configured_day
Expand Down
6 changes: 3 additions & 3 deletions src/redturtle/prenotazioni/tests/test_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ def test_requested_day_is_out_of_range(self):

results = response.json()

self.assertEquals(results["gates"], [])
self.assertEquals(results["pauses"], [])
self.assertEquals(results["bookings"], [])
self.assertEqual(results["gates"], [])
self.assertEqual(results["pauses"], [])
self.assertEqual(results["bookings"], [])

0 comments on commit c6ab84e

Please sign in to comment.