Skip to content

Commit

Permalink
Add hidden booking types (#103)
Browse files Browse the repository at this point in the history
* Add hidden bookign types

* Format + Changelog

* Fix tests

* Upgrade step

* Refactor the hidden booking types resection techique

* Update locales

* Update changelog

* Review requirements

* Formatting

* Update rolemap

* Wrong title fix

* Reset test to master

* Update readme

* Article

* Extend definition

* Update locales

* Update readme

* Update doc

* Fix grammar
  • Loading branch information
folix-01 authored Oct 13, 2023
1 parent 4e0f829 commit 6bb8b9a
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 271 deletions.
13 changes: 7 additions & 6 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
2.1.2 (unreleased)
------------------

- Nothing changed yet.
- Add hidden booking types for operator use.
[folix-01]


2.1.1 (2023-10-11)
Expand All @@ -18,24 +19,24 @@ Changelog
2.1.0 (2023-10-11)
------------------

- Add booking details to the export file
- Add booking details to the export file.
[folix-01]

- Change PrenotazioniFolder.cosa_serve field type to RichText
- Change PrenotazioniFolder.cosa_serve field type to RichText.
[folix-01]

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

- Rimosso searchabletext di prenotazioni doppio
- Rimosso searchabletext di prenotazioni doppio.
[mamico]

- Aggiunto indexer per fiscalcode uppercase per
fare ricerche case insensitive
fare ricerche case insensitive.
[mamico]

- Remove Contributor from the package permissions map
- Remove Contributor from the package permissions map.
[folix-01]

- Add configurable simultaneous bookings limit for the same user.
Expand Down
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,19 @@ Creating a new Booking Folder
If the product is correctly installed the **Booking Folder** entry is available on the `add new` action menu.

You can configure:

- hidden booking types for the internal usage
- more then one gate
- booking vacations
- custom duration for booking types
- week schedule for morning and afternoon time tables

Creating the hidden booking types
---------------------------------

You can hide your booking types from simple and anonymous users by using the 'Hidden Booking' flag
in your booking types definition. This way, it will only be available to users with the 'Bookings Manager'
permission. This feature may be useful if you want to restrict booking types for internal corporate use.

Creating a new booking content
------------------------------

Expand Down
42 changes: 33 additions & 9 deletions src/redturtle/prenotazioni/content/prenotazioni_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from redturtle.prenotazioni import _
from redturtle.prenotazioni.browser.widget import WeekTableOverridesFieldWidget
from redturtle.prenotazioni.config import DEFAULT_VISIBLE_BOOKING_FIELDS
from redturtle.prenotazioni.content.validators import PauseValidator, checkOverrides
from redturtle.prenotazioni.content.validators import (
PauseValidator,
checkOverrides,
)

try:
from plone.app.dexterity import textindexer
Expand All @@ -42,7 +45,9 @@ def get_from_form(form, fieldname):
return value
return None

number_of_entry = request.form.get("form.widgets.{}.count".format(fieldname))
number_of_entry = request.form.get(
"form.widgets.{}.count".format(fieldname)
)
data = []
prefix = "form.widgets.{}".format(fieldname)
for counter in range(int(number_of_entry)):
Expand Down Expand Up @@ -82,7 +87,9 @@ class IWeekTableRow(model.Schema):
)

afternoon_start = schema.Choice(
title=_("afternoon_start_label", default="Start time in the afternoon"),
title=_(
"afternoon_start_label", default="Start time in the afternoon"
),
vocabulary="redturtle.prenotazioni.VocOreInizio",
required=False,
)
Expand Down Expand Up @@ -130,6 +137,11 @@ class IBookingTypeRow(Interface):
required=True,
vocabulary="redturtle.prenotazioni.VocDurataIncontro",
)
hidden = schema.Bool(
title=_("Hidden type"),
required=False,
default=False,
)


@provider(IContextAwareDefaultFactory)
Expand Down Expand Up @@ -217,7 +229,9 @@ class IPrenotazioniFolder(model.Schema):
descriptionAgenda = RichText(
required=False,
title=_("Descrizione Agenda", default="Descrizione Agenda"),
description=_("Inserire il testo di presentazione dell'agenda corrente"),
description=_(
"Inserire il testo di presentazione dell'agenda corrente"
),
)

form.mode(descriptionAgenda="display")
Expand All @@ -232,7 +246,9 @@ class IPrenotazioniFolder(model.Schema):

directives.widget(visible_booking_fields=CheckBoxFieldWidget)
visible_booking_fields = schema.List(
title=_("label_visible_booking_fields", default="Visible booking fields"),
title=_(
"label_visible_booking_fields", default="Visible booking fields"
),
description=_(
"help_visible_booking_fields",
"User will not be able to add a booking unless those "
Expand All @@ -250,7 +266,9 @@ class IPrenotazioniFolder(model.Schema):

directives.widget(required_booking_fields=CheckBoxFieldWidget)
required_booking_fields = schema.List(
title=_("label_required_booking_fields", default="Required booking fields"),
title=_(
"label_required_booking_fields", default="Required booking fields"
),
description=_(
"help_required_booking_fields",
"User will not be able to add a booking unless those "
Expand Down Expand Up @@ -442,7 +460,9 @@ def get_options():
"booking_types_help",
default="Put booking types there (one per line).\n"
"If you do not provide this field, "
"not type selection will be available",
"not type selection will be available. "
"If the 'Hidden Type' flag is selected the type will only "
"be available to users with the 'Bookings Manager' permission",
),
value_type=DictRow(schema=IBookingTypeRow),
)
Expand Down Expand Up @@ -500,10 +520,14 @@ def data_validation(data):
raise Invalid(_("You should set a start time for afternoon."))
if interval["morning_start"] and interval["morning_end"]:
if interval["morning_start"] > interval["morning_end"]:
raise Invalid(_("Morning start should not be greater than end."))
raise Invalid(
_("Morning start should not be greater than end.")
)
if interval["afternoon_start"] and interval["afternoon_end"]:
if interval["afternoon_start"] > interval["afternoon_end"]:
raise Invalid(_("Afternoon start should not be greater than end."))
raise Invalid(
_("Afternoon start should not be greater than end.")
)

# TODO: definire o descrivere quando avviee la notifica
# TODO: inserire qui la chiave IO ? o su un config in zope.conf/environment ?
Expand Down
Loading

0 comments on commit 6bb8b9a

Please sign in to comment.