Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default b_size for bookyngtypesvocab to 200 #38

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 200
[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()
Loading