Skip to content

Commit

Permalink
Merge branch 'master' into email_vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico authored Nov 17, 2023
2 parents 0eb75a9 + 9178b7f commit a1641cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
33 changes: 15 additions & 18 deletions src/redturtle/prenotazioni/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,25 +468,22 @@ def to_1808(context):


def to_2000(context):
for i in api.content.find(portal_type="PrenotazioniFolder"):
obj = aq_base(i.getObject())
if "booking_types" not in obj.__dict__: # noqa
for brain in api.content.find(portal_type="PrenotazioniFolder"):
obj = brain.getObject()
booking_types = obj.__dict__.get("booking_types", [])
if not booking_types:
continue
logger.info(f"Transforming <{i.UID}>.booking_types to contenttypes themself")
for type in obj.__dict__["booking_types"]:
logger.info(f" --| Creating {type.get('name')} booking type")
booking_type = api.content.create(
logger.info(
f"Transforming <{brain.UID}>.booking_types to contenttypes themself"
)
for booking_type in booking_types:
logger.info(f" --| Creating {booking_type.get('name')} booking type")
booking_type_obj = api.content.create(
type="PrenotazioneType",
title=type.get("name"),
duration=type.get("duration"),
# hidden=type.get("hidden"),
title=booking_type.get("name"),
duration=booking_type.get("duration"),
container=obj,
# gates=["all"],
)
if not type.get("hidden", False):
api.content.transition(obj=booking_type, transition="publish")
booking_type.reindexObject(idxs=["review_state"])

del obj.__dict__["booking_types"]
# getattr(obj, "booking_types", None) and delattr(obj, "booking_types")
# getattr(obj, "cosa_serve", None) and delattr(obj, "cosa_serve")
if not booking_type.get("hidden", False):
api.content.transition(obj=booking_type_obj, transition="publish")
booking_type_obj.reindexObject(idxs=["review_state"])
2 changes: 1 addition & 1 deletion src/redturtle/prenotazioni/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
handler=".upgrades.update_rolemap"
/>
<genericsetup:upgradeStep
title="Update rolemap"
title="Update types"
handler=".upgrades.update_types"
/>
<genericsetup:upgradeStep
Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/prenotazioni/vocabularies/tipologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def booking_type2term(self, booking_type):
if not duration:
title = name
else:
title = "%s (%d min)" % (name, duration)
title = f"{name} ({duration} min)"

return SimpleTerm(name, token=name, title=title)

Expand Down

0 comments on commit a1641cb

Please sign in to comment.