From 9260b4fe81c54fc0a788f1cde7650b1f95333cc6 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 29 Aug 2023 10:55:29 +0200 Subject: [PATCH] Remove unavailavle_gates branch --- CHANGES.rst | 4 --- .../browser/prenotazioni_context_state.py | 30 ++++--------------- .../tests/test_available_slots.py | 1 - .../tests/test_gates_overrides.py | 10 ++----- 4 files changed, 7 insertions(+), 38 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1b667a20..db8e2c9f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ---------------------- @@ -23,7 +20,6 @@ Changelog - allow to add out-of-office in api (aka blocco prenotazione) [mamico] - 2.0.0.dev5 (2023-08-21) ----------------------- diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py index b2f698c6..c69cc8f1 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py @@ -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): """ diff --git a/src/redturtle/prenotazioni/tests/test_available_slots.py b/src/redturtle/prenotazioni/tests/test_available_slots.py index ae13c103..b9356d8f 100644 --- a/src/redturtle/prenotazioni/tests/test_available_slots.py +++ b/src/redturtle/prenotazioni/tests/test_available_slots.py @@ -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, ): diff --git a/src/redturtle/prenotazioni/tests/test_gates_overrides.py b/src/redturtle/prenotazioni/tests/test_gates_overrides.py index 04d6dc00..bafbf093 100644 --- a/src/redturtle/prenotazioni/tests/test_gates_overrides.py +++ b/src/redturtle/prenotazioni/tests/test_gates_overrides.py @@ -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):