Skip to content

Commit

Permalink
Remove unavailavle_gates branch
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Aug 29, 2023
1 parent e8dec63 commit 9260b4f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 38 deletions.
4 changes: 0 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ Changelog

- Fix slots overlap valiation on booking move
[folix-01]
- Show default gates as unavailable in get_gates method, if they are overrided.
[cekk]


2.0.0.rc1 (2023-08-25)
----------------------
Expand All @@ -23,7 +20,6 @@ Changelog
- allow to add out-of-office in api (aka blocco prenotazione)
[mamico]


2.0.0.dev5 (2023-08-21)
-----------------------

Expand Down
30 changes: 5 additions & 25 deletions src/redturtle/prenotazioni/browser/prenotazioni_context_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,38 +401,18 @@ def get_gates(self, booking_date=None):
# sometimes booking_date is passed as date and sometimes as datetime
booking_date = booking_date.date()

gates = [
{
"name": gate,
"available": True,
}
for gate in self.context.getGates() or [""]
]

gates = self.context.getGates()
overrides = self.get_week_overrides(day=booking_date)
if not overrides:
return gates

overrided_gates = overrides.get("gates", [])
if not overrided_gates:
return gates
if overrides:
gates = overrides.get("gates", []) or gates

# set default gates as unavailable
gates = [
{
"name": gate["name"],
"available": False,
}
for gate in gates
]
overrided_gates = [
return [
{
"name": gate,
"available": True,
}
for gate in overrided_gates or [""]
for gate in gates or [""]
]
return gates + overrided_gates

def get_busy_gates_in_slot(self, booking_date, booking_end_date=None):
"""
Expand Down
1 change: 0 additions & 1 deletion src/redturtle/prenotazioni/tests/test_available_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def test_month_slots_called_without_params_return_all_available_slots_of_current
)
self.assertEqual(expected, response.json()["items"])

@unittest.skipIf(date.today().day > 20, "issue testing in the last days of a month")
def test_month_slots_called_without_params_return_available_slots_of_current_month_when_some_are_full(
self,
):
Expand Down
10 changes: 2 additions & 8 deletions src/redturtle/prenotazioni/tests/test_gates_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,12 @@ def setUp(self):
request=self.request,
)

def test_day_in_override_gates_return_overrided_gates_available_and_default_unavailable(
self,
):
def test_day_in_override_gates(self):
now = date.today()
gates = self.view.get_gates(date(now.year, 1, 10))
self.assertEqual(
gates,
[
{"name": "Gate A", "available": False},
{"name": "foo", "available": True},
{"name": "bar", "available": True},
],
[{"name": "foo", "available": True}, {"name": "bar", "available": True}],
)

def test_day_not_in_override_gates(self):
Expand Down

0 comments on commit 9260b4f

Please sign in to comment.