From e84f250618c17b77bb43a21c6f9ed86ab126dc51 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 25 Jan 2024 14:38:00 +0100 Subject: [PATCH] Fix: term values must be unique in booking_type vocabulary (#35) --- CHANGES.rst | 3 +++ src/design/plone/ioprenoto/vocabularies/tipologies.py | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7141562..73d911b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changelog 1.2.2 (unreleased) ------------------ +- Fix: term values must be unique in booking_type vocabulary + [mamico] + - Workaround per booking_type con caratteri encodati due volte [mamico] diff --git a/src/design/plone/ioprenoto/vocabularies/tipologies.py b/src/design/plone/ioprenoto/vocabularies/tipologies.py index 75fe7fb..0418c01 100644 --- a/src/design/plone/ioprenoto/vocabularies/tipologies.py +++ b/src/design/plone/ioprenoto/vocabularies/tipologies.py @@ -33,12 +33,11 @@ def __call__(self, context): if prenotazioni_folder and api.user.has_permission( "View", obj=prenotazioni_folder ): - terms.extend( - [ - self.booking_type2term(booking_type) - for booking_type in prenotazioni_folder.get_booking_types() - ] - ) + for booking_type in prenotazioni_folder.get_booking_types(): + term = self.booking_type2term(booking_type) + if term.value not in [t.value for t in terms]: + terms.append(term) + terms.sort(key=lambda x: x.title) return SimpleVocabulary(terms)