Skip to content

Commit

Permalink
fix default (#95)
Browse files Browse the repository at this point in the history
* fix default

* fix: contextaware
  • Loading branch information
mamico authored Sep 26, 2023
1 parent 8ded7dc commit d1aaaa0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 42 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog
2.0.1 (unreleased)
------------------

- Utilizzare defaultFactory se il default è una funzione, altrimenti non viene
eseguita nel momento corretto.
[mamico]

- Rimosso searchabletext di prenotazioni doppio
[mamico]

Expand All @@ -16,7 +20,6 @@ Changelog
- Add configurable simultaneous bookings limit for the same user.
[folix-01]


2.0.0 (2023-09-12)
------------------

Expand Down
112 changes: 71 additions & 41 deletions src/redturtle/prenotazioni/content/prenotazioni_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
from z3c.form.browser.checkbox import CheckBoxFieldWidget
from zope import schema
from zope.component import provideAdapter
from zope.interface import Interface, Invalid, implementer, invariant
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
from zope.interface import implementer
from zope.interface import Interface
from zope.interface import Invalid
from zope.interface import invariant
from zope.interface import provider
from zope.schema.interfaces import IContextAwareDefaultFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

from redturtle.prenotazioni import _
from redturtle.prenotazioni.browser.widget import WeekTableOverridesFieldWidget
Expand Down Expand Up @@ -130,57 +136,81 @@ class IBookingTypeRow(Interface):
)


def notify_on_submit_subject_default_factory():
return _("notify_on_submit_subject_default_value", "Booking created ${title}")
@provider(IContextAwareDefaultFactory)
def notify_on_submit_subject_default_factory(context):
return context.translate(
_("notify_on_submit_subject_default_value", "Booking created ${title}")
)


def notify_on_submit_message_default_factory():
return _(
"notify_on_submit_message_default_value",
"Booking ${booking_type} for ${booking_date} at ${booking_time} was created.<a href=${booking_print_url}>Link</a>",
@provider(IContextAwareDefaultFactory)
def notify_on_submit_message_default_factory(context):
return context.translate(
_(
"notify_on_submit_message_default_value",
"Booking ${booking_type} for ${booking_date} at ${booking_time} was created.<a href=${booking_print_url}>Link</a>",
)
)


def notify_on_confirm_subject_default_factory():
return _(
"notify_on_confirm_subject_default_value",
"Booking of ${booking_date} at ${booking_time} was accepted",
@provider(IContextAwareDefaultFactory)
def notify_on_confirm_subject_default_factory(context):
return context.translate(
_(
"notify_on_confirm_subject_default_value",
"Booking of ${booking_date} at ${booking_time} was accepted",
)
)


def notify_on_confirm_message_default_factory():
return _(
"notify_on_confirm_message_default_value",
"The booking${booking_type} for ${title} was confirmed! <a href=${booking_print_url}>Link</a>",
@provider(IContextAwareDefaultFactory)
def notify_on_confirm_message_default_factory(context):
return context.translate(
_(
"notify_on_confirm_message_default_value",
"The booking${booking_type} for ${title} was confirmed! <a href=${booking_print_url}>Link</a>",
)
)


def notify_on_move_subject_default_factory():
return _(
"notify_on_move_subject_default_value",
"Modified the boolking date for ${title}",
@provider(IContextAwareDefaultFactory)
def notify_on_move_subject_default_factory(context):
return context.translate(
_(
"notify_on_move_subject_default_value",
"Modified the boolking date for ${title}",
)
)


def notify_on_move_message_default_factory():
return _(
"notify_on_move_message_default_value",
"The booking scheduling of ${booking_type} was modified."
"The new one is on ${booking_date} at ${booking_time}. <a href=${booking_print_url}>Link</a>.",
@provider(IContextAwareDefaultFactory)
def notify_on_move_message_default_factory(context):
return context.translate(
_(
"notify_on_move_message_default_value",
"The booking scheduling of ${booking_type} was modified."
"The new one is on ${booking_date} at ${booking_time}. <a href=${booking_print_url}>Link</a>.",
)
)


def notify_on_refuse_subject_default_factory():
return _(
"notify_on_refuse_subject_default_value",
"Booking refused for ${title}",
@provider(IContextAwareDefaultFactory)
def notify_on_refuse_subject_default_factory(context):
return context.translate(
_(
"notify_on_refuse_subject_default_value",
"Booking refused for ${title}",
)
)


def notify_on_refuse_message_default_factory():
return _(
"notify_on_refuse_message_default_value",
"The booking ${booking_type} of ${booking_date} at ${booking_time} was refused.",
@provider(IContextAwareDefaultFactory)
def notify_on_refuse_message_default_factory(context):
return context.translate(
_(
"notify_on_refuse_message_default_value",
"The booking ${booking_type} of ${booking_date} at ${booking_time} was refused.",
)
)


Expand Down Expand Up @@ -529,7 +559,7 @@ def data_validation(data):
default="Prenotazione created notification subject.",
),
description=_("notify_on_submit_subject_help", default=""),
default=notify_on_submit_subject_default_factory(),
defaultFactory=notify_on_submit_subject_default_factory,
required=False,
)
notify_on_submit_message = schema.Text(
Expand All @@ -538,7 +568,7 @@ def data_validation(data):
default="Prenotazione created notification message.",
),
description=_("notify_on_submit_message_help", default=""),
default=notify_on_submit_message_default_factory(),
defaultFactory=notify_on_submit_message_default_factory,
required=False,
)
notify_on_confirm_subject = schema.TextLine(
Expand All @@ -547,7 +577,7 @@ def data_validation(data):
default="Prenotazione confirmed notification subject.",
),
description=_("notify_on_confirm_subject_help", default=""),
default=notify_on_confirm_subject_default_factory(),
defaultFactory=notify_on_confirm_subject_default_factory,
required=False,
)
notify_on_confirm_message = schema.Text(
Expand All @@ -556,7 +586,7 @@ def data_validation(data):
default="Prenotazione confirmed notification message.",
),
description=_("notify_on_confirm_message_help", default=""),
default=notify_on_confirm_message_default_factory(),
defaultFactory=notify_on_confirm_message_default_factory,
required=False,
)
notify_on_move_subject = schema.TextLine(
Expand All @@ -565,7 +595,7 @@ def data_validation(data):
default="Prenotazione moved notification subject.",
),
description=_("notify_on_move_subject_help", default=""),
default=notify_on_move_subject_default_factory(),
defaultFactory=notify_on_move_subject_default_factory,
required=False,
)
notify_on_move_message = schema.Text(
Expand All @@ -574,7 +604,7 @@ def data_validation(data):
default="Prenotazione moved notification message.",
),
description=_("notify_on_move_message_help", default=""),
default=notify_on_move_message_default_factory(),
defaultFactory=notify_on_move_message_default_factory,
required=False,
)
notify_on_refuse_subject = schema.TextLine(
Expand All @@ -583,7 +613,7 @@ def data_validation(data):
default="Prenotazione refused notification subject.",
),
description=_("notify_on_refuse_subject_help", default=""),
default=notify_on_refuse_subject_default_factory(),
defaultFactory=notify_on_refuse_subject_default_factory,
required=False,
)
notify_on_refuse_message = schema.Text(
Expand All @@ -592,7 +622,7 @@ def data_validation(data):
default="Prenotazione created notification message.",
),
description=_("notify_on_refuse_message_help", default=""),
default=notify_on_refuse_message_default_factory(),
defaultFactory=notify_on_refuse_message_default_factory,
required=False,
)

Expand Down

0 comments on commit d1aaaa0

Please sign in to comment.