Skip to content

Commit

Permalink
Merge branch 'cekk_fiscalcode_stringinterp' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jan 27, 2025
2 parents f4d2da2 + f25fde9 commit 2ef613c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog

- Add booking code as qrcode attachment in email messages
- Nothing changed yet.
- Add also fiscalcode to stringinterp variables.
[cekk]


2.8.5 (2025-01-23)
Expand Down
1 change: 0 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extends =
[instance]
eggs +=
Products.PrintingMailHost
design.plone.ioprenoto

[versions]
docutils=0.21.2
6 changes: 6 additions & 0 deletions src/redturtle/prenotazioni/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
for="*"
name="booking_user_details"
/>
<adapter
factory=".stringinterp.BookingUserFiscalCodeSubstitution"
provides="plone.stringinterp.interfaces.IStringSubstitution"
for="*"
name="booking_user_fiscalcode"
/>
<adapter
factory=".stringinterp.BookingCodeSubstitution"
provides="plone.stringinterp.interfaces.IStringSubstitution"
Expand Down
9 changes: 9 additions & 0 deletions src/redturtle/prenotazioni/adapters/stringinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ def safe_call(self):
return getattr(self.context, "description", "")


@adapter(Interface)
class BookingUserFiscalCodeSubstitution(BaseSubstitution):
category = _("Booking")
description = _("The fiscal code of the user who made the reservation.")

def safe_call(self):
return getattr(self.context, "fiscalcode", "")


@adapter(Interface)
class BookingOfficeContactPhoneSubstitution(BaseSubstitution):
category = _("Booking")
Expand Down
16 changes: 16 additions & 0 deletions src/redturtle/prenotazioni/tests/test_stringinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,19 @@ def test_stringinterp(self):
)()
self.assertEqual(booking_time, "08:00")
self.assertEqual(booking_time_end, "08:30")

def test_stringinterp_fiscalcode(self):
booker = IBooker(self.folder_prenotazioni)
booking = booker.book(
{
"booking_date": self.tomorrow_8_0,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
"fiscalcode": "ABCDEF12G34H567I",
}
)
fiscalcode = getAdapter(
booking, IStringSubstitution, "booking_user_fiscalcode"
)()
self.assertEqual(fiscalcode, "ABCDEF12G34H567I")

0 comments on commit 2ef613c

Please sign in to comment.