Skip to content

Commit

Permalink
Merge branch 'master' into default_factory
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico authored Sep 25, 2023
2 parents 2d7e430 + 05a0d59 commit 51ec494
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 52 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Changelog
eseguita nel momento corretto.
[mamico]

- Rimosso searchabletext di prenotazioni doppio
[mamico]

- Aggiunto indexer per fiscalcode uppercase per
fare ricerche case insensitive
[mamico]

- Remove Contributor from the package permissions map
[folix-01]

2.0.0 (2023-09-12)
------------------

Expand Down
15 changes: 0 additions & 15 deletions src/redturtle/prenotazioni/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,4 @@
name="redturtle.prenotazioni-hiddenprofiles"
/>

<adapter
factory=".indexes.Subject_prenotazione"
name="Subject"
/>

<adapter
factory=".indexes.SearchableText_prenotazione"
name="SearchableText"
/>

<adapter
factory=".indexes.Date"
name="Date"
/>

</configure>
17 changes: 16 additions & 1 deletion src/redturtle/prenotazioni/indexers/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@
>

<adapter
factory=".searchable_text.prenotazione"
factory=".prenotazione.Subject_prenotazione"
name="Subject"
/>

<adapter
factory=".prenotazione.SearchableText_prenotazione"
name="SearchableText"
/>

<adapter
factory=".prenotazione.Date"
name="Date"
/>

<adapter
factory=".prenotazione.fiscalcode"
name="fiscalcode"
/>

</configure>
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ def Date(obj):
Set as booking_date
"""
return obj.Date()


@indexer(IPrenotazione)
def fiscalcode(obj):
"""upper-ize fiscalcode for case insensitive search"""
if obj.fiscalcode:
return obj.fiscalcode.upper()
28 changes: 0 additions & 28 deletions src/redturtle/prenotazioni/indexers/searchable_text.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/redturtle/prenotazioni/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<version>1802</version>
<version>1803</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-collective.z3cform.datagridfield:default</dependency>
Expand Down
6 changes: 0 additions & 6 deletions src/redturtle/prenotazioni/profiles/default/rolemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,39 @@
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Bookings Manager" />
<role name="Contributor"/>
</permission>

<permission name="redturtle.prenotazioni: Add PrenotazioniDay" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Contributor"/>
<role name="Bookings Manager" />
</permission>

<permission name="redturtle.prenotazioni: Add PrenotazioniWeek" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Contributor"/>
<role name="Bookings Manager" />
</permission>

<permission name="redturtle.prenotazioni: Add PrenotazioniYear" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Contributor"/>
<role name="Bookings Manager" />
</permission>

<permission name="redturtle.prenotazioni: Add PrenotazioniFolder" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Owner"/>
<role name="Contributor"/>
<role name="Bookings Manager" />
</permission>

<permission name="redturtle.prenotazioni: search prenotazioni" acquire="True">
<role name="Manager"/>
<role name="Site Administrator"/>
<role name="Contributor"/>
<role name="Bookings Manager" />
</permission>

Expand Down
18 changes: 18 additions & 0 deletions src/redturtle/prenotazioni/tests/test_prenotazioni_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ def test_search_by_fiscalcode(self):
self.assertIn(self.prenotazione_fscode.UID(), result_uids)
self.assertNotIn(self.prenotazione_no_fscode.UID(), result_uids)

def test_search_by_fiscalcode_case_insensitive(self):
# ABCDEF12G34H567I -> AbCdEf12G34H567i
camelcase_fiscalcode = "".join(
[
c.upper() if i % 2 == 0 else c.lower()
for i, c in enumerate(self.testing_fiscal_code)
]
)
result_uids = [
i["booking_id"]
for i in self.api_session.get(
f"{self.portal.absolute_url()}/@bookings/{camelcase_fiscalcode}" # noqa: E501
).json()["items"]
]

self.assertIn(self.prenotazione_fscode.UID(), result_uids)
self.assertNotIn(self.prenotazione_no_fscode.UID(), result_uids)

def test_search_by_fiscalcode_traverse(self):
res = self.api_session.get(
f"{self.portal.absolute_url()}/@bookings/{self.testing_fiscal_code}"
Expand Down
11 changes: 10 additions & 1 deletion src/redturtle/prenotazioni/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,14 @@
handler=".upgrades.update_booking_code"
/>
</genericsetup:upgradeSteps>

<genericsetup:upgradeSteps
profile="redturtle.prenotazioni:default"
source="1802"
destination="1803"
>
<genericsetup:upgradeStep
title="Remove Contributor from package permissions"
handler=".upgrades.update_rolemap"
/>
</genericsetup:upgradeSteps>
</configure>

0 comments on commit 51ec494

Please sign in to comment.