diff --git a/CHANGES.rst b/CHANGES.rst index 1982214..536345e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 1.2.4 (unreleased) ------------------ -- Nothing changed yet. +- default b_size for bookyngtypesvocab to 100 + [mamico] 1.2.3 (2024-03-13) diff --git a/src/design/plone/ioprenoto/restapi/serializers/configure.zcml b/src/design/plone/ioprenoto/restapi/serializers/configure.zcml index 650d83c..beec5aa 100644 --- a/src/design/plone/ioprenoto/restapi/serializers/configure.zcml +++ b/src/design/plone/ioprenoto/restapi/serializers/configure.zcml @@ -6,5 +6,6 @@ + diff --git a/src/design/plone/ioprenoto/restapi/serializers/vocabularies.py b/src/design/plone/ioprenoto/restapi/serializers/vocabularies.py new file mode 100644 index 0000000..401b33d --- /dev/null +++ b/src/design/plone/ioprenoto/restapi/serializers/vocabularies.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +from design.plone.ioprenoto.vocabularies.tipologies import IPrenotazioneTypesVocabulary +from plone.restapi.interfaces import ISerializeToJson +from plone.restapi.serializer.vocabularies import SerializeVocabularyToJson as Base +from zope.component import adapter +from zope.interface import implementer +from zope.interface import Interface + + +@implementer(ISerializeToJson) +@adapter(IPrenotazioneTypesVocabulary, Interface) +class SerializeVocabularyToJson(Base): + def __call__(self, vocabulary_id): + b_size = self.request.form.get("b_size", "") + if not b_size: + self.request.form["b_size"] = "200" + return super().__call__(vocabulary_id) diff --git a/src/design/plone/ioprenoto/vocabularies/tipologies.py b/src/design/plone/ioprenoto/vocabularies/tipologies.py index 47fe997..49e985a 100644 --- a/src/design/plone/ioprenoto/vocabularies/tipologies.py +++ b/src/design/plone/ioprenoto/vocabularies/tipologies.py @@ -11,6 +11,15 @@ from zope.schema.vocabulary import SimpleVocabulary +class IPrenotazioneTypesVocabulary(IVocabularyFactory): + pass + + +@implementer(IPrenotazioneTypesVocabulary) +class TypesVocabulary(SimpleVocabulary): + pass + + @implementer(IVocabularyFactory) class PrenotazioneTypesVocabulary(object): def booking_type2term(self, booking_type): @@ -48,7 +57,7 @@ def __call__(self, context): if term.value not in [t.value for t in terms]: terms.append(term) terms.sort(key=lambda x: x.title) - return SimpleVocabulary(terms) + return TypesVocabulary(terms) PrenotazioneTypesVocabularyFactory = PrenotazioneTypesVocabulary()