From 7f523913a97104c4b8118c708a46e7b41c0b7947 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 18 Jul 2023 17:17:48 +0200 Subject: [PATCH] Black to 79 chars --- docs/conf.py | 123 +++++++++--------- pyproject.toml | 2 + src/redturtle/prenotazioni/__init__.py | 12 +- src/redturtle/prenotazioni/actions/mail.py | 9 +- src/redturtle/prenotazioni/adapters/booker.py | 20 ++- .../prenotazioni/adapters/conflict.py | 4 +- src/redturtle/prenotazioni/adapters/slot.py | 14 +- .../prenotazioni/adapters/stringinterp.py | 3 +- src/redturtle/prenotazioni/browser/base.py | 8 +- .../browser/delete_reservation.py | 25 +++- .../prenotazioni/browser/folderfactories.py | 4 +- .../prenotazioni/browser/prenotazione.py | 12 +- .../prenotazioni/browser/prenotazione_add.py | 42 ++++-- .../prenotazioni/browser/prenotazione_move.py | 12 +- .../browser/prenotazioni_context_state.py | 34 +++-- .../browser/prenotazioni_portal_state.py | 4 +- .../browser/prenotazioni_search.py | 27 +++- .../browser/stats/booking_stats.py | 4 +- .../prenotazioni/browser/vacations.py | 8 +- src/redturtle/prenotazioni/browser/week.py | 12 +- .../prenotazioni/browser/z3c_custom_widget.py | 16 ++- src/redturtle/prenotazioni/content/pause.py | 8 +- .../prenotazioni/content/prenotazione.py | 15 ++- .../content/prenotazioni_folder.py | 40 ++++-- .../prenotazioni/content/validators.py | 7 +- .../prenotazioni/events/prenotazione.py | 4 +- .../events/prenotazioni_folder.py | 4 +- .../serializers/adapters/prenotazione.py | 12 +- .../restapi/services/booking/add.py | 14 +- .../restapi/services/booking_schema/get.py | 8 +- .../restapi/services/bookings/search.py | 8 +- .../restapi/services/month_slots/get.py | 21 +-- .../restapi/services/week_slots/get.py | 16 ++- src/redturtle/prenotazioni/scripts/app_io.py | 13 +- .../prenotazioni/scripts/io_tools/api.py | 24 +++- .../prenotazioni/scripts/io_tools/rdbms.py | 8 +- .../prenotazioni/scripts/io_tools/storage.py | 8 +- .../prenotazioni/tests/test_booking_info.py | 20 ++- .../prenotazioni/tests/test_booking_schema.py | 16 ++- .../prenotazioni/tests/test_delete_booking.py | 44 +++++-- .../tests/test_delete_booking_api.py | 48 ++++--- .../prenotazioni/tests/test_month_slots.py | 48 +++++-- .../prenotazioni/tests/test_prenotazione.py | 23 +++- ...prenotazione_searchable_item_serializer.py | 14 +- .../tests/test_prenotazioni_search.py | 18 ++- .../prenotazioni/tests/test_send_ical.py | 20 ++- .../prenotazioni/tests/test_setup.py | 24 +++- .../tests/test_week_table_overrides.py | 22 +++- src/redturtle/prenotazioni/upgrades.py | 28 +++- src/redturtle/prenotazioni/viewlets/app_io.py | 6 +- .../vocabularies/requirable_booking_fields.py | 3 +- .../vocabularies/voc_durata_incontro.py | 4 +- .../prenotazioni/vocabularies/voc_months.py | 48 +++++-- .../vocabularies/voc_ore_inizio.py | 4 +- 54 files changed, 702 insertions(+), 293 deletions(-) create mode 100644 pyproject.toml diff --git a/docs/conf.py b/docs/conf.py index a8874059..9aa20bf4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,12 +15,12 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -28,32 +28,32 @@ extensions = [] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'redturtle.prenotazioni' -copyright = u'Daniele Andreotti ()' -author = u'Daniele Andreotti ()' +project = "redturtle.prenotazioni" +copyright = "Daniele Andreotti ()" +author = "Daniele Andreotti ()" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'3.0' +version = "3.0" # The full version, including alpha/beta/rc tags. -release = u'3.0' +release = "3.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -64,38 +64,38 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -105,135 +105,132 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. # " v documentation" by default. -#html_title = u'bobtemplates.plone v3.0' +# html_title = u'bobtemplates.plone v3.0' # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not None, a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. # The empty string is equivalent to '%b %d, %Y'. -#html_last_updated_fmt = None +# html_last_updated_fmt = None # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # 'ja' uses this config value. # 'zh' user can custom change `jieba` dictionary path. -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'redturtle.prenotazionidoc' +htmlhelp_basename = "redturtle.prenotazionidoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', - -# Latex figure (float) alignment -#'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', + # Latex figure (float) alignment + #'figure_align': 'htbp', } # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..a8f43fef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 79 diff --git a/src/redturtle/prenotazioni/__init__.py b/src/redturtle/prenotazioni/__init__.py index f04df7dc..59b2c820 100644 --- a/src/redturtle/prenotazioni/__init__.py +++ b/src/redturtle/prenotazioni/__init__.py @@ -50,10 +50,14 @@ def get_or_create_obj(folder, key, portal_type): if not userid: raise UserNotFoundError() with api.env.adopt_user(userid): - return api.content.create(type=portal_type, title=key, container=folder) + return api.content.create( + type=portal_type, title=key, container=folder + ) except (UserNotFoundError, Unauthorized): with api.env.adopt_roles(["Manager"]): - return api.content.create(type=portal_type, title=key, container=folder) + return api.content.create( + type=portal_type, title=key, container=folder + ) def init_handler(): @@ -68,7 +72,9 @@ def init_handler(): if not logfile: return hdlr = FileHandler(logfile) - formatter = Formatter("%(asctime)s %(levelname)s %(message)s", "%Y-%m-%d %H:%M:%S") + formatter = Formatter( + "%(asctime)s %(levelname)s %(message)s", "%Y-%m-%d %H:%M:%S" + ) hdlr.setFormatter(formatter) prenotazioniFileLogger.addHandler(hdlr) diff --git a/src/redturtle/prenotazioni/actions/mail.py b/src/redturtle/prenotazioni/actions/mail.py index 1b2299fa..c1fa1ceb 100644 --- a/src/redturtle/prenotazioni/actions/mail.py +++ b/src/redturtle/prenotazioni/actions/mail.py @@ -2,7 +2,9 @@ from Acquisition import aq_base from Acquisition import aq_inner from collective.contentrules.mailfromfield import logger -from collective.contentrules.mailfromfield.actions.mail import IMailFromFieldAction +from collective.contentrules.mailfromfield.actions.mail import ( + IMailFromFieldAction, +) from collective.contentrules.mailfromfield.actions.mail import ( MailActionExecutor as BaseExecutor, ) @@ -72,7 +74,10 @@ def manage_attachments(self, msg): booking = self.event.object action = getattr(self.event, "action", "") if ( - not (action == "confirm" or IMovedPrenotazione.providedBy(self.event)) + not ( + action == "confirm" + or IMovedPrenotazione.providedBy(self.event) + ) or booking.portal_type != "Prenotazione" ): return diff --git a/src/redturtle/prenotazioni/adapters/booker.py b/src/redturtle/prenotazioni/adapters/booker.py index 5753f887..627399bc 100644 --- a/src/redturtle/prenotazioni/adapters/booker.py +++ b/src/redturtle/prenotazioni/adapters/booker.py @@ -29,7 +29,9 @@ def __init__(self, context): @memoize def prenotazioni(self): """The prenotazioni context state view""" - return self.context.unrestrictedTraverse("@@prenotazioni_context_state") # noqa + return self.context.unrestrictedTraverse( + "@@prenotazioni_context_state" + ) # noqa def get_available_gate(self, booking_date, booking_expiration_date=None): """ @@ -67,14 +69,18 @@ def _create(self, data, duration=-1, force_gate=""): booking_type = params.get("booking_type", "") if duration < 0: # if we pass a negative duration it will be recalculated - duration = self.prenotazioni.get_booking_type_duration(booking_type) + duration = self.prenotazioni.get_booking_type_duration( + booking_type + ) # duration = (float(duration) / MIN_IN_DAY) booking_expiration_date = params["booking_date"] + timedelta( minutes=duration ) else: # in this case we need to deal with seconds converted in days - booking_expiration_date = params["booking_date"] + timedelta(days=duration) + booking_expiration_date = params["booking_date"] + timedelta( + days=duration + ) gate = "" if not force_gate: @@ -109,8 +115,12 @@ def _create(self, data, duration=-1, force_gate=""): user.getProperty("fiscalcode", "") or user.getId() or "" ).upper() # noqa elif user.hasProperty("fiscalcode") and fiscalcode: - if (user.getProperty("fiscalcode") or "").upper() == fiscalcode: - logger.info("Booking verified: {}".format(obj.absolute_url())) + if ( + user.getProperty("fiscalcode") or "" + ).upper() == fiscalcode: + logger.info( + "Booking verified: {}".format(obj.absolute_url()) + ) annotations[VERIFIED_BOOKING] = True obj.reindexObject() diff --git a/src/redturtle/prenotazioni/adapters/conflict.py b/src/redturtle/prenotazioni/adapters/conflict.py index 7bde6b0a..d314db56 100644 --- a/src/redturtle/prenotazioni/adapters/conflict.py +++ b/src/redturtle/prenotazioni/adapters/conflict.py @@ -98,7 +98,9 @@ def extend_availability(self, slots, gate_slots): for slot in slots: if gate_slots[i].overlaps(slot): interval = gate_slots[i].union(slot) - gate_slots[i] = BaseSlot(interval.lower_value, interval.upper_value) + gate_slots[i] = BaseSlot( + interval.lower_value, interval.upper_value + ) return gate_slots + slots diff --git a/src/redturtle/prenotazioni/adapters/slot.py b/src/redturtle/prenotazioni/adapters/slot.py index 91c6c9c9..dcbef5ca 100644 --- a/src/redturtle/prenotazioni/adapters/slot.py +++ b/src/redturtle/prenotazioni/adapters/slot.py @@ -124,13 +124,19 @@ def __init__(self, start, stop, gate=""): def __len__(self): """The length of this object""" - if self._upper_value is None or self.lower_value is None or self.empty(): + if ( + self._upper_value is None + or self.lower_value is None + or self.empty() + ): return 0 return self._upper_value - self.lower_value def __nonzero__(self): """Check if this should be True""" - if isinstance(self._lower_value, int) and isinstance(self._upper_value, int): + if isinstance(self._lower_value, int) and isinstance( + self._upper_value, int + ): return 1 else: return 0 @@ -248,7 +254,9 @@ def get_values_hr_every(self, width, slot_min_size=0): class Slot(BaseSlot): def __eq__(self, other): """We need to compare also the context before comparing the boundaries""" - return self.context == other.context and super(Slot, self).__eq__(other) + return self.context == other.context and super(Slot, self).__eq__( + other + ) def __init__(self, context): """ diff --git a/src/redturtle/prenotazioni/adapters/stringinterp.py b/src/redturtle/prenotazioni/adapters/stringinterp.py index 79ec2ea8..e2d2b84a 100644 --- a/src/redturtle/prenotazioni/adapters/stringinterp.py +++ b/src/redturtle/prenotazioni/adapters/stringinterp.py @@ -186,7 +186,8 @@ def safe_call(self): class BookingOfficeCompleteAddressSubstitution(BaseSubstitution): category = _("Booking") description = _( - "The complete address information of the office where" "user book a reservation" + "The complete address information of the office where" + "user book a reservation" ) def safe_call(self): diff --git a/src/redturtle/prenotazioni/browser/base.py b/src/redturtle/prenotazioni/browser/base.py index e7da22d6..0e10462a 100644 --- a/src/redturtle/prenotazioni/browser/base.py +++ b/src/redturtle/prenotazioni/browser/base.py @@ -3,7 +3,9 @@ from plone.memoize.view import memoize from Products.Five.browser import BrowserView from redturtle.prenotazioni.adapters.conflict import IConflictManager -from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder +from redturtle.prenotazioni.content.prenotazioni_folder import ( + IPrenotazioniFolder, +) from zExceptions import NotFound @@ -31,7 +33,9 @@ def prenotazione_macros(self): Everyone should know about this! """ - return api.content.get_view("prenotazione_macros", self.context, self.request) + return api.content.get_view( + "prenotazione_macros", self.context, self.request + ) @property @memoize diff --git a/src/redturtle/prenotazioni/browser/delete_reservation.py b/src/redturtle/prenotazioni/browser/delete_reservation.py index 2dc2099e..d9e5556e 100644 --- a/src/redturtle/prenotazioni/browser/delete_reservation.py +++ b/src/redturtle/prenotazioni/browser/delete_reservation.py @@ -67,11 +67,15 @@ def __call__(self): self.uid = form.get("uid", None) if not self.uid: msg = self.missing_uid_error() - api.portal.show_message(message=msg, type="warning", request=self.request) + api.portal.show_message( + message=msg, type="warning", request=self.request + ) return self.request.response.redirect(self.context.absolute_url()) if not self.prenotazione: msg = self.missing_booking_error() - api.portal.show_message(message=msg, type="warning", request=self.request) + api.portal.show_message( + message=msg, type="warning", request=self.request + ) return self.request.response.redirect(self.context.absolute_url()) if not self.prenotazione.canDeleteBooking(): raise Unauthorized @@ -98,21 +102,30 @@ def __call__(self): ), context=self.request, ) - api.portal.show_message(message=msg, type="error", request=self.request) + api.portal.show_message( + message=msg, type="error", request=self.request + ) return self.request.response.redirect(self.context.absolute_url()) if not self.uid: msg = self.missing_uid_error() - api.portal.show_message(message=msg, type="warning", request=self.request) + api.portal.show_message( + message=msg, type="warning", request=self.request + ) return self.request.response.redirect(self.context.absolute_url()) res = self.do_delete() if not res: msg = translate( - _("booking_deleted_success", default="Your booking has been deleted."), + _( + "booking_deleted_success", + default="Your booking has been deleted.", + ), context=self.request, ) - api.portal.show_message(message=msg, type="info", request=self.request) + api.portal.show_message( + message=msg, type="info", request=self.request + ) else: if res.get("error", ""): api.portal.show_message( diff --git a/src/redturtle/prenotazioni/browser/folderfactories.py b/src/redturtle/prenotazioni/browser/folderfactories.py index 45c2e854..1c639f7f 100644 --- a/src/redturtle/prenotazioni/browser/folderfactories.py +++ b/src/redturtle/prenotazioni/browser/folderfactories.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -from plone.app.content.browser.folderfactories import FolderFactoriesView as BaseView +from plone.app.content.browser.folderfactories import ( + FolderFactoriesView as BaseView, +) class FolderFactoriesView(BaseView): diff --git a/src/redturtle/prenotazioni/browser/prenotazione.py b/src/redturtle/prenotazioni/browser/prenotazione.py index 43d4be2d..10d2db46 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione.py +++ b/src/redturtle/prenotazioni/browser/prenotazione.py @@ -46,7 +46,9 @@ def back_url(self): @memoize def move_url(self): """move this booking visiting this url""" - can_move = api.user.has_permission("Modify portal content", obj=self.context) + can_move = api.user.has_permission( + "Modify portal content", obj=self.context + ) if not can_move: return "" booking_date = self.booking_date @@ -64,7 +66,9 @@ def review_state(self): @property def reject_url(self): - can_review = api.user.has_permission("Review portal content", obj=self.context) + can_review = api.user.has_permission( + "Review portal content", obj=self.context + ) if not can_review: return "" return "{context_url}/content_status_modify?workflow_action=refuse&_authenticator={token}".format( # noqa @@ -84,7 +88,9 @@ def reset_duration(self): booking_type = self.context.getBooking_type() duration = self.request.form.get("duration", 0) if not duration: - duration = self.prenotazioni.get_booking_type_duration(booking_type) + duration = self.prenotazioni.get_booking_type_duration( + booking_type + ) duration = float(duration) / MIN_IN_DAY self.context.setBooking_expiration_date(self.booking_date + duration) diff --git a/src/redturtle/prenotazioni/browser/prenotazione_add.py b/src/redturtle/prenotazioni/browser/prenotazione_add.py index 55389c62..13d0fcfe 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione_add.py +++ b/src/redturtle/prenotazioni/browser/prenotazione_add.py @@ -10,8 +10,12 @@ from Products.CMFPlone.interfaces.controlpanel import IMailSchema from redturtle.prenotazioni import _ from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.browser.week import TIPOLOGIA_PRENOTAZIONE_NAME_COOKIE -from redturtle.prenotazioni.browser.z3c_custom_widget import CustomRadioFieldWidget +from redturtle.prenotazioni.browser.week import ( + TIPOLOGIA_PRENOTAZIONE_NAME_COOKIE, +) +from redturtle.prenotazioni.browser.z3c_custom_widget import ( + CustomRadioFieldWidget, +) from redturtle.prenotazioni.config import REQUIRABLE_AND_VISIBLE_FIELDS from redturtle.prenotazioni.content.prenotazione import IPrenotazione from redturtle.prenotazioni.utilities.urls import urlify @@ -46,7 +50,9 @@ class IAddForm(IPrenotazione): title=_("label_booking_title", "Fullname"), default="", required=True ) description = Text( - title=_("label_booking_description", "Subject"), default="", required=False + title=_("label_booking_description", "Subject"), + default="", + required=False, ) @@ -67,7 +73,11 @@ def fields(self): fields["booking_type"].widgetFactory = CustomRadioFieldWidget # omit some fields - fields = fields.omit("gate").omit("booking_expiration_date").omit("staff_notes") + fields = ( + fields.omit("gate") + .omit("booking_expiration_date") + .omit("staff_notes") + ) # move title on top (after the type) ids = [x for x in fields.keys()] @@ -89,7 +99,9 @@ def updateWidgets(self): "redturtle.prenotazioni.requirable_booking_fields", ) required_fields_vocabulary = required_fields_factory(self.context) - possibly_required_fields = [x.token for x in required_fields_vocabulary._terms] + possibly_required_fields = [ + x.token for x in required_fields_vocabulary._terms + ] for f in self.widgets.values(): # If you have a field required by schema, when you fill the field @@ -132,7 +144,9 @@ def updateWidgets(self): @memoize def localized_time(self): """Facade for context/@@plone/toLocalizedTime""" - return api.content.get_view("plone", self.context, self.request).toLocalizedTime + return api.content.get_view( + "plone", self.context, self.request + ).toLocalizedTime @property @memoize @@ -169,7 +183,9 @@ def booking_DateTime(self): """ booking_date = self.request.form.get("form.booking_date", None) if not booking_date: - booking_date = self.request.form.get("form.widgets.booking_date", None) + booking_date = self.request.form.get( + "form.widgets.booking_date", None + ) if not booking_date: return None @@ -272,7 +288,9 @@ def action_book(self, action): obj = self.do_book(data) if not obj: msg = _("Sorry, this slot is not available anymore.") - api.portal.show_message(message=msg, type="warning", request=self.request) + api.portal.show_message( + message=msg, type="warning", request=self.request + ) target = self.back_to_booking_url return self.request.response.redirect(target) msg = _("booking_created") @@ -297,7 +315,9 @@ def action_book(self, action): return self.request.response.redirect(target) - @button.buttonAndHandler(_("action_cancel", default="Cancel"), name="cancel") + @button.buttonAndHandler( + _("action_cancel", default="Cancel"), name="cancel" + ) def action_cancel(self, action): """ Cancel @@ -338,7 +358,9 @@ def __call__(self): def get_mail_from_address(self): registry = getUtility(IRegistry) - mail_settings = registry.forInterface(IMailSchema, prefix="plone", check=False) + mail_settings = registry.forInterface( + IMailSchema, prefix="plone", check=False + ) from_address = mail_settings.email_from_address from_name = mail_settings.email_from_name diff --git a/src/redturtle/prenotazioni/browser/prenotazione_move.py b/src/redturtle/prenotazioni/browser/prenotazione_move.py index b44a582c..70a09c16 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione_move.py +++ b/src/redturtle/prenotazioni/browser/prenotazione_move.py @@ -28,7 +28,9 @@ class IMoveForm(Interface): Interface for moving a prenotazione """ - booking_date = Datetime(title=_("label_booking_time", "Booking time"), default=None) + booking_date = Datetime( + title=_("label_booking_time", "Booking time"), default=None + ) gate = TextLine(title=_("label_gate", "Gate"), default="", required=False) @@ -155,13 +157,17 @@ def action_move(self, action): data["booking_type"] = self.context.getBooking_type() conflict_manager = self.prenotazioni_view.conflict_manager current_data = self.context.getBooking_date() - current = {"booking_date": current_data, "booking_type": data["booking_type"]} + current = { + "booking_date": current_data, + "booking_type": data["booking_type"], + } current_slot = conflict_manager.get_choosen_slot(current) current_gate = getattr(self.context, "gate", "") exclude = {current_gate: [current_slot]} if conflict_manager.conflicts(data, exclude=exclude): msg = _( - "Sorry, this slot is not available or does not fit your " "booking." + "Sorry, this slot is not available or does not fit your " + "booking." ) api.portal.show_message(msg, self.request, type="error") raise ActionExecutionError(Invalid(msg)) diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py index 99d788a4..562234b0 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py @@ -101,7 +101,9 @@ def user_can_manage(self): """States if the authenticated user can manage this context""" if self.is_anonymous: return False - return api.user.has_permission("Modify portal content", obj=self.context) + return api.user.has_permission( + "Modify portal content", obj=self.context + ) @property @memoize @@ -288,7 +290,8 @@ def remembered_params(self): and key.startswith("form.") and not key.startswith("form.action") and key not in ("form.booking_date",) - or key in ("disable_plone.leftcolumn", "disable_plone.rightcolumn") + or key + in ("disable_plone.leftcolumn", "disable_plone.rightcolumn") ) ) for key, value in six.iteritems(params): @@ -324,7 +327,9 @@ def get_booking_urls(self, day, slot, slot_min_size=0, gate=None): params["form.booking_date"] = form_booking_date if gate: params["gate"] = gate - booking_date = DateTime(params["form.booking_date"]).asdatetime() # noqa + booking_date = DateTime( + params["form.booking_date"] + ).asdatetime() # noqa urls.append( { "title": t, @@ -532,7 +537,9 @@ def weektable_boundaries(self): for key, value in six.iteritems(boundaries): boundaries[key] = hm2seconds(value) return { - "morning": BaseSlot(boundaries["morning_start"], boundaries["morning_end"]), + "morning": BaseSlot( + boundaries["morning_start"], boundaries["morning_end"] + ), "afternoon": BaseSlot( boundaries["afternoon_start"], boundaries["afternoon_end"] ), @@ -613,7 +620,9 @@ def get_pauses_in_day_folder(self, booking_date): """ weekday = booking_date.weekday() pause_table = self.context.pause_table or [] - today_pauses = [row for row in pause_table if row["day"] == str(weekday)] + today_pauses = [ + row for row in pause_table if row["day"] == str(weekday) + ] pauses = [] if today_pauses: for pause in today_pauses: @@ -641,7 +650,9 @@ def get_existing_slots_in_day_folder(self, booking_date): def get_busy_slots_in_stormynight(self, booking_date): """This will show the slots that will not show elsewhere""" morning_slots = self.get_busy_slots_in_period(booking_date, "morning") - afternoon_slots = self.get_busy_slots_in_period(booking_date, "afternoon") + afternoon_slots = self.get_busy_slots_in_period( + booking_date, "afternoon" + ) all_slots = self.get_existing_slots_in_day_folder(booking_date) return sorted( [ @@ -724,7 +735,10 @@ def get_free_slots(self, booking_date, period="day"): for gate in gates: # unavailable gates doesn't have free slots # XXX Riprendi da qui: - if self.get_unavailable_gates() and gate in self.get_unavailable_gates(): + if ( + self.get_unavailable_gates() + and gate in self.get_unavailable_gates() + ): availability[gate] = [] else: availability.setdefault(gate, []) @@ -748,7 +762,8 @@ def get_freebusy_slots(self, booking_date, period="day"): busy = self.get_busy_slots(booking_date, period) keys = set(list(free.keys()) + list(busy.keys())) return dict( - (key, sorted(free.get(key, []) + busy.get(key, []))) for key in keys + (key, sorted(free.get(key, []) + busy.get(key, []))) + for key in keys ) def get_anonymous_slots(self, booking_date, period="day"): @@ -858,7 +873,8 @@ def get_first_slot(self, booking_type, booking_date, period="day"): for slots in six.itervalues(availability): for slot in slots: if len(slot) >= duration and ( - booking_date > self.first_bookable_date or slot.start() >= hm_now + booking_date > self.first_bookable_date + or slot.start() >= hm_now ): good_slots.append(slot) if not good_slots: diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py index 00543892..58e79e99 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py @@ -42,7 +42,9 @@ def booking_review_states(self): terms = [] for state in states: key = state.getId() - title = translate(__(safe_unicode(state.title)), context=self.request) + title = translate( + __(safe_unicode(state.title)), context=self.request + ) terms.append(SimpleTerm(key, title=title)) terms.sort(key=lambda x: x.title) return SimpleVocabulary(terms) diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_search.py b/src/redturtle/prenotazioni/browser/prenotazioni_search.py index 3356a054..6f21c83e 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_search.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_search.py @@ -38,7 +38,9 @@ class ISearchForm(Interface): Interface for creating a prenotazione """ - text = TextLine(title=_("label_text", "Text to search"), default="", required=False) + text = TextLine( + title=_("label_text", "Text to search"), default="", required=False + ) review_state = Choice( title=__("State"), default="", @@ -102,7 +104,9 @@ def get_prenotazioni_states(self): vocabulary = factory(self.context) if not vocabulary: return "" - return {k: v.title for (k, v) in factory(self.context).by_token.items()} + return { + k: v.title for (k, v) in factory(self.context).by_token.items() + } def get_query(self, data): """The query we requested""" @@ -117,7 +121,9 @@ def get_query(self, data): if data.get("review_state"): query["review_state"] = data["review_state"] if data.get("gate"): - factory = getUtility(IVocabularyFactory, "redturtle.prenotazioni.gates") + factory = getUtility( + IVocabularyFactory, "redturtle.prenotazioni.gates" + ) vocabulary = factory(context=self.context) try: term = vocabulary.getTermByToken(data["gate"]) @@ -178,7 +184,9 @@ def set_search_string(self, data): if "start" in data and data.get("start", None): if isinstance(data.get("start"), str): - data["start"] = datetime.strptime(data.get("start"), "%Y-%m-%d") + data["start"] = datetime.strptime( + data.get("start"), "%Y-%m-%d" + ) result.append( MARKUP.format( self.context.translate(_("label_start", "Start date ")), @@ -243,7 +251,9 @@ def action_search(self, action): self.status = self.formErrorsMessage return - @button.buttonAndHandler(_("move_back_message", default="Go back to the calendar")) + @button.buttonAndHandler( + _("move_back_message", default="Go back to the calendar") + ) def action_cancel(self, action): """ Cancel and go back to the week view @@ -276,7 +286,8 @@ def get_row_data(self, brain): obj = brain.getObject() custom_fields = [ - getattr(obj, x, "") or "" for x in self.context.visible_booking_fields + getattr(obj, x, "") or "" + for x in self.context.visible_booking_fields ] return ( @@ -306,7 +317,9 @@ def get_prenotazioni_states(self): vocabulary = factory(self.context) if not vocabulary: return "" - return {k: v.title for (k, v) in factory(self.context).by_token.items()} + return { + k: v.title for (k, v) in factory(self.context).by_token.items() + } def get_prenotazione_state(self, obj): states = self.get_prenotazioni_states() diff --git a/src/redturtle/prenotazioni/browser/stats/booking_stats.py b/src/redturtle/prenotazioni/browser/stats/booking_stats.py index c33a283a..94141340 100644 --- a/src/redturtle/prenotazioni/browser/stats/booking_stats.py +++ b/src/redturtle/prenotazioni/browser/stats/booking_stats.py @@ -10,7 +10,9 @@ from redturtle.prenotazioni import _ from redturtle.prenotazioni import logger from redturtle.prenotazioni import prenotazioniFileLogger -from redturtle.prenotazioni.browser.base import BaseView as PrenotazioniBaseView +from redturtle.prenotazioni.browser.base import ( + BaseView as PrenotazioniBaseView, +) from time import mktime from zope.annotation.interfaces import IAnnotations from zope.interface import Interface diff --git a/src/redturtle/prenotazioni/browser/vacations.py b/src/redturtle/prenotazioni/browser/vacations.py index 66324a77..72c2dff4 100644 --- a/src/redturtle/prenotazioni/browser/vacations.py +++ b/src/redturtle/prenotazioni/browser/vacations.py @@ -105,7 +105,9 @@ def fields(self): def updateWidgets(self): super(VacationBooking, self).updateWidgets() - self.widgets["start_date"].value = datetime.today().strftime("%Y-%m-%d") + self.widgets["start_date"].value = datetime.today().strftime( + "%Y-%m-%d" + ) def get_parsed_data(self, data): """ @@ -238,7 +240,9 @@ def do_book(self, data): # duration = float(len(slot)) / 60 slot_data = {k: v for k, v in data.items() if k != "gate"} slot_data["booking_date"] = booking_date - booker.create(slot_data, duration=duration, force_gate=data.get("gate")) + booker.create( + slot_data, duration=duration, force_gate=data.get("gate") + ) msg = _("booking_created") IStatusMessage(self.request).add(msg, "info") diff --git a/src/redturtle/prenotazioni/browser/week.py b/src/redturtle/prenotazioni/browser/week.py index b2d5c6b0..96359aff 100644 --- a/src/redturtle/prenotazioni/browser/week.py +++ b/src/redturtle/prenotazioni/browser/week.py @@ -35,7 +35,9 @@ def translation_service(self): @memoize def localized_time(self): """Facade for context/@@plone/toLocalizedTime""" - return api.content.get_view("plone", self.context, self.request).toLocalizedTime + return api.content.get_view( + "plone", self.context, self.request + ).toLocalizedTime def DT2time(self, value): """ @@ -55,7 +57,9 @@ def user_can_manage(self): """States if the authenticated user can manage this context""" if api.user.is_anonymous(): return False - return api.user.has_permission("Modify portal content", obj=self.context) + return api.user.has_permission( + "Modify portal content", obj=self.context + ) @property @memoize @@ -300,7 +304,9 @@ def set_cookies(self): def set_prenotation_type(self): prenotation_type = self.get_prenotation_type() - cookie_value = self.request.cookies.get(TIPOLOGIA_PRENOTAZIONE_NAME_COOKIE, "") + cookie_value = self.request.cookies.get( + TIPOLOGIA_PRENOTAZIONE_NAME_COOKIE, "" + ) if prenotation_type and not cookie_value: # set expiring cookies diff --git a/src/redturtle/prenotazioni/browser/z3c_custom_widget.py b/src/redturtle/prenotazioni/browser/z3c_custom_widget.py index 32a942af..1f1a2d49 100644 --- a/src/redturtle/prenotazioni/browser/z3c_custom_widget.py +++ b/src/redturtle/prenotazioni/browser/z3c_custom_widget.py @@ -67,7 +67,9 @@ def unbookable_items(self): keys = sorted(self.booking_types_bookability["unbookable"]) keys = [key for key in keys] return [ - self.vocabulary.getTerm(key) for key in keys if key in self.context.terms + self.vocabulary.getTerm(key) + for key in keys + if key in self.context.terms ] @@ -107,7 +109,9 @@ def bookable_items(self): """Get booking_type bookability""" keys = sorted(self.booking_types_bookability["bookable"]) keys = [safe_unicode(key) for key in keys] - return [self.vocabulary.getTerm(key) for key in keys if key in self.terms] + return [ + self.vocabulary.getTerm(key) for key in keys if key in self.terms + ] @property @memoize @@ -116,7 +120,9 @@ def unbookable_items(self): keys = sorted(self.booking_types_bookability["unbookable"]) keys = [safe_unicode(key) for key in keys] return [ - self.vocabulary.getTerm(key) for key in keys if key in self.context.terms + self.vocabulary.getTerm(key) + for key in keys + if key in self.context.terms ] @property @@ -130,7 +136,9 @@ def items(self): checked = self.isChecked(term) id = "%s-%i" % (self.id, count) if zope.schema.interfaces.ITitledTokenizedTerm.providedBy(term): - label = translate(term.title, context=self.request, default=term.title) + label = translate( + term.title, context=self.request, default=term.title + ) else: label = util.toUnicode(term.value) results.append( diff --git a/src/redturtle/prenotazioni/content/pause.py b/src/redturtle/prenotazioni/content/pause.py index 69cf4503..c58d3200 100644 --- a/src/redturtle/prenotazioni/content/pause.py +++ b/src/redturtle/prenotazioni/content/pause.py @@ -44,10 +44,14 @@ def getBooking_date(self): # we use as base date 1970/01/01 # we pass these data to a method that convert it to a day agnostic # number - return datetime.strptime("1970/01/01 {}".format(self.start), "%Y/%m/%d %H:%M") + return datetime.strptime( + "1970/01/01 {}".format(self.start), "%Y/%m/%d %H:%M" + ) def getBooking_expiration_date(self): # we use as base date 1970/01/01 # we pass these data to a method that convert it to a day agnostic # number - return datetime.strptime("1970/01/01 {}".format(self.stop), "%Y/%m/%d %H:%M") + return datetime.strptime( + "1970/01/01 {}".format(self.stop), "%Y/%m/%d %H:%M" + ) diff --git a/src/redturtle/prenotazioni/content/prenotazione.py b/src/redturtle/prenotazioni/content/prenotazione.py index 09b57390..b806d3bb 100644 --- a/src/redturtle/prenotazioni/content/prenotazione.py +++ b/src/redturtle/prenotazioni/content/prenotazione.py @@ -213,7 +213,8 @@ def getPrenotazioniFolder(self): if IPrenotazioniFolder.providedBy(parent): return parent raise Exception( - "Could not find Prenotazioni Folder " "in acquisition chain of %r" % self + "Could not find Prenotazioni Folder " + "in acquisition chain of %r" % self ) def getDuration(self): @@ -249,7 +250,9 @@ def canAccessBooking(self): else: current_user = api.user.get_current() if ( - not api.user.has_permission("redturtle.prenotazioni.ManagePrenotazioni") + not api.user.has_permission( + "redturtle.prenotazioni.ManagePrenotazioni" + ) and creator != current_user.getUserName() ): return False @@ -260,14 +263,18 @@ def canDeleteBooking(self): if not creator: if api.user.is_anonymous(): return True - if api.user.has_permission("redturtle.prenotazioni.ManagePrenotazioni"): + if api.user.has_permission( + "redturtle.prenotazioni.ManagePrenotazioni" + ): return True else: if api.user.is_anonymous(): return False current_user = api.user.get_current() if ( - api.user.has_permission("redturtle.prenotazioni.ManagePrenotazioni") + api.user.has_permission( + "redturtle.prenotazioni.ManagePrenotazioni" + ) or creator == current_user.getUserName() ): return True diff --git a/src/redturtle/prenotazioni/content/prenotazioni_folder.py b/src/redturtle/prenotazioni/content/prenotazioni_folder.py index 47f4c2c0..fe6ea584 100644 --- a/src/redturtle/prenotazioni/content/prenotazioni_folder.py +++ b/src/redturtle/prenotazioni/content/prenotazioni_folder.py @@ -44,7 +44,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)): @@ -84,7 +86,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, ) @@ -141,7 +145,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") @@ -156,7 +162,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 " @@ -174,7 +182,9 @@ class IPrenotazioniFolder(model.Schema): directives.widget(required_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 " @@ -208,7 +218,9 @@ def get_options(): options = [ SimpleTerm(value="yes", token="yes", title=_("Yes")), SimpleTerm(value="no", token="no", title=_("No")), - SimpleTerm(value=today, token=today, title=_("No, just for today")), + SimpleTerm( + value=today, token=today, title=_("No, just for today") + ), ] return SimpleVocabulary(options) @@ -311,7 +323,9 @@ def get_options(): value_type=DictRow(title="Pause row", schema=IPauseTableRow), ) form.widget( - "pause_table", DataGridFieldFactory, frontendOptions={"widget": "data_grid"} + "pause_table", + DataGridFieldFactory, + frontendOptions={"widget": "data_grid"}, ) holidays = schema.List( @@ -361,7 +375,9 @@ def get_options(): value_type=DictRow(schema=IBookingTypeRow), ) form.widget( - "booking_types", DataGridFieldFactory, frontendOptions={"widget": "data_grid"} + "booking_types", + DataGridFieldFactory, + frontendOptions={"widget": "data_grid"}, ) gates = schema.List( @@ -449,10 +465,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 ? diff --git a/src/redturtle/prenotazioni/content/validators.py b/src/redturtle/prenotazioni/content/validators.py index 91ebe7f4..f0612e4e 100644 --- a/src/redturtle/prenotazioni/content/validators.py +++ b/src/redturtle/prenotazioni/content/validators.py @@ -28,7 +28,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)): @@ -88,7 +90,8 @@ def validate(self, pause_table): ): raise Invalid( translate( - _("You must set both start and end"), context=getRequest() + _("You must set both start and end"), + context=getRequest(), ) ) diff --git a/src/redturtle/prenotazioni/events/prenotazione.py b/src/redturtle/prenotazioni/events/prenotazione.py index eb6d2443..d8646dcc 100644 --- a/src/redturtle/prenotazioni/events/prenotazione.py +++ b/src/redturtle/prenotazioni/events/prenotazione.py @@ -12,7 +12,9 @@ def reallocate_gate(obj): """ context = obj.object - if context.REQUEST.form.get("form.gate", "") and getattr(context, "gate", ""): + if context.REQUEST.form.get("form.gate", "") and getattr( + context, "gate", "" + ): return container = context.getPrenotazioniFolder() diff --git a/src/redturtle/prenotazioni/events/prenotazioni_folder.py b/src/redturtle/prenotazioni/events/prenotazioni_folder.py index a46991e0..fb203872 100644 --- a/src/redturtle/prenotazioni/events/prenotazioni_folder.py +++ b/src/redturtle/prenotazioni/events/prenotazioni_folder.py @@ -20,7 +20,9 @@ def on_create(obj, event): ]: assignable[rule_id] = RuleAssignment(rule_id) assignable[rule_id].bubbles = True - get_assignments(storage[rule_id]).insert("/".join(obj.getPhysicalPath())) + get_assignments(storage[rule_id]).insert( + "/".join(obj.getPhysicalPath()) + ) def sort_on_creation_or_change(obj, event): diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py index b5351d98..0f83a68b 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py @@ -38,7 +38,9 @@ def __call__(self, *args, **kwargs): "fiscalcode": fiscalcode, "company": self.prenotazione.company, "staff_notes": self.prenotazione.staff_notes, - "booking_date": datetimelike_to_iso(self.prenotazione.booking_date), + "booking_date": datetimelike_to_iso( + self.prenotazione.booking_date + ), "booking_expiration_date": datetimelike_to_iso( self.prenotazione.booking_expiration_date ), @@ -57,13 +59,17 @@ def __init__(self, prenotazione, request): def __call__(self, *args, **kwargs): wf_tool = api.portal.get_tool("portal_workflow") - status = wf_tool.getStatusOf("prenotazioni_workflow", self.prenotazione) + status = wf_tool.getStatusOf( + "prenotazioni_workflow", self.prenotazione + ) return { "booking_id": self.prenotazione.UID(), "booking_code": self.prenotazione.getBookingCode(), "booking_url": self.prenotazione.absolute_url(), - "booking_date": datetimelike_to_iso(self.prenotazione.booking_date), + "booking_date": datetimelike_to_iso( + self.prenotazione.booking_date + ), "booking_expiration_date": datetimelike_to_iso( self.prenotazione.booking_expiration_date ), diff --git a/src/redturtle/prenotazioni/restapi/services/booking/add.py b/src/redturtle/prenotazioni/restapi/services/booking/add.py index 8bc21aae..78c678c8 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/add.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/add.py @@ -22,7 +22,9 @@ class AddBooking(Service): def reply(self): data = json_body(self.request) - data_fields = {field["name"]: field["value"] for field in data["fields"]} + data_fields = { + field["name"]: field["value"] for field in data["fields"] + } required = self.context.required_booking_fields or [] @@ -41,9 +43,9 @@ def reply(self): if isinstance(data["booking_date"], str): # TODO: redturtle.prenotazioni lavora con date naive, quindi toglia la timezone # ma non dovrebbe essere così - data["booking_date"] = datetime.fromisoformat(data["booking_date"]).replace( - tzinfo=None - ) + data["booking_date"] = datetime.fromisoformat( + data["booking_date"] + ).replace(tzinfo=None) for field in required: if field in ("booking_date", "booking_type"): @@ -59,7 +61,9 @@ def reply(self): return dict(error=dict(type="Bad Request", message=msg)) if data["booking_type"] not in [ - _t["name"] for _t in self.context.booking_types or [] if "name" in _t + _t["name"] + for _t in self.context.booking_types or [] + if "name" in _t ]: self.request.response.setStatus(400) msg = self.context.translate( diff --git a/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py b/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py index ae4726fb..ab8e9c40 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py +++ b/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py @@ -43,7 +43,9 @@ def reply(self): # noqa: C901 """ booking_context_state_view = api.content.get_view( - "prenotazioni_context_state", context=self.context, request=self.request + "prenotazioni_context_state", + context=self.context, + request=self.request, ) current_user = None @@ -72,7 +74,9 @@ def reply(self): # noqa: C901 except ValueError: raise ValueError("Wrong date format") - bookings = booking_context_state_view.booking_types_bookability(booking_date) + bookings = booking_context_state_view.booking_types_bookability( + booking_date + ) fields_list = [] fields = ["fullname"] diff --git a/src/redturtle/prenotazioni/restapi/services/bookings/search.py b/src/redturtle/prenotazioni/restapi/services/bookings/search.py index f6061764..7529bce9 100644 --- a/src/redturtle/prenotazioni/restapi/services/bookings/search.py +++ b/src/redturtle/prenotazioni/restapi/services/bookings/search.py @@ -2,7 +2,9 @@ from DateTime import DateTime from plone import api from plone.restapi.services import Service -from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem +from redturtle.prenotazioni.interfaces import ( + ISerializeToPrenotazioneSearchableItem, +) from zExceptions import Unauthorized from zope.component import getMultiAdapter from zope.interface import implementer @@ -26,7 +28,9 @@ def reply(self): if api.user.is_anonymous(): raise Unauthorized("You must be logged in to perform this action") - elif api.user.has_permission("redturtle.prenotazioni: search prenotazioni"): + elif api.user.has_permission( + "redturtle.prenotazioni: search prenotazioni" + ): userid = self.request.get("userid", None) else: userid = api.user.get_current().getUserId() diff --git a/src/redturtle/prenotazioni/restapi/services/month_slots/get.py b/src/redturtle/prenotazioni/restapi/services/month_slots/get.py index 895ef9d6..042b996b 100644 --- a/src/redturtle/prenotazioni/restapi/services/month_slots/get.py +++ b/src/redturtle/prenotazioni/restapi/services/month_slots/get.py @@ -17,7 +17,9 @@ def reply(self): """ prenotazioni_week_view = api.content.get_view( - "prenotazioni_week_view", context=self.context, request=self.request + "prenotazioni_week_view", + context=self.context, + request=self.request, ) now = self.request.form.get("date", "") if now: @@ -38,20 +40,23 @@ def reply(self): start_month = now.month start_day = now.day - response = {"@id": f"{self.context.absolute_url()}/@month_slots", "items": []} + response = { + "@id": f"{self.context.absolute_url()}/@month_slots", + "items": [], + } for week in calendar.monthcalendar(start_year, start_month): for day in week: if day < start_day: continue booking_date = date(start_year, start_month, day) - slots = prenotazioni_week_view.prenotazioni.get_anonymous_slots( - booking_date=booking_date + slots = ( + prenotazioni_week_view.prenotazioni.get_anonymous_slots( + booking_date=booking_date + ) ) for slot in slots.get("anonymous_gate", []): - info = ( - prenotazioni_week_view.prenotazioni.get_anonymous_booking_url( - booking_date, slot, slot_min_size=slot_min_size - ) + info = prenotazioni_week_view.prenotazioni.get_anonymous_booking_url( + booking_date, slot, slot_min_size=slot_min_size ) if not info.get("url", ""): continue diff --git a/src/redturtle/prenotazioni/restapi/services/week_slots/get.py b/src/redturtle/prenotazioni/restapi/services/week_slots/get.py index 26a01526..4d708276 100644 --- a/src/redturtle/prenotazioni/restapi/services/week_slots/get.py +++ b/src/redturtle/prenotazioni/restapi/services/week_slots/get.py @@ -42,16 +42,24 @@ def reply(self): """ prenotazioni_week_view = api.content.get_view( - "prenotazioni_week_view", context=self.context, request=self.request + "prenotazioni_week_view", + context=self.context, + request=self.request, ) prenotazioni_context_state_view = api.content.get_view( - "prenotazioni_context_state", context=self.context, request=self.request + "prenotazioni_context_state", + context=self.context, + request=self.request, ) response = {} for week_day in prenotazioni_week_view.actual_week_days: - free_slots = prenotazioni_context_state_view.get_free_slots(week_day) - busy_slots = prenotazioni_context_state_view.get_busy_slots(week_day) + free_slots = prenotazioni_context_state_view.get_free_slots( + week_day + ) + busy_slots = prenotazioni_context_state_view.get_busy_slots( + week_day + ) week_day_key = week_day.isoformat() # build the response diff --git a/src/redturtle/prenotazioni/scripts/app_io.py b/src/redturtle/prenotazioni/scripts/app_io.py index a607fe50..7285a2d3 100644 --- a/src/redturtle/prenotazioni/scripts/app_io.py +++ b/src/redturtle/prenotazioni/scripts/app_io.py @@ -28,7 +28,11 @@ def days_before(obj, days=1, as_date=True): ): return True else: - if timedelta() < obj.booking_date - datetime.now() <= timedelta(days=days): + if ( + timedelta() + < obj.booking_date - datetime.now() + <= timedelta(days=days) + ): return True return False @@ -65,7 +69,8 @@ def notifica_app_io(obj, api_io, msg_type, commit=False, verbose=False): how_to_get_here=how_to_get_here, # sportello=u" sportello %s" % obj.gate if obj.gate else "", sportello=" - %s" % obj.gate if obj.gate else "", - booking_code="\n\nIl codice della prenotazione è %s" % obj.getBookingCode() + booking_code="\n\nIl codice della prenotazione è %s" + % obj.getBookingCode() if obj.getBookingCode() else "", ) @@ -117,7 +122,9 @@ def get_message(self, key): d = self.context.get("%s.%s" % (NOTIFICATIONS_LOGS, key)) return ObjectView(d) if d else None - def create_message(self, key, fiscal_code, subject, body, payment_data, due_date): + def create_message( + self, key, fiscal_code, subject, body, payment_data, due_date + ): msg = { "key": key, "fiscal_code": fiscal_code, diff --git a/src/redturtle/prenotazioni/scripts/io_tools/api.py b/src/redturtle/prenotazioni/scripts/io_tools/api.py index 3f1f02a6..d3866039 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/api.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/api.py @@ -91,7 +91,13 @@ def update_message_status( return False def send_message( - self, fiscal_code, subject, body, payment_data=None, due_date=None, key=None + self, + fiscal_code, + subject, + body, + payment_data=None, + due_date=None, + key=None, ): """[summary] @@ -123,7 +129,9 @@ def send_message( return None if key is None: if payment_data: - key = "#".join([fiscal_code, subject, payment_data["notice_number"]]) + key = "#".join( + [fiscal_code, subject, payment_data["notice_number"]] + ) else: key = payment_data or "#".join([fiscal_code, subject]) # 1. verifica che lo stesso messaggio non sia già stato mandato @@ -141,12 +149,15 @@ def send_message( # 2. verifica se il destinatario è abilitato o meno a ricevere il messaggio try: profile = ( - self.api.profiles.getProfile(fiscal_code=fiscal_code).response().result + self.api.profiles.getProfile(fiscal_code=fiscal_code) + .response() + .result ) except HTTPForbidden: self.storage.update_message(key, status=PROFILE_NOT_FOUND) logger.error( - "profile for user %s not found (access forbidden to api)", fiscal_code + "profile for user %s not found (access forbidden to api)", + fiscal_code, ) return None except Exception: @@ -189,7 +200,10 @@ def send_message( msgid = data["id"] self.storage.update_message(key, msgid=msgid, status=QUEUED) logger.info( - "message %s queued for %s (msgid %s)", subject, fiscal_code, msgid + "message %s queued for %s (msgid %s)", + subject, + fiscal_code, + msgid, ) return msgid else: diff --git a/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py b/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py index de973978..b372b1ed 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py @@ -70,14 +70,18 @@ def update_message(key, **kwargs): @staticmethod @orm.db_session - def create_message(key, fiscal_code, subject, body, payment_data, due_date): + def create_message( + key, fiscal_code, subject, body, payment_data, due_date + ): msg = Message_io( key=key, fiscal_code=fiscal_code, subject=subject, body=body, amount=payment_data["amount"] if payment_data else None, - notice_number=payment_data["notice_number"] if payment_data else None, + notice_number=payment_data["notice_number"] + if payment_data + else None, invalid_after_due_date=payment_data["invalid_after_due_date"] if payment_data else None, diff --git a/src/redturtle/prenotazioni/scripts/io_tools/storage.py b/src/redturtle/prenotazioni/scripts/io_tools/storage.py index 97121fed..c814948e 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/storage.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/storage.py @@ -6,7 +6,9 @@ class Storage(object): def get_message(self, key): raise NotImplementedError - def create_message(self, key, fiscal_code, subject, body, payment_data, due_date): + def create_message( + self, key, fiscal_code, subject, body, payment_data, due_date + ): raise NotImplementedError def update_message(self, key, **kwargs): @@ -20,7 +22,9 @@ def __init__(self, logger=logger): def get_message(self, key): self.logger.info("get_message %s", key) - def create_message(self, key, fiscal_code, subject, body, payment_data, due_date): + def create_message( + self, key, fiscal_code, subject, body, payment_data, due_date + ): self.logger.info( "create_message %s %s %s %s %s %s", key, diff --git a/src/redturtle/prenotazioni/tests/test_booking_info.py b/src/redturtle/prenotazioni/tests/test_booking_info.py index ba92d96a..5e8d5f1a 100644 --- a/src/redturtle/prenotazioni/tests/test_booking_info.py +++ b/src/redturtle/prenotazioni/tests/test_booking_info.py @@ -8,7 +8,9 @@ from plone.app.testing import TEST_USER_ID from plone.restapi.testing import RelativeSession from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) import calendar import transaction @@ -94,9 +96,13 @@ def setUp(self): ) year = api.content.create( - container=self.folder_prenotazioni, type="PrenotazioniYear", title="Year" + container=self.folder_prenotazioni, + type="PrenotazioniYear", + title="Year", + ) + week = api.content.create( + container=year, type="PrenotazioniWeek", title="Week" ) - week = api.content.create(container=year, type="PrenotazioniWeek", title="Week") self.day_folder = api.content.create( container=week, type="PrenotazioniDay", title="Day" ) @@ -131,7 +137,9 @@ def test_create_booking_and_check_details( booker = IBooker(self.folder_prenotazioni) booking = booker.create( { - "booking_date": datetime(current_year, current_month, monday, 7, 0), + "booking_date": datetime( + current_year, current_month, monday, 7, 0 + ), "booking_type": "Type A", "title": "foo", } @@ -175,7 +183,9 @@ def test_get_booking_without_UID( booker = IBooker(self.folder_prenotazioni) booker.create( { - "booking_date": datetime(current_year, current_month, monday, 7, 0), + "booking_date": datetime( + current_year, current_month, monday, 7, 0 + ), "booking_type": "Type A", "title": "foo", } diff --git a/src/redturtle/prenotazioni/tests/test_booking_schema.py b/src/redturtle/prenotazioni/tests/test_booking_schema.py index 6254036b..7c0f5c7c 100644 --- a/src/redturtle/prenotazioni/tests/test_booking_schema.py +++ b/src/redturtle/prenotazioni/tests/test_booking_schema.py @@ -8,7 +8,9 @@ setRoles, ) from plone.restapi.testing import RelativeSession -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) from plone.restapi.serializer.converters import json_compatible import unittest @@ -95,9 +97,13 @@ def setUp(self): ) year = api.content.create( - container=self.folder_prenotazioni, type="PrenotazioniYear", title="Year" + container=self.folder_prenotazioni, + type="PrenotazioniYear", + title="Year", + ) + week = api.content.create( + container=year, type="PrenotazioniWeek", title="Week" ) - week = api.content.create(container=year, type="PrenotazioniWeek", title="Week") self.day_folder = api.content.create( container=week, type="PrenotazioniDay", title="Day" ) @@ -110,7 +116,9 @@ def test_booking_schema_called_without_params_return_error( self, ): response = self.api_session.get( - "{}/@prenotazione-schema".format(self.folder_prenotazioni.absolute_url()) + "{}/@prenotazione-schema".format( + self.folder_prenotazioni.absolute_url() + ) ) expected = "Wrong date format" diff --git a/src/redturtle/prenotazioni/tests/test_delete_booking.py b/src/redturtle/prenotazioni/tests/test_delete_booking.py index 1c2ef200..6ad1b591 100644 --- a/src/redturtle/prenotazioni/tests/test_delete_booking.py +++ b/src/redturtle/prenotazioni/tests/test_delete_booking.py @@ -9,7 +9,9 @@ from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING, +) from zExceptions import NotFound import transaction @@ -63,7 +65,9 @@ def setUp(self): self.booker = IBooker(self.folder_prenotazioni) self.today = datetime.now().replace(hour=8) - api.content.transition(obj=self.folder_prenotazioni, transition="publish") + api.content.transition( + obj=self.folder_prenotazioni, transition="publish" + ) transaction.commit() def tearDown(self): @@ -121,7 +125,8 @@ def test_anon_can_delete_anon_booking(self): ) uid = booking.UID() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() @@ -129,7 +134,8 @@ def test_anon_can_delete_anon_booking(self): self.assertIsNone(res) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 0 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 0, ) def test_user_can_delete_his_booking(self): @@ -143,7 +149,8 @@ def test_user_can_delete_his_booking(self): ) uid = booking.UID() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() @@ -151,7 +158,8 @@ def test_user_can_delete_his_booking(self): self.assertIsNone(res) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 0 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 0, ) def test_user_cant_delete_other_user_booking(self): @@ -166,14 +174,16 @@ def test_user_cant_delete_other_user_booking(self): login(self.portal, "user2") uid = booking.UID() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() self.assertRaises(Unauthorized, self.view.do_delete) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_user_cant_delete_anon_booking(self): @@ -190,14 +200,16 @@ def test_user_cant_delete_anon_booking(self): login(self.portal, "user") self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() self.assertRaises(Unauthorized, self.view.do_delete) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_cant_delete_past_booking(self): @@ -211,7 +223,8 @@ def test_cant_delete_past_booking(self): uid = booking.UID() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() @@ -221,7 +234,8 @@ def test_cant_delete_past_booking(self): "You can't delete your reservation; it's too late.", res["error"] ) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_cant_delete_today_booking(self): @@ -235,7 +249,8 @@ def test_cant_delete_today_booking(self): uid = booking.UID() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) self.request.form["uid"] = booking.UID() @@ -245,7 +260,8 @@ def test_cant_delete_today_booking(self): "You can't delete your reservation; it's too late.", res["error"] ) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_unable_to_delete_other_types(self): diff --git a/src/redturtle/prenotazioni/tests/test_delete_booking_api.py b/src/redturtle/prenotazioni/tests/test_delete_booking_api.py index 9b24d572..6ef44fbe 100644 --- a/src/redturtle/prenotazioni/tests/test_delete_booking_api.py +++ b/src/redturtle/prenotazioni/tests/test_delete_booking_api.py @@ -11,7 +11,9 @@ from plone.app.testing import TEST_USER_ID from plone.restapi.testing import RelativeSession from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) import transaction import unittest @@ -79,7 +81,9 @@ def setUp(self): self.booker = IBooker(self.folder_prenotazioni) self.today = datetime.now().replace(hour=8) - api.content.transition(obj=self.folder_prenotazioni, transition="publish") + api.content.transition( + obj=self.folder_prenotazioni, transition="publish" + ) transaction.commit() def tearDown(self): @@ -95,7 +99,9 @@ def get_response(self, session, uid=None): if not uid: response = session.delete("{}/@booking".format(self.portal_url)) else: - response = session.delete("{}/@booking/{}".format(self.portal_url, uid)) + response = session.delete( + "{}/@booking/{}".format(self.portal_url, uid) + ) transaction.commit() return response @@ -157,14 +163,16 @@ def test_anon_can_delete_anon_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_anon, uid=uid) self.assertEqual(response.status_code, 204) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 0 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 0, ) def test_user_can_delete_his_booking(self): @@ -180,14 +188,16 @@ def test_user_can_delete_his_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_user, uid=uid) self.assertEqual(response.status_code, 204) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 0 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 0, ) def test_user_cant_delete_other_user_booking(self): @@ -203,14 +213,16 @@ def test_user_cant_delete_other_user_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_user2, uid=uid) self.assertEqual(response.status_code, 401) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_user_can_delete_anon_booking(self): @@ -226,14 +238,16 @@ def test_user_can_delete_anon_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_user, uid=uid) self.assertEqual(response.status_code, 401) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_cant_delete_past_booking(self): @@ -248,7 +262,8 @@ def test_cant_delete_past_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_admin, uid=uid) @@ -258,7 +273,8 @@ def test_cant_delete_past_booking(self): response.json()["message"], ) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) def test_cant_delete_today_booking(self): @@ -273,7 +289,8 @@ def test_cant_delete_today_booking(self): transaction.commit() self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) response = self.get_response(session=self.api_session_admin, uid=uid) @@ -283,5 +300,6 @@ def test_cant_delete_today_booking(self): response.json()["message"], ) self.assertEqual( - len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), 1 + len(self.portal.portal_catalog.unrestrictedSearchResults(UID=uid)), + 1, ) diff --git a/src/redturtle/prenotazioni/tests/test_month_slots.py b/src/redturtle/prenotazioni/tests/test_month_slots.py index 75082e97..9f552000 100644 --- a/src/redturtle/prenotazioni/tests/test_month_slots.py +++ b/src/redturtle/prenotazioni/tests/test_month_slots.py @@ -10,7 +10,9 @@ from plone.restapi.serializer.converters import json_compatible from plone.restapi.testing import RelativeSession from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) import calendar import transaction @@ -95,9 +97,13 @@ def setUp(self): ) year = api.content.create( - container=self.folder_prenotazioni, type="PrenotazioniYear", title="Year" + container=self.folder_prenotazioni, + type="PrenotazioniYear", + title="Year", + ) + week = api.content.create( + container=year, type="PrenotazioniWeek", title="Week" ) - week = api.content.create(container=year, type="PrenotazioniWeek", title="Week") self.day_folder = api.content.create( container=week, type="PrenotazioniDay", title="Day" ) @@ -125,7 +131,9 @@ def test_month_slots_called_without_params_return_all_available_slots_of_current for hour in [7, 8, 9]: expected.append( json_compatible( - datetime(current_year, current_month, week[0], hour, 0) + datetime( + current_year, current_month, week[0], hour, 0 + ) ) ) self.assertEqual(expected, response.json()["items"]) @@ -157,7 +165,9 @@ def test_month_slots_called_without_params_return_available_slots_of_current_mon booker = IBooker(self.folder_prenotazioni) booker.create( { - "booking_date": datetime(current_year, current_month, monday, 7, 0), + "booking_date": datetime( + current_year, current_month, monday, 7, 0 + ), "booking_type": "Type A", "title": "foo", } @@ -179,17 +189,23 @@ def test_month_slots_called_without_params_return_available_slots_of_current_mon # first free slot is at 7:30 of the next month self.assertEqual( response.json()["items"][0], - json_compatible(datetime(current_year, next_month, monday, 7, 30)), + json_compatible( + datetime(current_year, next_month, monday, 7, 30) + ), ) else: response = self.api_session.get( - "{}/@month-slots".format(self.folder_prenotazioni.absolute_url()) + "{}/@month-slots".format( + self.folder_prenotazioni.absolute_url() + ) ) # first free slot is at 7:30 self.assertEqual( response.json()["items"][0], - json_compatible(datetime(current_year, current_month, monday, 7, 30)), + json_compatible( + datetime(current_year, current_month, monday, 7, 30) + ), ) def test_show_all_available_slots_for_next_month_from_the_beginning( @@ -220,7 +236,9 @@ def test_show_all_available_slots_for_next_month_from_the_beginning( ) self.assertEqual(expected, response.json()["items"]) - @unittest.skipIf(date.today().day > 20, "issue testing in the last days of a month") + @unittest.skipIf( + date.today().day > 20, "issue testing in the last days of a month" + ) def test_month_slots_notBeforeDays_honored( self, ): @@ -254,7 +272,9 @@ def test_month_slots_notBeforeDays_honored( ) transaction.commit() - response = self.api_session.get("{}/@month-slots".format(folder.absolute_url())) + response = self.api_session.get( + "{}/@month-slots".format(folder.absolute_url()) + ) tomorrow = json_compatible( datetime.now().replace(hour=7, minute=0, second=0, microsecond=0) @@ -265,10 +285,14 @@ def test_month_slots_notBeforeDays_honored( folder.notBeforeDays = 0 transaction.commit() - response = self.api_session.get("{}/@month-slots".format(folder.absolute_url())) + response = self.api_session.get( + "{}/@month-slots".format(folder.absolute_url()) + ) self.assertIn(tomorrow, response.json()["items"]) - @unittest.skipIf(date.today().day > 20, "issue testing in the last days of a month") + @unittest.skipIf( + date.today().day > 20, "issue testing in the last days of a month" + ) def test_month_slots_filtered_by_booking_type(self): # Type A 30 minutes response = self.api_session.get( diff --git a/src/redturtle/prenotazioni/tests/test_prenotazione.py b/src/redturtle/prenotazioni/tests/test_prenotazione.py index c95ab95c..0f493f3d 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazione.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazione.py @@ -12,8 +12,12 @@ from plone.autoform.interfaces import MODES_KEY from plone.restapi.testing import RelativeSession from redturtle.prenotazioni.content.prenotazione import IPrenotazione -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING, +) import transaction from zope.interface import Interface @@ -53,10 +57,13 @@ def tearDown(self): def test_prenotazione_restapi_endpoint(self): result = self.api_session.get(self.portal_url + "/@types/Prenotazione") content_type_properties = result.json()["properties"] - self.assertEqual(content_type_properties["booking_date"]["mode"], "display") + self.assertEqual( + content_type_properties["booking_date"]["mode"], "display" + ) self.assertEqual(content_type_properties["gate"]["mode"], "display") self.assertEqual( - content_type_properties["booking_expiration_date"]["mode"], "display" + content_type_properties["booking_expiration_date"]["mode"], + "display", ) @@ -84,7 +91,9 @@ def setUp(self): row["morning_start"] = "0700" row["morning_end"] = "1000" self.folder_prenotazioni.week_table = week_table - api.content.transition(obj=self.folder_prenotazioni, transition="publish") + api.content.transition( + obj=self.folder_prenotazioni, transition="publish" + ) transaction.commit() self.api_session = RelativeSession(self.portal_url) @@ -111,7 +120,9 @@ def test_add_booking_anonymous(self): ) self.assertEqual(res.status_code, 200) self.assertEqual(res.json()["booking_date"], booking_date) - self.assertEqual(res.json()["booking_expiration_date"], booking_expiration_date) + self.assertEqual( + res.json()["booking_expiration_date"], booking_expiration_date + ) self.assertEqual(res.json()["booking_type"], "Type A") self.assertEqual(res.json()["gate"], "Gate A") self.assertEqual(res.json()["title"], "Mario Rossi") diff --git a/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py b/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py index 36c0302a..a2800a19 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py @@ -28,9 +28,9 @@ def setUp(self): self.portal_url = self.portal.absolute_url() self.testing_fiscal_code = "TESTINGFISCALCODE" self.testing_booking_date = parser.parse("2023-04-28 16:00:00") - self.booking_expiration_date = parser.parse("2023-04-28 16:00:00") + timedelta( - days=100 - ) + self.booking_expiration_date = parser.parse( + "2023-04-28 16:00:00" + ) + timedelta(days=100) setRoles(self.portal, TEST_USER_ID, ["Manager"]) self.folder_prenotazioni = api.content.create( @@ -101,7 +101,9 @@ def setUp(self): type="PrenotazioniYear", title="Year", ) - week = api.content.create(container=year, type="PrenotazioniWeek", title="Week") + week = api.content.create( + container=year, type="PrenotazioniWeek", title="Week" + ) self.day_folder = api.content.create( container=week, type="PrenotazioniDay", title="Day" ) @@ -121,7 +123,9 @@ def test_serializer_fields(self): ISerializeToPrenotazioneSearchableItem, )() wf_tool = api.portal.get_tool("portal_workflow") - status = wf_tool.getStatusOf("prenotazioni_workflow", self.prenotazione_fscode) + status = wf_tool.getStatusOf( + "prenotazioni_workflow", self.prenotazione_fscode + ) self.assertEqual( result, diff --git a/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py b/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py index c97e5e7c..abe4f882 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py @@ -28,9 +28,9 @@ def setUp(self): self.portal_url = self.portal.absolute_url() self.testing_fiscal_code = "TESTINGFISCALCODE" self.testing_booking_date = parser.parse("2023-04-28 16:00:00") - self.booking_expiration_date = parser.parse("2023-04-28 16:00:00") + timedelta( - days=100 - ) + self.booking_expiration_date = parser.parse( + "2023-04-28 16:00:00" + ) + timedelta(days=100) setRoles(self.portal, TEST_USER_ID, ["Manager"]) @@ -106,7 +106,9 @@ def setUp(self): type="PrenotazioniYear", title="Year", ) - week = api.content.create(container=year, type="PrenotazioniWeek", title="Week") + week = api.content.create( + container=year, type="PrenotazioniWeek", title="Week" + ) self.day_folder = api.content.create( container=week, type="PrenotazioniDay", title="Day" ) @@ -163,7 +165,9 @@ def tearDown(self): def test_view_permission(self): self.assertEqual( - self.api_session.get(f"{self.portal.absolute_url()}/@bookings").status_code, + self.api_session.get( + f"{self.portal.absolute_url()}/@bookings" + ).status_code, 200, ) @@ -172,7 +176,9 @@ def test_view_permission(self): self.api_session.auth = (TEST_USER_ID, TEST_USER_PASSWORD) self.assertEqual( - self.api_session.get(f"{self.portal.absolute_url()}/@bookings").status_code, + self.api_session.get( + f"{self.portal.absolute_url()}/@bookings" + ).status_code, 401, ) diff --git a/src/redturtle/prenotazioni/tests/test_send_ical.py b/src/redturtle/prenotazioni/tests/test_send_ical.py index d36837c3..b3c7d6fe 100644 --- a/src/redturtle/prenotazioni/tests/test_send_ical.py +++ b/src/redturtle/prenotazioni/tests/test_send_ical.py @@ -1,5 +1,7 @@ # -*- coding: UTF-8 -*- -from collective.contentrules.mailfromfield.actions.mail import MailFromFieldAction +from collective.contentrules.mailfromfield.actions.mail import ( + MailFromFieldAction, +) from datetime import date, datetime from datetime import timedelta from plone import api @@ -9,7 +11,9 @@ from Products.CMFCore.WorkflowCore import ActionSucceededEvent from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING, +) from zope.component import getMultiAdapter from zope.interface import implementer from zope.interface.interfaces import IObjectEvent @@ -158,7 +162,9 @@ def test_ical_sent_on_confirm(self): ) else: self.assertIn( - "DTSTART:{}".format(booking.booking_date.strftime("%Y%m%dT%H%M%S")), + "DTSTART:{}".format( + booking.booking_date.strftime("%Y%m%dT%H%M%S") + ), data, ) self.assertIn( @@ -230,7 +236,9 @@ def test_ical_sent_on_move(self): # move date one day after booking.booking_date = booking.booking_date + timedelta(1) - booking.booking_expiration_date = booking.booking_expiration_date + timedelta(1) + booking.booking_expiration_date = ( + booking.booking_expiration_date + timedelta(1) + ) e = MailFromFieldAction() e.source = "foo@bar.be" @@ -275,7 +283,9 @@ def test_ical_sent_on_move(self): ) else: self.assertIn( - "DTSTART:{}".format(booking.booking_date.strftime("%Y%m%dT%H%M%S")), + "DTSTART:{}".format( + booking.booking_date.strftime("%Y%m%dT%H%M%S") + ), data, ) self.assertIn( diff --git a/src/redturtle/prenotazioni/tests/test_setup.py b/src/redturtle/prenotazioni/tests/test_setup.py index 45e43231..0ffda600 100644 --- a/src/redturtle/prenotazioni/tests/test_setup.py +++ b/src/redturtle/prenotazioni/tests/test_setup.py @@ -3,7 +3,9 @@ from plone import api from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING, +) import unittest @@ -35,16 +37,22 @@ def test_product_installed(self): self.installer.is_product_installed("redturtle.prenotazioni") ) else: - self.assertTrue(self.installer.isProductInstalled("redturtle.prenotazioni")) + self.assertTrue( + self.installer.isProductInstalled("redturtle.prenotazioni") + ) def test_browserlayer(self): """Test that IRedturtlePrenotazioniLayer is registered.""" from plone.browserlayer import utils - from redturtle.prenotazioni.interfaces import IRedturtlePrenotazioniLayer + from redturtle.prenotazioni.interfaces import ( + IRedturtlePrenotazioniLayer, + ) self.assertIn(IRedturtlePrenotazioniLayer, utils.registered_layers()) - def test_dexteritytextindexer_behavior_enabled_only_in_plone_less_than_6(self): + def test_dexteritytextindexer_behavior_enabled_only_in_plone_less_than_6( + self, + ): plone_version = api.env.plone_version() portal_types = api.portal.get_tool(name="portal_types") behaviors = portal_types["PrenotazioniFolder"].behaviors @@ -87,6 +95,10 @@ def test_product_uninstalled(self): def test_browserlayer_removed(self): """Test that IRedturtlePrenotazioniLayer is removed.""" from plone.browserlayer import utils - from redturtle.prenotazioni.interfaces import IRedturtlePrenotazioniLayer + from redturtle.prenotazioni.interfaces import ( + IRedturtlePrenotazioniLayer, + ) - self.assertNotIn(IRedturtlePrenotazioniLayer, utils.registered_layers()) + self.assertNotIn( + IRedturtlePrenotazioniLayer, utils.registered_layers() + ) diff --git a/src/redturtle/prenotazioni/tests/test_week_table_overrides.py b/src/redturtle/prenotazioni/tests/test_week_table_overrides.py index 830037c9..a0a9bb8f 100644 --- a/src/redturtle/prenotazioni/tests/test_week_table_overrides.py +++ b/src/redturtle/prenotazioni/tests/test_week_table_overrides.py @@ -8,8 +8,12 @@ setRoles, ) from plone.restapi.testing import RelativeSession -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, +) +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING, +) from plone import api import unittest @@ -79,7 +83,9 @@ def test_if_day_is_in_overrides_use_override_week_table(self): res = self.view.get_week_table(date(now.year, 1, 10)) self.assertEqual( res, - json.loads(self.folder_prenotazioni.week_table_overrides)[0]["week_table"], + json.loads(self.folder_prenotazioni.week_table_overrides)[0][ + "week_table" + ], ) def test_override_between_year(self): @@ -105,7 +111,9 @@ def test_override_between_year(self): now = date.today() self.assertEqual( self.view.get_week_table(date(now.year, 12, 25)), - json.loads(self.folder_prenotazioni.week_table_overrides)[0]["week_table"], + json.loads(self.folder_prenotazioni.week_table_overrides)[0][ + "week_table" + ], ) self.assertEqual( @@ -327,7 +335,8 @@ def test_if_set_start_you_should_set_an_end(self): self.assertEqual(response.status_code, 400) self.assertIn( - "You should set an end time for morning", response.json()["message"] + "You should set an end time for morning", + response.json()["message"], ) def test_if_set_end_you_should_set_a_start(self): @@ -366,5 +375,6 @@ def test_if_set_end_you_should_set_a_start(self): self.assertEqual(response.status_code, 400) self.assertIn( - "You should set a start time for morning", response.json()["message"] + "You should set a start time for morning", + response.json()["message"], ) diff --git a/src/redturtle/prenotazioni/upgrades.py b/src/redturtle/prenotazioni/upgrades.py index a555b4c5..1746f57e 100644 --- a/src/redturtle/prenotazioni/upgrades.py +++ b/src/redturtle/prenotazioni/upgrades.py @@ -3,7 +3,9 @@ from plone.app.contentrules.actions.workflow import WorkflowAction from plone.app.contentrules.conditions.portaltype import PortalTypeCondition from plone.app.contentrules.conditions.wfstate import WorkflowStateCondition -from plone.app.contentrules.conditions.wftransition import WorkflowTransitionCondition +from plone.app.contentrules.conditions.wftransition import ( + WorkflowTransitionCondition, +) from plone.app.upgrade.utils import loadMigrationProfile from plone.app.workflow.remap import remap_workflow from plone.contentrules.engine.interfaces import IRuleStorage @@ -144,13 +146,19 @@ def to_1400(context): ) for portal_type_condition in portal_type_conditions: - if "Prenotazione" in getattr(portal_type_condition, "check_types", []): - for workflow_transition_condition in workflow_transition_conditions: + if "Prenotazione" in getattr( + portal_type_condition, "check_types", [] + ): + for ( + workflow_transition_condition + ) in workflow_transition_conditions: if isinstance( workflow_transition_condition, WorkflowTransitionCondition, ): - wf_states = list(workflow_transition_condition.wf_transitions) + wf_states = list( + workflow_transition_condition.wf_transitions + ) if "publish" in wf_states: wf_states.remove("publish") @@ -161,7 +169,9 @@ def to_1400(context): ) for workflow_state_condition in workflow_state_conditions: - if isinstance(workflow_state_condition, WorkflowStateCondition): + if isinstance( + workflow_state_condition, WorkflowStateCondition + ): wf_states = list(workflow_state_condition.wf_states) if "publish" in wf_states: @@ -197,13 +207,17 @@ def to_1401(context): def to_1402(context): # load new content rules - context.runImportStepFromProfile(CONTENT_RULES_EVOLUTION_PROFILE, "contentrules") + context.runImportStepFromProfile( + CONTENT_RULES_EVOLUTION_PROFILE, "contentrules" + ) def to_1403(context): update_catalog(context) - for brain in api.portal.get_tool("portal_catalog")(portal_type="Prenotazione"): + for brain in api.portal.get_tool("portal_catalog")( + portal_type="Prenotazione" + ): brain.getObject().reindexObject(idxs=["fiscalcode"]) diff --git a/src/redturtle/prenotazioni/viewlets/app_io.py b/src/redturtle/prenotazioni/viewlets/app_io.py index e5240970..80b0426f 100644 --- a/src/redturtle/prenotazioni/viewlets/app_io.py +++ b/src/redturtle/prenotazioni/viewlets/app_io.py @@ -10,4 +10,8 @@ def available(self): def logs(self): annotations = IAnnotations(self.context) - return [v for (k, v) in annotations.items() if k.startswith(NOTIFICATIONS_LOGS)] + return [ + v + for (k, v) in annotations.items() + if k.startswith(NOTIFICATIONS_LOGS) + ] diff --git a/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py b/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py index 9ffde5a9..50c8cdcb 100644 --- a/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py +++ b/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py @@ -20,7 +20,8 @@ def __call__(self, context): field, field, translate( - _("label_booking_{}".format(field)), context=context.REQUEST + _("label_booking_{}".format(field)), + context=context.REQUEST, ), ) for field in REQUIRABLE_AND_VISIBLE_FIELDS diff --git a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py index fdc7fe44..b8df0770 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py @@ -30,7 +30,9 @@ def __call__(self, context): terms = [] for item in items: terms.append( - SimpleTerm(value=item.token, token=str(item.token), title=item.value) + SimpleTerm( + value=item.token, token=str(item.token), title=item.value + ) ) return SimpleVocabulary(terms) diff --git a/src/redturtle/prenotazioni/vocabularies/voc_months.py b/src/redturtle/prenotazioni/vocabularies/voc_months.py index fec71c97..4a17b7c8 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_months.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_months.py @@ -15,62 +15,86 @@ def __call__(self, context): SimpleTerm( value=1, token=1, - title=api.portal.translate(msgid="month_jan", domain="plonelocales"), + title=api.portal.translate( + msgid="month_jan", domain="plonelocales" + ), ), SimpleTerm( value=2, token=2, - title=api.portal.translate(msgid="month_feb", domain="plonelocales"), + title=api.portal.translate( + msgid="month_feb", domain="plonelocales" + ), ), SimpleTerm( value=3, token=3, - title=api.portal.translate(msgid="month_mar", domain="plonelocales"), + title=api.portal.translate( + msgid="month_mar", domain="plonelocales" + ), ), SimpleTerm( value=4, token=4, - title=api.portal.translate(msgid="month_apr", domain="plonelocales"), + title=api.portal.translate( + msgid="month_apr", domain="plonelocales" + ), ), SimpleTerm( value=5, token=5, - title=api.portal.translate(msgid="month_may", domain="plonelocales"), + title=api.portal.translate( + msgid="month_may", domain="plonelocales" + ), ), SimpleTerm( value=6, token=6, - title=api.portal.translate(msgid="month_jun", domain="plonelocales"), + title=api.portal.translate( + msgid="month_jun", domain="plonelocales" + ), ), SimpleTerm( value=7, token=7, - title=api.portal.translate(msgid="month_jul", domain="plonelocales"), + title=api.portal.translate( + msgid="month_jul", domain="plonelocales" + ), ), SimpleTerm( value=8, token=8, - title=api.portal.translate(msgid="month_aug", domain="plonelocales"), + title=api.portal.translate( + msgid="month_aug", domain="plonelocales" + ), ), SimpleTerm( value=9, token=9, - title=api.portal.translate(msgid="month_sep", domain="plonelocales"), + title=api.portal.translate( + msgid="month_sep", domain="plonelocales" + ), ), SimpleTerm( value=10, token=10, - title=api.portal.translate(msgid="month_oct", domain="plonelocales"), + title=api.portal.translate( + msgid="month_oct", domain="plonelocales" + ), ), SimpleTerm( value=11, token=11, - title=api.portal.translate(msgid="month_nov", domain="plonelocales"), + title=api.portal.translate( + msgid="month_nov", domain="plonelocales" + ), ), SimpleTerm( value=12, token=12, - title=api.portal.translate(msgid="month_dec", domain="plonelocales"), + title=api.portal.translate( + msgid="month_dec", domain="plonelocales" + ), ), ] return SimpleVocabulary(terms) diff --git a/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py b/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py index e379b6ad..6d8faa72 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py @@ -49,7 +49,9 @@ def __call__(self, context): terms = [] for item in items: terms.append( - SimpleTerm(value=item.token, token=str(item.token), title=item.value) + SimpleTerm( + value=item.token, token=str(item.token), title=item.value + ) ) return SimpleVocabulary(terms)