Skip to content

Commit

Permalink
Add translated BookingExceedLimitException message
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Sep 29, 2023
1 parent 46e88bc commit 8e94839
Show file tree
Hide file tree
Showing 6 changed files with 715 additions and 693 deletions.
2 changes: 1 addition & 1 deletion src/redturtle/prenotazioni/adapters/booker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _validate_user_limit(self, fiscalcode):
if len(self.search_future_bookings_by_fiscalcode(fiscalcode)) >= (
self.context.max_bookings_allowed
):
raise BookingsLimitExceded
raise BookingsLimitExceded(self.context)

def search_future_bookings_by_fiscalcode(self, fiscalcode):
"""Find all the future bookings registered for the same fiscalcode"""
Expand Down
9 changes: 2 additions & 7 deletions src/redturtle/prenotazioni/content/prenotazioni_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@
from zope import schema
from zope.component import provideAdapter
from zope.i18n import translate
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.interface import Interface, Invalid, implementer, invariant, provider
from zope.schema.interfaces import IContextAwareDefaultFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary

from redturtle.prenotazioni import _
from redturtle.prenotazioni.browser.widget import WeekTableOverridesFieldWidget
Expand Down
20 changes: 16 additions & 4 deletions src/redturtle/prenotazioni/exceptions/booker.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# -*- coding: utf-8 -*-
from plone import api

from redturtle.prenotazioni import _


class BookerException(Exception):
pass


class BookingsLimitExceded(BookerException):
def __init__(
self, message="Booking limit is exceed for the current user", *args, **kwargs
):
return super().__init__(message, *args, **kwargs)
def __init__(self, bookings_folder=None, *args, **kwargs):
return super().__init__(
api.portal.translate(
_(
"bookings_limit_exceeded_exception",
default="Booking limit({limit}) is exceed for the current user",
)
).format(limit=bookings_folder.max_bookings_allowed),
*args,
**kwargs
)
Loading

0 comments on commit 8e94839

Please sign in to comment.