Skip to content

Commit

Permalink
default b_size for bookyngtypesvocab to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Apr 10, 2024
1 parent 803ec3d commit 2689677
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

<include package=".ovverrides" />

<adapter factory=".vocabularies.SerializeVocabularyToJson" />

</configure>
17 changes: 17 additions & 0 deletions src/design/plone/ioprenoto/restapi/serializers/vocabularies.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 10 additions & 1 deletion src/design/plone/ioprenoto/vocabularies/tipologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()

0 comments on commit 2689677

Please sign in to comment.