Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 22c1e4d
Author: Roman <[email protected]>
Date:   Thu Nov 2 09:50:11 2023 +0100

    Remove cosa_serve field from the Booking Folder

commit 354c4cb
Author: Roman <[email protected]>
Date:   Tue Oct 31 14:46:27 2023 +0100

    Fix booking duration type

commit 5ffc526
Merge: d3d4b34 7829bc6
Author: Roman <[email protected]>
Date:   Tue Oct 31 12:07:30 2023 +0100

    Merge branch 'develop' into booking_types_ct

commit d3d4b34
Author: Roman <[email protected]>
Date:   Tue Oct 31 11:49:43 2023 +0100

    Fix booking duration converison

commit 8ce51e6
Author: Roman <[email protected]>
Date:   Tue Oct 31 10:53:12 2023 +0100

    Fix booking types duration vocabulary values type

commit 34429b6
Author: Roman <[email protected]>
Date:   Tue Oct 31 10:39:48 2023 +0100

    Fix booking duration handling

commit 0af7e6e
Author: Roman <[email protected]>
Date:   Tue Oct 31 10:16:20 2023 +0100

    Fix BookingType profile

commit 142bb8d
Author: Roman <[email protected]>
Date:   Tue Oct 31 10:00:36 2023 +0100

    Hide gates

commit f748cd7
Author: Roman <[email protected]>
Date:   Fri Oct 27 17:49:34 2023 +0200

    Refactor the @@prenotazioni_context_state.get_booking_type_duration method

commit d1209e7
Author: Roman <[email protected]>
Date:   Thu Oct 26 15:10:41 2023 +0200

    Refactor

commit 8da8dea
Author: Roman <[email protected]>
Date:   Thu Oct 26 15:05:56 2023 +0200

    Refactor

commit 5aac9ce
Author: Roman <[email protected]>
Date:   Thu Oct 26 14:37:37 2023 +0200

    Fix typos

commit 190b0ca
Author: Roman <[email protected]>
Date:   Thu Oct 19 16:54:46 2023 +0200

    Initial implementation
  • Loading branch information
folix-01 committed Nov 2, 2023
1 parent 1a516c1 commit 1cdf5cb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
9 changes: 0 additions & 9 deletions src/redturtle/prenotazioni/browser/templates/prenotazione.pt
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@
<strong i18n:translate="label_booking_code">Booking code</strong>:
<span tal:replace="here/getBookingCode"></span>
</div>
<div class="field"
tal:define="
cosa_serve python: here.getPrenotazioniFolder().getCosaServe();
"
tal:condition="cosa_serve"
>
<strong i18n:translate="cosa_serve">Cosa serve</strong>:
<span tal:replace="cosa_serve"></span>
</div>
<hr />
<p>&nbsp;</p>
<div class="field"
Expand Down
5 changes: 5 additions & 0 deletions src/redturtle/prenotazioni/content/prenotazione.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,8 @@ def canDeleteBooking(self):
# ):
# return True
# return False

def get_booking_type(self):
return {
i.title: i.title for i in self.getPrenotazioniFolder().get_booking_types()
}.get(self.booking_type, None)
11 changes: 0 additions & 11 deletions src/redturtle/prenotazioni/content/prenotazioni_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ class IPrenotazioniFolder(model.Schema):

form.mode(descriptionAgenda="display")

cosa_serve = RichText(
required=False,
title=_("Cosa serve", default="Cosa serve"),
description=_(
"Elencare le informazioni utili per il giorno della prenotazione, come ad esempio i documenti da presentare."
),
)

directives.widget(visible_booking_fields=CheckBoxFieldWidget)
visible_booking_fields = schema.List(
title=_("label_visible_booking_fields", default="Visible booking fields"),
Expand Down Expand Up @@ -731,8 +723,5 @@ def getFutureDays(self):
def getNotBeforeDays(self):
return self.notBeforeDays

def getCosaServe(self):
return self.cosa_serve

def get_booking_types(self) -> Generator[BookingType, None, None]:
return self.listFolderContents(contentFilter={"portal_type": "BookingType"})
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from zope.component import adapter, getMultiAdapter
from zope.i18n import translate
from zope.interface import implementer
from zope.interface.interfaces import ComponentLookupError
from zope.publisher.interfaces import IRequest
from zope.schema import getFields

from redturtle.prenotazioni import logger
from redturtle.prenotazioni.content.booking_type import IBookingType
from redturtle.prenotazioni.content.prenotazione import IPrenotazione
from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder
from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem


Expand All @@ -22,15 +23,18 @@ def __init__(self, prenotazione, request):
self.request = request

def __call__(self, *args, **kwargs):
booking_folder = self.prenotazione.getPrenotazioniFolder()
useful_docs = getMultiAdapter(
(
getFields(IPrenotazioniFolder)["cosa_serve"],
booking_folder,
self.request,
),
IFieldSerializer,
)()
booking_folder = self.prenotazione.getBookingFolder()
try:
requirements = getMultiAdapter(
(
getFields(IBookingType)["requirements"],
self.prenotazione.get_booking_type(),
self.request,
),
IFieldSerializer,
)()
except ComponentLookupError:
requirements = ""

if self.prenotazione.fiscalcode:
fiscalcode = self.prenotazione.fiscalcode.upper()
Expand Down Expand Up @@ -73,8 +77,8 @@ def __call__(self, *args, **kwargs):
"booking_folder_uid": booking_folder.UID(),
"vacation": self.prenotazione.isVacation(),
"booking_code": self.prenotazione.getBookingCode(),
"cosa_serve": useful_docs,
"notify_on_confirm": booking_folder.notify_on_confirm,
"cosa_serve": requirements,
}


Expand Down
10 changes: 9 additions & 1 deletion src/redturtle/prenotazioni/tests/test_vacation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ def setUp(self):
same_day_booking_disallowed="no",
)

api.content.create(
booking_type_A = api.content.create(
type="BookingType",
title="Type A",
duration=30,
container=self.folder_prenotazioni,
gates=["all"],
)

api.content.transition(
booking_type_A,
transition="publish",
)
booking_type_A.reindexObject(idxs=["review_state"])

week_table = self.folder_prenotazioni.week_table
for row in week_table:
row["morning_start"] = "0700"
Expand Down Expand Up @@ -105,6 +111,7 @@ def test_add_vacation(self):
],
},
)

self.assertEqual(res.status_code, 200)
# gates[0] is busy because of vacation
self.assertEqual(res.json()["gate"], self.folder_prenotazioni.gates[1])
Expand All @@ -123,6 +130,7 @@ def test_add_vacation(self):
],
},
)

self.assertEqual(res.status_code, 400)
self.assertEqual(
res.json()["message"],
Expand Down
1 change: 1 addition & 0 deletions src/redturtle/prenotazioni/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,4 @@ def to_2000(context):
booking_type.reindexObject(idxs=["review_state"])

delattr(obj, "booking_types")
delattr(obj, "cosa_serve")

0 comments on commit 1cdf5cb

Please sign in to comment.