diff --git a/.github/workflows/isort.yaml b/.github/workflows/isort.yaml new file mode 100644 index 00000000..0b8086c0 --- /dev/null +++ b/.github/workflows/isort.yaml @@ -0,0 +1,14 @@ +name: Isort +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - uses: isort/isort-action@master + with: + configuration: --profile black diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..b9fb3f3e --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/src/redturtle/prenotazioni/__init__.py b/src/redturtle/prenotazioni/__init__.py index fc63939f..486d6616 100644 --- a/src/redturtle/prenotazioni/__init__.py +++ b/src/redturtle/prenotazioni/__init__.py @@ -1,23 +1,20 @@ # -*- coding: utf-8 -*- +from datetime import datetime, timedelta +from logging import FileHandler, Formatter, getLogger + +import dateutil +import pytz from AccessControl import Unauthorized from App.config import getConfiguration -from datetime import datetime -from datetime import timedelta from DateTime import DateTime from dateutil.tz.tz import tzutc -from logging import FileHandler -from logging import Formatter -from logging import getLogger from plone import api from plone.api.exc import UserNotFoundError from plone.app.event.base import default_timezone -from redturtle.prenotazioni.utils import is_migration from six.moves import map from zope.i18nmessageid import MessageFactory -import dateutil -import pytz - +from redturtle.prenotazioni.utils import is_migration logger = getLogger("redturtle.prenotazioni") _ = MessageFactory("redturtle.prenotazioni") diff --git a/src/redturtle/prenotazioni/actions/mail.py b/src/redturtle/prenotazioni/actions/mail.py index 7cfa7d56..3814737e 100644 --- a/src/redturtle/prenotazioni/actions/mail.py +++ b/src/redturtle/prenotazioni/actions/mail.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from Acquisition import aq_base -from Acquisition import aq_inner +import six +from Acquisition import aq_base, aq_inner from collective.contentrules.mailfromfield import logger from collective.contentrules.mailfromfield.actions.mail import IMailFromFieldAction from collective.contentrules.mailfromfield.actions.mail import ( @@ -10,13 +10,11 @@ from plone.dexterity.interfaces import IDexterityContainer from plone.event.interfaces import IICalendar from Products.CMFPlone.interfaces.siteroot import IPloneSiteRoot -from redturtle.prenotazioni.prenotazione_event import IMovedPrenotazione from six.moves import filter from zope.component import adapter -from zope.interface import implementer -from zope.interface import Interface +from zope.interface import Interface, implementer -import six +from redturtle.prenotazioni.prenotazione_event import IMovedPrenotazione class MailActionExecutor(BaseExecutor): diff --git a/src/redturtle/prenotazioni/adapters/booker.py b/src/redturtle/prenotazioni/adapters/booker.py index d6aeab3f..0e60ea00 100644 --- a/src/redturtle/prenotazioni/adapters/booker.py +++ b/src/redturtle/prenotazioni/adapters/booker.py @@ -1,24 +1,22 @@ # -*- coding: utf-8 -*- +import math from datetime import timedelta +from random import choice + from plone import api from plone.memoize.instance import memoize -from random import choice -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni import logger -from redturtle.prenotazioni.adapters.slot import BaseSlot -from redturtle.prenotazioni.config import VERIFIED_BOOKING -from redturtle.prenotazioni.content.prenotazione import VACATION_TYPE -from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione -from redturtle.prenotazioni.utilities.dateutils import exceedes_date_limit -from six.moves.urllib.parse import parse_qs -from six.moves.urllib.parse import urlparse +from six.moves.urllib.parse import parse_qs, urlparse from zope.annotation.interfaces import IAnnotations from zope.component import Interface from zope.event import notify from zope.interface import implementer -import math +from redturtle.prenotazioni import _, datetime_with_tz, logger +from redturtle.prenotazioni.adapters.slot import BaseSlot +from redturtle.prenotazioni.config import VERIFIED_BOOKING +from redturtle.prenotazioni.content.prenotazione import VACATION_TYPE +from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione +from redturtle.prenotazioni.utilities.dateutils import exceedes_date_limit class BookerException(Exception): diff --git a/src/redturtle/prenotazioni/adapters/conflict.py b/src/redturtle/prenotazioni/adapters/conflict.py index 9348343c..21f544a2 100644 --- a/src/redturtle/prenotazioni/adapters/conflict.py +++ b/src/redturtle/prenotazioni/adapters/conflict.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- from datetime import timedelta + +import six from plone.memoize.instance import memoize from Products.CMFCore.utils import getToolByName -from redturtle.prenotazioni.adapters.slot import BaseSlot from six.moves import range from zope.component import Interface from zope.interface import implementer -import six +from redturtle.prenotazioni.adapters.slot import BaseSlot class IConflictManager(Interface): diff --git a/src/redturtle/prenotazioni/adapters/ical.py b/src/redturtle/prenotazioni/adapters/ical.py index aa3e56e5..48b08707 100644 --- a/src/redturtle/prenotazioni/adapters/ical.py +++ b/src/redturtle/prenotazioni/adapters/ical.py @@ -1,21 +1,14 @@ # -*- coding: utf-8 -*- import icalendar - from Acquisition import aq_inner from plone.app.event.base import default_timezone -from plone.app.event.ical.exporter import ICalendarEventComponent -from plone.app.event.ical.exporter import PRODID -from plone.app.event.ical.exporter import VERSION -from plone.event.interfaces import IICalendar -from plone.event.interfaces import IICalendarEventComponent +from plone.app.event.ical.exporter import PRODID, VERSION, ICalendarEventComponent +from plone.event.interfaces import IICalendar, IICalendarEventComponent from plone.registry.interfaces import IRegistry -from plone.stringinterp.interfaces import IStringSubstitution -from plone.stringinterp.interfaces import IContextWrapper -from zope.component import getAdapter -from zope.component import getUtility +from plone.stringinterp.interfaces import IContextWrapper, IStringSubstitution +from zope.component import getAdapter, getUtility from zope.interface import implementer - from redturtle.prenotazioni import _ diff --git a/src/redturtle/prenotazioni/adapters/prenotazione_email_message.py b/src/redturtle/prenotazioni/adapters/prenotazione_email_message.py index 563d6c3d..86d82c28 100644 --- a/src/redturtle/prenotazioni/adapters/prenotazione_email_message.py +++ b/src/redturtle/prenotazioni/adapters/prenotazione_email_message.py @@ -4,18 +4,18 @@ from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText + from plone import api from plone.event.interfaces import IICalendar -from plone.stringinterp.interfaces import IContextWrapper -from plone.stringinterp.interfaces import IStringInterpolator +from plone.stringinterp.interfaces import IContextWrapper, IStringInterpolator from Products.DCWorkflow.interfaces import IAfterTransitionEvent +from zope.component import adapter, getAdapter +from zope.interface import implementer + from redturtle.prenotazioni import logger from redturtle.prenotazioni.content.prenotazione import IPrenotazione from redturtle.prenotazioni.interfaces import IPrenotazioneEmailMessage from redturtle.prenotazioni.prenotazione_event import IMovedPrenotazione -from zope.component import adapter -from zope.component import getAdapter -from zope.interface import implementer class PrenotazioneEventEmailMessage: diff --git a/src/redturtle/prenotazioni/adapters/slot.py b/src/redturtle/prenotazioni/adapters/slot.py index 184eb844..9483c84d 100644 --- a/src/redturtle/prenotazioni/adapters/slot.py +++ b/src/redturtle/prenotazioni/adapters/slot.py @@ -2,8 +2,7 @@ from DateTime import DateTime from plone.app.event.base import default_timezone from pyinter.interval import Interval -from six.moves import map -from six.moves import range +from six.moves import map, range from zope.component import Interface from zope.interface import implementer diff --git a/src/redturtle/prenotazioni/adapters/stringinterp.py b/src/redturtle/prenotazioni/adapters/stringinterp.py index ac134e8c..77cff1a6 100644 --- a/src/redturtle/prenotazioni/adapters/stringinterp.py +++ b/src/redturtle/prenotazioni/adapters/stringinterp.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- from plone.app.event.base import default_timezone from plone.stringinterp.adapters import BaseSubstitution -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import logger from zope.component import adapter from zope.interface import Interface +from redturtle.prenotazioni import _, logger try: from plone.app.event.base import spell_date diff --git a/src/redturtle/prenotazioni/behaviors/booking_folder.py b/src/redturtle/prenotazioni/behaviors/booking_folder.py index e3b69d8c..cf0fd13f 100644 --- a/src/redturtle/prenotazioni/behaviors/booking_folder.py +++ b/src/redturtle/prenotazioni/behaviors/booking_folder.py @@ -2,11 +2,11 @@ from plone.autoform.interfaces import IFormFieldProvider from plone.dexterity.interfaces import IDexterityContent from plone.supermodel import model -from redturtle.prenotazioni import _ from zope import schema from zope.component import adapter -from zope.interface import implementer -from zope.interface import provider +from zope.interface import implementer, provider + +from redturtle.prenotazioni import _ @provider(IFormFieldProvider) diff --git a/src/redturtle/prenotazioni/browser/base.py b/src/redturtle/prenotazioni/browser/base.py index e7da22d6..ba6be062 100644 --- a/src/redturtle/prenotazioni/browser/base.py +++ b/src/redturtle/prenotazioni/browser/base.py @@ -2,9 +2,10 @@ from plone import api from plone.memoize.view import memoize from Products.Five.browser import BrowserView +from zExceptions import NotFound + from redturtle.prenotazioni.adapters.conflict import IConflictManager from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder -from zExceptions import NotFound class BaseView(BrowserView): diff --git a/src/redturtle/prenotazioni/browser/delete_reservation.py b/src/redturtle/prenotazioni/browser/delete_reservation.py index b45b49d7..e226cc40 100644 --- a/src/redturtle/prenotazioni/browser/delete_reservation.py +++ b/src/redturtle/prenotazioni/browser/delete_reservation.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- +from datetime import datetime, time + from AccessControl import Unauthorized -from datetime import datetime -from datetime import time from plone import api from plone.memoize.view import memoize from plone.protect import CheckAuthenticator from Products.CMFCore.utils import getToolByName from Products.Five.browser import BrowserView -from redturtle.prenotazioni import _ -from zExceptions import Forbidden -from zExceptions import NotFound +from zExceptions import Forbidden, NotFound from zope.i18n import translate +from redturtle.prenotazioni import _ + class BaseView(BrowserView): @property diff --git a/src/redturtle/prenotazioni/browser/prenotazione.py b/src/redturtle/prenotazioni/browser/prenotazione.py index 43d4be2d..08b55c5a 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione.py +++ b/src/redturtle/prenotazioni/browser/prenotazione.py @@ -3,6 +3,7 @@ from plone.memoize.view import memoize from plone.protect.authenticator import createToken from Products.Five.browser import BrowserView + from redturtle.prenotazioni.config import MIN_IN_DAY from redturtle.prenotazioni.utilities.urls import urlify diff --git a/src/redturtle/prenotazioni/browser/prenotazione_add.py b/src/redturtle/prenotazioni/browser/prenotazione_add.py index 6e1a0e5f..5396b3d0 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione_add.py +++ b/src/redturtle/prenotazioni/browser/prenotazione_add.py @@ -2,28 +2,24 @@ from plone import api from plone.memoize.view import memoize from plone.z3cform.layout import wrap_form -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni.adapters.booker import BookerException -from redturtle.prenotazioni.adapters.booker import IBooker +from z3c.form import button, field, form +from z3c.form.interfaces import ( + HIDDEN_MODE, + ActionExecutionError, + WidgetActionExecutionError, +) +from zope.component import getUtility +from zope.interface import Invalid, implementer +from zope.schema import Text, TextLine +from zope.schema.interfaces import IVocabularyFactory + +from redturtle.prenotazioni import _, datetime_with_tz +from redturtle.prenotazioni.adapters.booker import BookerException, IBooker 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 -from z3c.form import button -from z3c.form import field -from z3c.form import form -from z3c.form.interfaces import ActionExecutionError -from z3c.form.interfaces import HIDDEN_MODE -from z3c.form.interfaces import WidgetActionExecutionError -from zope.component import getUtility -from zope.interface import implementer -from zope.interface import Invalid -from zope.schema import Text -from zope.schema import TextLine -from zope.schema.interfaces import IVocabularyFactory - DEFAULT_REQUIRED_FIELDS = [] diff --git a/src/redturtle/prenotazioni/browser/prenotazione_move.py b/src/redturtle/prenotazioni/browser/prenotazione_move.py index 6aa5bd30..0391f607 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione_move.py +++ b/src/redturtle/prenotazioni/browser/prenotazione_move.py @@ -1,26 +1,18 @@ # -*- coding: utf-8 -*- +import logging + from plone import api from plone.memoize.view import memoize from plone.protect.utils import addTokenToUrl from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni import tznow -from redturtle.prenotazioni.adapters.booker import BookerException -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.utilities.urls import urlify -from z3c.form import button -from z3c.form import field -from z3c.form import form +from z3c.form import button, field, form from z3c.form.interfaces import ActionExecutionError -from zope.interface import implementer -from zope.interface import Interface -from zope.interface import Invalid -from zope.schema import Datetime -from zope.schema import TextLine - -import logging +from zope.interface import Interface, Invalid, implementer +from zope.schema import Datetime, TextLine +from redturtle.prenotazioni import _, datetime_with_tz, tznow +from redturtle.prenotazioni.adapters.booker import BookerException, IBooker +from redturtle.prenotazioni.utilities.urls import urlify logger = logging.getLogger(__name__) diff --git a/src/redturtle/prenotazioni/browser/prenotazione_print.py b/src/redturtle/prenotazioni/browser/prenotazione_print.py index e8b40125..1fbb9abd 100644 --- a/src/redturtle/prenotazioni/browser/prenotazione_print.py +++ b/src/redturtle/prenotazioni/browser/prenotazione_print.py @@ -5,6 +5,7 @@ from Products.CMFCore.utils import getToolByName from Products.Five.browser import BrowserView from Products.statusmessages.interfaces import IStatusMessage + from redturtle.prenotazioni import _ from redturtle.prenotazioni.utilities.urls import urlify diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py index 3c1ec29c..b44b2c1a 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py @@ -1,32 +1,24 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import itertools +import json +import logging +from datetime import date, datetime, timedelta + +import six from DateTime import DateTime from plone import api from plone.memoize.view import memoize from Products.Five.browser import BrowserView -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import get_or_create_obj -from redturtle.prenotazioni import tznow +from six.moves import map, range + +from redturtle.prenotazioni import _, get_or_create_obj, tznow from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.adapters.conflict import IConflictManager -from redturtle.prenotazioni.adapters.slot import BaseSlot -from redturtle.prenotazioni.adapters.slot import ISlot -from redturtle.prenotazioni.config import PAUSE_PORTAL_TYPE -from redturtle.prenotazioni.config import PAUSE_SLOT +from redturtle.prenotazioni.adapters.slot import BaseSlot, ISlot +from redturtle.prenotazioni.config import PAUSE_PORTAL_TYPE, PAUSE_SLOT from redturtle.prenotazioni.content.pause import Pause -from redturtle.prenotazioni.utilities.dateutils import hm2DT -from redturtle.prenotazioni.utilities.dateutils import hm2seconds +from redturtle.prenotazioni.utilities.dateutils import hm2DT, hm2seconds from redturtle.prenotazioni.utilities.urls import urlify -from six.moves import map -from six.moves import range - -import itertools -import json -import logging -import six - logger = logging.getLogger(__name__) diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py index 00543892..7d820466 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_portal_state.py @@ -5,8 +5,7 @@ from Products.CMFPlone.utils import safe_unicode from Products.Five.browser import BrowserView from zope.i18n import translate -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary class PrenotazioniPortalState(BrowserView): diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_search.py b/src/redturtle/prenotazioni/browser/prenotazioni_search.py index 6d748633..1f23ae32 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_search.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_search.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- -from datetime import datetime -from DateTime import DateTime -import json import base64 +import json +from datetime import datetime # from ZPublisher.Iterators import filestream_iterator from io import BytesIO + +from DateTime import DateTime from plone import api from plone.api.content import get_state from plone.app.event.base import default_timezone @@ -15,24 +16,19 @@ from Products.CMFPlone.browser.search import quote_chars from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from pyexcel_xlsx import save_data -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.adapters.conflict import IConflictManager -from redturtle.prenotazioni.utilities.urls import urlify -from z3c.form import button -from z3c.form import field -from z3c.form import form +from z3c.form import button, field, form from zExceptions import NotFound from zope.component import getUtility from zope.i18n import translate -from zope.interface import implementer -from zope.interface import Interface +from zope.interface import Interface, implementer from zope.publisher.interfaces import IPublishTraverse -from zope.schema import Choice -from zope.schema import Date -from zope.schema import TextLine -from zope.schema import ValidationError +from zope.schema import Choice, Date, TextLine, ValidationError from zope.schema.interfaces import IVocabularyFactory +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.adapters.conflict import IConflictManager +from redturtle.prenotazioni.utilities.urls import urlify + class InvalidDate(ValidationError): __doc__ = _("invalid_end:search_date", "Invalid start or end date") diff --git a/src/redturtle/prenotazioni/browser/stats/booking_stats.py b/src/redturtle/prenotazioni/browser/stats/booking_stats.py index c33a283a..2a081b8d 100644 --- a/src/redturtle/prenotazioni/browser/stats/booking_stats.py +++ b/src/redturtle/prenotazioni/browser/stats/booking_stats.py @@ -1,24 +1,19 @@ # -*- coding: utf-8 -*- -from BTrees.OOBTree import OOTreeSet from csv import writer -from datetime import date -from datetime import datetime -from datetime import timedelta +from datetime import date, datetime, timedelta from io import StringIO from json import dumps -from plone.memoize.view import memoize -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import logger -from redturtle.prenotazioni import prenotazioniFileLogger -from redturtle.prenotazioni.browser.base import BaseView as PrenotazioniBaseView from time import mktime + +import six +from BTrees.OOBTree import OOTreeSet +from plone.memoize.view import memoize from zope.annotation.interfaces import IAnnotations from zope.interface import Interface -from zope.schema import Date -from zope.schema import TextLine -from zope.schema import ValidationError +from zope.schema import Date, TextLine, ValidationError -import six +from redturtle.prenotazioni import _, logger, prenotazioniFileLogger +from redturtle.prenotazioni.browser.base import BaseView as PrenotazioniBaseView class InvalidDate(ValidationError): diff --git a/src/redturtle/prenotazioni/browser/vacations.py b/src/redturtle/prenotazioni/browser/vacations.py index e33565a7..69e4d39d 100644 --- a/src/redturtle/prenotazioni/browser/vacations.py +++ b/src/redturtle/prenotazioni/browser/vacations.py @@ -1,30 +1,22 @@ # -*- coding: utf-8 -*- from datetime import datetime + +import six from DateTime import DateTime from plone import api from plone.memoize.view import memoize from Products.Five.browser import BrowserView from Products.statusmessages.interfaces import IStatusMessage -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import logger -from redturtle.prenotazioni import time2timedelta -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.adapters.slot import BaseSlot -from redturtle.prenotazioni.utilities.urls import urlify from six.moves import map -from z3c.form import button -from z3c.form import field -from z3c.form import form +from z3c.form import button, field, form from z3c.form.interfaces import ActionExecutionError -from zope.interface import implementer -from zope.interface import Interface -from zope.interface import Invalid -from zope.schema import Choice -from zope.schema import Date -from zope.schema import TextLine -from zope.schema import ValidationError +from zope.interface import Interface, Invalid, implementer +from zope.schema import Choice, Date, TextLine, ValidationError -import six +from redturtle.prenotazioni import _, logger, time2timedelta +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.adapters.slot import BaseSlot +from redturtle.prenotazioni.utilities.urls import urlify class InvalidDate(ValidationError): diff --git a/src/redturtle/prenotazioni/browser/viewlets.py b/src/redturtle/prenotazioni/browser/viewlets.py index 7d51d2f4..44cf47d4 100644 --- a/src/redturtle/prenotazioni/browser/viewlets.py +++ b/src/redturtle/prenotazioni/browser/viewlets.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- +import importlib.metadata + from plone import api from plone.app.layout.viewlets.common import ViewletBase from zope.interface import Interface -import importlib.metadata - - HASH = importlib.metadata.version("redturtle.prenotazioni") diff --git a/src/redturtle/prenotazioni/browser/week.py b/src/redturtle/prenotazioni/browser/week.py index b2d5c6b0..adb8ba4c 100644 --- a/src/redturtle/prenotazioni/browser/week.py +++ b/src/redturtle/prenotazioni/browser/week.py @@ -1,21 +1,20 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import timedelta +import time +from datetime import date, timedelta from email.utils import formatdate + from plone import api from plone.memoize.view import memoize from Products.CMFCore.utils import getToolByName -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.browser.base import BaseView -from redturtle.prenotazioni.browser.interfaces import IDontFollowMe -from redturtle.prenotazioni.utilities.urls import urlify from six.moves import range from zope.deprecation import deprecate from zope.interface import implementer from zope.schema.vocabulary import getVocabularyRegistry -import time - +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.browser.base import BaseView +from redturtle.prenotazioni.browser.interfaces import IDontFollowMe +from redturtle.prenotazioni.utilities.urls import urlify TIPOLOGIA_PRENOTAZIONE_NAME = "TipologiaPrenotazione" TIPOLOGIA_PRENOTAZIONE_NAME_COOKIE = "TipologiaPrenotazione_cookie" diff --git a/src/redturtle/prenotazioni/browser/widget.py b/src/redturtle/prenotazioni/browser/widget.py index 881b4693..465d06e0 100644 --- a/src/redturtle/prenotazioni/browser/widget.py +++ b/src/redturtle/prenotazioni/browser/widget.py @@ -1,13 +1,10 @@ # -*- coding: utf-8 -*- from z3c.form.browser import widget from z3c.form.browser.textarea import TextAreaWidget -from z3c.form.interfaces import IFieldWidget -from z3c.form.interfaces import IFormLayer -from z3c.form.interfaces import ITextAreaWidget +from z3c.form.interfaces import IFieldWidget, IFormLayer, ITextAreaWidget from z3c.form.widget import FieldWidget from zope.component import adapter -from zope.interface import implementer -from zope.interface import implementer_only +from zope.interface import implementer, implementer_only from zope.schema.interfaces import IField diff --git a/src/redturtle/prenotazioni/browser/z3c_custom_widget.py b/src/redturtle/prenotazioni/browser/z3c_custom_widget.py index 32a942af..40c263af 100644 --- a/src/redturtle/prenotazioni/browser/z3c_custom_widget.py +++ b/src/redturtle/prenotazioni/browser/z3c_custom_widget.py @@ -1,16 +1,14 @@ # -*- coding: utf-8 -*- +import zope from plone import api from plone.memoize.view import memoize from Products.CMFPlone.utils import safe_unicode from Products.Five.browser import BrowserView from Products.Five.browser.metaconfigure import ViewMixinForTemplates -from redturtle.prenotazioni import _ -from z3c.form import interfaces -from z3c.form import util +from z3c.form import interfaces, util from z3c.form.browser.radio import RadioWidget from z3c.form.interfaces import IRadioWidget -from z3c.form.widget import FieldWidget -from z3c.form.widget import SequenceWidget +from z3c.form.widget import FieldWidget, SequenceWidget from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile as VPTF from zope.component import getUtility from zope.i18n import translate @@ -18,7 +16,7 @@ from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleTerm -import zope +from redturtle.prenotazioni import _ class ICustomRadioFieldWidget(interfaces.IFieldWidget): diff --git a/src/redturtle/prenotazioni/content/pause.py b/src/redturtle/prenotazioni/content/pause.py index b073b7b0..6afa3ee4 100644 --- a/src/redturtle/prenotazioni/content/pause.py +++ b/src/redturtle/prenotazioni/content/pause.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- +from zope.interface import implementer + from redturtle.prenotazioni import _ from redturtle.prenotazioni.config import PAUSE_PORTAL_TYPE from redturtle.prenotazioni.interfaces import IPause from redturtle.prenotazioni.utilities.dateutils import hm2DT -from zope.interface import implementer @implementer(IPause) diff --git a/src/redturtle/prenotazioni/content/prenotazione.py b/src/redturtle/prenotazioni/content/prenotazione.py index e70e6650..45516fc0 100644 --- a/src/redturtle/prenotazioni/content/prenotazione.py +++ b/src/redturtle/prenotazioni/content/prenotazione.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -from .prenotazioni_folder import IPrenotazioniFolder +import re + +import six from DateTime import DateTime from plone import api from plone.app.event.base import default_timezone @@ -7,17 +9,14 @@ from plone.autoform import directives from plone.dexterity.content import Item from plone.supermodel import model -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni import tznow -from redturtle.prenotazioni.utils import is_migration from zope import schema from zope.interface import implementer from zope.schema import ValidationError -import re -import six +from redturtle.prenotazioni import _, datetime_with_tz, tznow +from redturtle.prenotazioni.utils import is_migration +from .prenotazioni_folder import IPrenotazioniFolder VACATION_TYPE = "out-of-office" TELEPHONE_PATTERN = re.compile(r"^(\+){0,1}([0-9]| )*$") diff --git a/src/redturtle/prenotazioni/content/prenotazioni_folder.py b/src/redturtle/prenotazioni/content/prenotazioni_folder.py index 984b3968..ae8bd6f2 100644 --- a/src/redturtle/prenotazioni/content/prenotazioni_folder.py +++ b/src/redturtle/prenotazioni/content/prenotazioni_folder.py @@ -6,22 +6,17 @@ from plone.autoform import directives as form from plone.dexterity.content import Container from plone.supermodel import model -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.browser.widget import WeekTableOverridesFieldWidget -from redturtle.prenotazioni.config import DEFAULT_VISIBLE_BOOKING_FIELDS -from redturtle.prenotazioni.content.validators import checkOverrides -from redturtle.prenotazioni.content.validators import PauseValidator from z3c.form import validator from z3c.form.browser.checkbox import CheckBoxFieldWidget from zope import schema from zope.component import provideAdapter -from zope.interface import implementer -from zope.interface import Interface -from zope.interface import Invalid -from zope.interface import invariant -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.interface import Interface, Invalid, implementer, invariant +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.browser.widget import WeekTableOverridesFieldWidget +from redturtle.prenotazioni.config import DEFAULT_VISIBLE_BOOKING_FIELDS +from redturtle.prenotazioni.content.validators import PauseValidator, checkOverrides try: from plone.app.dexterity import textindexer diff --git a/src/redturtle/prenotazioni/content/validators.py b/src/redturtle/prenotazioni/content/validators.py index 5ce414c6..e97f0313 100644 --- a/src/redturtle/prenotazioni/content/validators.py +++ b/src/redturtle/prenotazioni/content/validators.py @@ -1,16 +1,19 @@ # -*- coding: utf-8 -*- +import calendar +import json from datetime import date -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.adapters.slot import interval_is_contained -from redturtle.prenotazioni.adapters.slot import is_intervals_overlapping + from z3c.form import validator from zope.globalrequest import getRequest from zope.i18n import translate from zope.interface import Invalid from zope.schema import ValidationError -import calendar -import json +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.adapters.slot import ( + interval_is_contained, + is_intervals_overlapping, +) def get_dgf_values_from_request(request, fieldname, columns=[]): diff --git a/src/redturtle/prenotazioni/contentrules/sendMovedPrenotazione.py b/src/redturtle/prenotazioni/contentrules/sendMovedPrenotazione.py index 4fb58b60..89a35b4b 100644 --- a/src/redturtle/prenotazioni/contentrules/sendMovedPrenotazione.py +++ b/src/redturtle/prenotazioni/contentrules/sendMovedPrenotazione.py @@ -1,21 +1,17 @@ # -*- coding: utf-8 -*- +import six from Acquisition import aq_inner from OFS.SimpleItem import SimpleItem -from plone.app.contentrules.actions import ActionAddForm -from plone.app.contentrules.actions import ActionEditForm -from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper -from plone.app.contentrules.browser.formhelper import EditForm -from plone.contentrules.rule.interfaces import IExecutable -from plone.contentrules.rule.interfaces import IRuleElementData +from plone.app.contentrules.actions import ActionAddForm, ActionEditForm +from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper, EditForm +from plone.contentrules.rule.interfaces import IExecutable, IRuleElementData from Products.CMFCore.utils import getToolByName -from redturtle.prenotazioni import _ from zope import schema from zope.component import adapter -from zope.interface import implementer -from zope.interface import Interface +from zope.interface import Interface, implementer from zope.interface.interfaces import ComponentLookupError -import six +from redturtle.prenotazioni import _ class IMovedPrenotazioneAction(Interface): diff --git a/src/redturtle/prenotazioni/events/events_logger.py b/src/redturtle/prenotazioni/events/events_logger.py index 6977affb..f635b6af 100644 --- a/src/redturtle/prenotazioni/events/events_logger.py +++ b/src/redturtle/prenotazioni/events/events_logger.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from json import dumps -from plone import api from time import time +from plone import api + def log_data_for_booking(obj, data): """Log the given data for a booking""" diff --git a/src/redturtle/prenotazioni/events/prenotazione.py b/src/redturtle/prenotazioni/events/prenotazione.py index afd77e47..cd66c5fe 100644 --- a/src/redturtle/prenotazioni/events/prenotazione.py +++ b/src/redturtle/prenotazioni/events/prenotazione.py @@ -1,23 +1,20 @@ # -*- coding: utf-8 -*- -from email.utils import formataddr -from email.utils import parseaddr +import hashlib +from email.utils import formataddr, parseaddr from logging import getLogger + from plone import api from plone.app.event.base import default_timezone from plone.registry.interfaces import IRegistry from plone.stringinterp.interfaces import IStringSubstitution from Products.CMFPlone.interfaces.controlpanel import IMailSchema +from zope.component import getAdapter, getMultiAdapter, getUtility +from zope.i18n import translate + from redturtle.prenotazioni import _ from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.interfaces import IPrenotazioneEmailMessage from redturtle.prenotazioni.utils import is_migration -from zope.component import getAdapter -from zope.component import getMultiAdapter -from zope.component import getUtility -from zope.i18n import translate - -import hashlib - logger = getLogger(__name__) diff --git a/src/redturtle/prenotazioni/events/prenotazioni_folder.py b/src/redturtle/prenotazioni/events/prenotazioni_folder.py index a46991e0..4ad4ebf1 100644 --- a/src/redturtle/prenotazioni/events/prenotazioni_folder.py +++ b/src/redturtle/prenotazioni/events/prenotazioni_folder.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- from plone.app.contentrules.rule import get_assignments from plone.contentrules.engine.assignments import RuleAssignment -from plone.contentrules.engine.interfaces import IRuleAssignmentManager -from plone.contentrules.engine.interfaces import IRuleStorage +from plone.contentrules.engine.interfaces import IRuleAssignmentManager, IRuleStorage from zope.component import getUtility diff --git a/src/redturtle/prenotazioni/indexers/prenotazione.py b/src/redturtle/prenotazioni/indexers/prenotazione.py index e639083e..52a40b91 100644 --- a/src/redturtle/prenotazioni/indexers/prenotazione.py +++ b/src/redturtle/prenotazioni/indexers/prenotazione.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from plone.indexer.decorator import indexer -from redturtle.prenotazioni.content.prenotazione import IPrenotazione +from redturtle.prenotazioni.content.prenotazione import IPrenotazione try: from plone.base.utils import safe_text diff --git a/src/redturtle/prenotazioni/locales/update.py b/src/redturtle/prenotazioni/locales/update.py index 2e891060..bdae5d7b 100644 --- a/src/redturtle/prenotazioni/locales/update.py +++ b/src/redturtle/prenotazioni/locales/update.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import os -import pkg_resources import subprocess +import pkg_resources domain = "redturtle.prenotazioni" os.chdir(pkg_resources.resource_filename(domain, "")) diff --git a/src/redturtle/prenotazioni/prenotazione_event.py b/src/redturtle/prenotazioni/prenotazione_event.py index 0de11f91..9d162822 100644 --- a/src/redturtle/prenotazioni/prenotazione_event.py +++ b/src/redturtle/prenotazioni/prenotazione_event.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from zope.interface import implementer -from zope.interface.interfaces import IObjectEvent -from zope.interface.interfaces import ObjectEvent +from zope.interface.interfaces import IObjectEvent, ObjectEvent class IMovedPrenotazione(IObjectEvent): diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py index 7c574346..419edc51 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py @@ -2,14 +2,15 @@ from plone import api from plone.restapi.interfaces import ISerializeToJson from plone.restapi.serializer.converters import json_compatible -from redturtle.prenotazioni import logger -from redturtle.prenotazioni.content.prenotazione import IPrenotazione -from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem from zope.component import adapter from zope.i18n import translate from zope.interface import implementer from zope.publisher.interfaces import IRequest +from redturtle.prenotazioni import logger +from redturtle.prenotazioni.content.prenotazione import IPrenotazione +from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem + @implementer(ISerializeToJson) @adapter(IPrenotazione, IRequest) diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/slot.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/slot.py index 345ec446..57da313a 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/slot.py +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/slot.py @@ -2,12 +2,13 @@ # from datetime import time, datetime from plone.restapi.interfaces import ISerializeToJson from plone.restapi.serializer.converters import json_compatible -from redturtle.prenotazioni.adapters.slot import ISlot -from redturtle.prenotazioni.utilities.dateutils import hm2DT from zope.component import adapter from zope.interface import implementer from zope.publisher.interfaces import IRequest +from redturtle.prenotazioni.adapters.slot import ISlot +from redturtle.prenotazioni.utilities.dateutils import hm2DT + @implementer(ISerializeToJson) @adapter(ISlot, IRequest) diff --git a/src/redturtle/prenotazioni/restapi/services/available_slots/get.py b/src/redturtle/prenotazioni/restapi/services/available_slots/get.py index e1bbff49..a8580860 100644 --- a/src/redturtle/prenotazioni/restapi/services/available_slots/get.py +++ b/src/redturtle/prenotazioni/restapi/services/available_slots/get.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- +import calendar +import datetime from datetime import timedelta + from plone import api from plone.restapi.serializer.converters import json_compatible from plone.restapi.services import Service -from redturtle.prenotazioni import _ from zExceptions import BadRequest -import calendar -import datetime +from redturtle.prenotazioni import _ class AvailableSlots(Service): diff --git a/src/redturtle/prenotazioni/restapi/services/booking/add.py b/src/redturtle/prenotazioni/restapi/services/booking/add.py index aae10888..281a82da 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/add.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/add.py @@ -3,15 +3,14 @@ from plone.protect.interfaces import IDisableCSRFProtection from plone.restapi.deserializer import json_body from plone.restapi.interfaces import ISerializeToJson -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.adapters.booker import BookerException -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.content.prenotazione import VACATION_TYPE -from redturtle.prenotazioni.restapi.services.booking_schema.get import BookingSchema from zExceptions import BadRequest from zope.component import queryMultiAdapter from zope.interface import alsoProvides +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.adapters.booker import BookerException, IBooker +from redturtle.prenotazioni.content.prenotazione import VACATION_TYPE +from redturtle.prenotazioni.restapi.services.booking_schema.get import BookingSchema # src/redturtle/prenotazioni/browser/prenotazione_add.py diff --git a/src/redturtle/prenotazioni/restapi/services/booking/move.py b/src/redturtle/prenotazioni/restapi/services/booking/move.py index 94e8199e..ac962efc 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/move.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/move.py @@ -3,11 +3,11 @@ from plone.protect.interfaces import IDisableCSRFProtection from plone.restapi.deserializer import json_body from plone.restapi.services import Service -from redturtle.prenotazioni.adapters.booker import BookerException -from redturtle.prenotazioni.adapters.booker import IBooker from zExceptions import BadRequest from zope.interface import alsoProvides +from redturtle.prenotazioni.adapters.booker import BookerException, IBooker + class MoveBooking(Service): def reply(self): diff --git a/src/redturtle/prenotazioni/restapi/services/booking/notify_about_confirm.py b/src/redturtle/prenotazioni/restapi/services/booking/notify_about_confirm.py index 6e82d551..65ece567 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/notify_about_confirm.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/notify_about_confirm.py @@ -1,14 +1,12 @@ # -*- coding: utf-8 -*- -from plone.restapi.services import Service from plone import api -from zope.interface import implementer -from zope.publisher.interfaces import IPublishTraverse +from plone.restapi.services import Service from Products.DCWorkflow.events import AfterTransitionEvent from zExceptions import BadRequest +from zope.interface import implementer +from zope.publisher.interfaces import IPublishTraverse -from redturtle.prenotazioni.events.prenotazione import ( - notify_on_after_transition_event, -) +from redturtle.prenotazioni.events.prenotazione import notify_on_after_transition_event @implementer(IPublishTraverse) diff --git a/src/redturtle/prenotazioni/restapi/services/booking/vacation.py b/src/redturtle/prenotazioni/restapi/services/booking/vacation.py index 033f7a49..42d61ab1 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/vacation.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/vacation.py @@ -5,12 +5,12 @@ from plone.protect.interfaces import IDisableCSRFProtection from plone.restapi.deserializer import json_body from plone.restapi.services import Service -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.adapters.booker import BookerException -from redturtle.prenotazioni.adapters.booker import IBooker from zExceptions import BadRequest from zope.interface import alsoProvides +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.adapters.booker import BookerException, IBooker + class AddVacation(Service): def reply(self): diff --git a/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py b/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py index 3b8adde9..81f0c829 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py +++ b/src/redturtle/prenotazioni/restapi/services/booking_schema/get.py @@ -2,11 +2,11 @@ from plone import api from plone.memoize.view import memoize from plone.restapi.services import Service -from redturtle.prenotazioni import _ -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni.config import STATIC_REQUIRED_FIELDS from zExceptions import BadRequest +from redturtle.prenotazioni import _, datetime_with_tz +from redturtle.prenotazioni.config import STATIC_REQUIRED_FIELDS + class BookingSchema(Service): field_type_mapping = {"description": "textarea"} diff --git a/src/redturtle/prenotazioni/restapi/services/bookings/search.py b/src/redturtle/prenotazioni/restapi/services/bookings/search.py index 29392521..0d108f34 100644 --- a/src/redturtle/prenotazioni/restapi/services/bookings/search.py +++ b/src/redturtle/prenotazioni/restapi/services/bookings/search.py @@ -2,12 +2,13 @@ from DateTime import DateTime from plone import api from plone.restapi.services import Service -from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem from zExceptions import Unauthorized from zope.component import getMultiAdapter from zope.interface import implementer from zope.publisher.interfaces import IPublishTraverse +from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem + @implementer(IPublishTraverse) class BookingsSearch(Service): diff --git a/src/redturtle/prenotazioni/restapi/services/day/day.py b/src/redturtle/prenotazioni/restapi/services/day/day.py index 07a457f4..15c38f02 100644 --- a/src/redturtle/prenotazioni/restapi/services/day/day.py +++ b/src/redturtle/prenotazioni/restapi/services/day/day.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime +from datetime import date, datetime + from plone import api from plone.memoize.view import memoize from plone.restapi.interfaces import ISerializeToJson from plone.restapi.services import Service -from redturtle.prenotazioni.adapters.slot import ISlot from zExceptions import BadRequest from zope.component import getMultiAdapter from zope.interface import implementer from zope.publisher.interfaces import IPublishTraverse +from redturtle.prenotazioni.adapters.slot import ISlot + @implementer(IPublishTraverse) class DaySlots(Service): diff --git a/src/redturtle/prenotazioni/scripts/app_io.py b/src/redturtle/prenotazioni/scripts/app_io.py index a607fe50..c75c3cbe 100644 --- a/src/redturtle/prenotazioni/scripts/app_io.py +++ b/src/redturtle/prenotazioni/scripts/app_io.py @@ -1,19 +1,18 @@ # -*- encoding: utf-8 -*- -from .io_tools.api import Api -from .io_tools.storage import logstorage -from datetime import datetime -from datetime import timedelta -from plone import api -from redturtle.prenotazioni.config import NOTIFICATIONS_LOGS -from redturtle.prenotazioni.config import VERIFIED_BOOKING -from zope.annotation.interfaces import IAnnotations - -import click import locale import logging import sys +from datetime import datetime, timedelta + +import click import transaction +from plone import api +from zope.annotation.interfaces import IAnnotations +from redturtle.prenotazioni.config import NOTIFICATIONS_LOGS, VERIFIED_BOOKING + +from .io_tools.api import Api +from .io_tools.storage import logstorage logger = logging.getLogger("redturtle.prenotazioni.app_io") locale.setlocale(locale.LC_ALL, "it_IT.UTF-8") diff --git a/src/redturtle/prenotazioni/scripts/io_tools/__init__.py b/src/redturtle/prenotazioni/scripts/io_tools/__init__.py index b0c170ab..5e3aa1bb 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/__init__.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/__init__.py @@ -5,10 +5,9 @@ __email__ = "mauro.amico@gmail.com" __version__ = "0.1.0" -from . import monkey - import logging +from . import monkey logger = logging.getLogger(__name__) monkey.apply() diff --git a/src/redturtle/prenotazioni/scripts/io_tools/api.py b/src/redturtle/prenotazioni/scripts/io_tools/api.py index 3f1f02a6..5301473b 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/api.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/api.py @@ -8,16 +8,16 @@ An optional due_date: a due date that let the recipient add a reminder when receiving the message. The format for all dates is ISO8601 with time information and UTC timezone (ie. "2018-10-13T00:00:00.000Z"). """ -from . import logger +from datetime import datetime # from pkg_resources import resource_filename # from bravado.swagger_model import load_file from bravado.client import SwaggerClient from bravado.exception import HTTPForbidden from bravado.requests_client import RequestsClient -from datetime import datetime from pytz import timezone +from . import logger # STATUS INTERNI A QUESTA API PROFILE_NOT_FOUND = "PROFILE_NOT_FOUND" diff --git a/src/redturtle/prenotazioni/scripts/io_tools/cli.py b/src/redturtle/prenotazioni/scripts/io_tools/cli.py index 406e76ad..4152a945 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/cli.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/cli.py @@ -1,12 +1,13 @@ # -*- encoding: utf-8 -*- """Console script for io_tools.""" -from .api import Api - -import click import importlib import sys + +import click import yaml +from .api import Api + def load_class(klass): mod, klassname = klass.split(":") diff --git a/src/redturtle/prenotazioni/scripts/io_tools/monkey.py b/src/redturtle/prenotazioni/scripts/io_tools/monkey.py index 9d585d88..51727bf1 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/monkey.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/monkey.py @@ -1,11 +1,5 @@ # -*- encoding: utf-8 -*- -from bravado_core.spec import is_yaml -from bravado_core.spec import json -from bravado_core.spec import log -from bravado_core.spec import Spec -from bravado_core.spec import url2pathname -from bravado_core.spec import urlparse -from bravado_core.spec import yaml +from bravado_core.spec import Spec, is_yaml, json, log, url2pathname, urlparse, yaml def get_ref_handlers(self): diff --git a/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py b/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py index de973978..70efd440 100644 --- a/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py +++ b/src/redturtle/prenotazioni/scripts/io_tools/rdbms.py @@ -1,9 +1,9 @@ # -*- encoding: utf-8 -*- from datetime import datetime + from io_tools.storage import Storage as Base from pony import orm - db = orm.Database() diff --git a/src/redturtle/prenotazioni/testing.py b/src/redturtle/prenotazioni/testing.py index 0e1a7397..bdbae74c 100644 --- a/src/redturtle/prenotazioni/testing.py +++ b/src/redturtle/prenotazioni/testing.py @@ -1,19 +1,20 @@ # -*- coding: utf-8 -*- -from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE -from plone.app.testing import applyProfile -from plone.app.testing import FunctionalTesting -from plone.app.testing import IntegrationTesting -from plone.app.testing import MOCK_MAILHOST_FIXTURE -from plone.app.testing import PloneSandboxLayer -from plone.restapi.testing import PloneRestApiDXLayer -from plone.testing import z2 - import collective.contentrules.mailfromfield import collective.z3cform.datagridfield import plone.app.caching import plone.restapi -import redturtle.prenotazioni +from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE +from plone.app.testing import ( + MOCK_MAILHOST_FIXTURE, + FunctionalTesting, + IntegrationTesting, + PloneSandboxLayer, + applyProfile, +) +from plone.restapi.testing import PloneRestApiDXLayer +from plone.testing import z2 +import redturtle.prenotazioni try: import collective.dexteritytextindexer diff --git a/src/redturtle/prenotazioni/tests/test_add_block.py b/src/redturtle/prenotazioni/tests/test_add_block.py index f8780708..671df656 100644 --- a/src/redturtle/prenotazioni/tests/test_add_block.py +++ b/src/redturtle/prenotazioni/tests/test_add_block.py @@ -1,19 +1,21 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import timedelta +import unittest +from datetime import date, timedelta + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.testing import RelativeSession + from redturtle.prenotazioni.content.prenotazione import VACATION_TYPE from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING from redturtle.prenotazioni.tests.helpers import WEEK_TABLE_SCHEMA -import transaction -import unittest - class TestBookingRestAPIAddBlock(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_add_booking.py b/src/redturtle/prenotazioni/tests/test_add_booking.py index 9ed3d1a6..c1394edf 100644 --- a/src/redturtle/prenotazioni/tests/test_add_booking.py +++ b/src/redturtle/prenotazioni/tests/test_add_booking.py @@ -1,24 +1,27 @@ # -*- coding: utf-8 -*- +import unittest +from datetime import date, datetime, timedelta + +import transaction from Acquisition import aq_parent -from datetime import date -from datetime import datetime -from datetime import timedelta from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.autoform.interfaces import MODES_KEY from plone.restapi.testing import RelativeSession +from zope.interface import Interface + from redturtle.prenotazioni.adapters.booker import IBooker 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, + REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING, +) from redturtle.prenotazioni.tests.helpers import WEEK_TABLE_SCHEMA -from zope.interface import Interface - -import transaction -import unittest class TestSchemaDirectives(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_available_slots.py b/src/redturtle/prenotazioni/tests/test_available_slots.py index 2beac80a..9ccdd792 100644 --- a/src/redturtle/prenotazioni/tests/test_available_slots.py +++ b/src/redturtle/prenotazioni/tests/test_available_slots.py @@ -1,22 +1,23 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import calendar +import unittest +from datetime import date, datetime, timedelta + +import pytz +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) 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 -import calendar -import pytz -import transaction -import unittest - class TestAvailableSlots(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_booking_info.py b/src/redturtle/prenotazioni/tests/test_booking_info.py index 92a5a838..35a8b1fe 100644 --- a/src/redturtle/prenotazioni/tests/test_booking_info.py +++ b/src/redturtle/prenotazioni/tests/test_booking_info.py @@ -1,19 +1,21 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime +import calendar +import unittest +from datetime import date, datetime + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.testing import RelativeSession + from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -import calendar -import transaction -import unittest - class TestBookingInfo(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_booking_notify_on_confirm_by_endoint.py b/src/redturtle/prenotazioni/tests/test_booking_notify_on_confirm_by_endoint.py index 9b2a5d66..f808f8ed 100644 --- a/src/redturtle/prenotazioni/tests/test_booking_notify_on_confirm_by_endoint.py +++ b/src/redturtle/prenotazioni/tests/test_booking_notify_on_confirm_by_endoint.py @@ -1,22 +1,20 @@ # -*- coding: UTF-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import email +import unittest +from datetime import date, datetime, timedelta + +import pytz from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles +from zope.globalrequest import getRequest +from zope.interface import implementer +from zope.interface.interfaces import IObjectEvent + from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.testing import ( REDTURTLE_PRENOTAZIONI_API_INTEGRATION_TESTING, ) -from zope.interface import implementer -from zope.interface.interfaces import IObjectEvent -from zope.globalrequest import getRequest - -import email -import pytz -import unittest @implementer(IObjectEvent) diff --git a/src/redturtle/prenotazioni/tests/test_booking_schema.py b/src/redturtle/prenotazioni/tests/test_booking_schema.py index 0c98833b..dd6985dc 100644 --- a/src/redturtle/prenotazioni/tests/test_booking_schema.py +++ b/src/redturtle/prenotazioni/tests/test_booking_schema.py @@ -1,17 +1,20 @@ # -*- coding: utf-8 -*- +import calendar +import unittest from datetime import date + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.serializer.converters import json_compatible from plone.restapi.testing import RelativeSession -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -import calendar -import transaction -import unittest +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING class TestBookingSchema(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_day.py b/src/redturtle/prenotazioni/tests/test_day.py index 45e8b66b..e6e75430 100644 --- a/src/redturtle/prenotazioni/tests/test_day.py +++ b/src/redturtle/prenotazioni/tests/test_day.py @@ -1,23 +1,24 @@ # -*- coding: UTF-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import unittest +from datetime import date, datetime, timedelta + from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.interfaces import ISerializeToJson from plone.restapi.testing import RelativeSession -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING from transaction import commit from zope.component import getMultiAdapter from zope.globalrequest import getRequest from zope.interface import implementer from zope.interface.interfaces import IObjectEvent -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING @implementer(IObjectEvent) diff --git a/src/redturtle/prenotazioni/tests/test_delete_booking.py b/src/redturtle/prenotazioni/tests/test_delete_booking.py index 8c57b78d..0012dac3 100644 --- a/src/redturtle/prenotazioni/tests/test_delete_booking.py +++ b/src/redturtle/prenotazioni/tests/test_delete_booking.py @@ -1,19 +1,15 @@ # -*- coding: utf-8 -*- +import unittest +from datetime import date, datetime, timedelta + +import transaction from AccessControl import Unauthorized -from datetime import date -from datetime import datetime -from datetime import timedelta from plone import api -from plone.app.testing import login -from plone.app.testing import logout -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 plone.app.testing import TEST_USER_ID, login, logout, setRoles from zExceptions import NotFound -import transaction -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING class TestDeleteBooking(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_delete_booking_api.py b/src/redturtle/prenotazioni/tests/test_delete_booking_api.py index 2cb7ba8a..c93f56bd 100644 --- a/src/redturtle/prenotazioni/tests/test_delete_booking_api.py +++ b/src/redturtle/prenotazioni/tests/test_delete_booking_api.py @@ -1,21 +1,22 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import unittest +from datetime import date, datetime, timedelta + +import transaction from plone import api -from plone.app.testing import login -from plone.app.testing import logout -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + login, + logout, + setRoles, +) from plone.restapi.testing import RelativeSession + from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -import transaction -import unittest - class TestDeleteBookingApi(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_gates_overrides.py b/src/redturtle/prenotazioni/tests/test_gates_overrides.py index d0bcd109..dad17086 100644 --- a/src/redturtle/prenotazioni/tests/test_gates_overrides.py +++ b/src/redturtle/prenotazioni/tests/test_gates_overrides.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- +import json +import unittest from datetime import date + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles + from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING from redturtle.prenotazioni.tests.helpers import WEEK_TABLE_SCHEMA -import json -import transaction -import unittest - class TestGatesOverrides(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_move_booking_api.py b/src/redturtle/prenotazioni/tests/test_move_booking_api.py index 62749486..eb0ca74b 100644 --- a/src/redturtle/prenotazioni/tests/test_move_booking_api.py +++ b/src/redturtle/prenotazioni/tests/test_move_booking_api.py @@ -1,20 +1,21 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import unittest +from datetime import date, datetime, timedelta + +import pytz +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.testing import RelativeSession + from redturtle.prenotazioni.adapters.booker import IBooker from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -import pytz -import transaction -import unittest - class TestMoveBookingApi(unittest.TestCase): layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/prenotazioni/tests/test_pauses_overrides.py b/src/redturtle/prenotazioni/tests/test_pauses_overrides.py index 26446cb1..68b9b242 100644 --- a/src/redturtle/prenotazioni/tests/test_pauses_overrides.py +++ b/src/redturtle/prenotazioni/tests/test_pauses_overrides.py @@ -1,18 +1,23 @@ # -*- coding: utf-8 -*- +import json +import unittest from datetime import date + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + 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.tests.helpers import WEEK_TABLE_SCHEMA -import json -import transaction -import unittest +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, + REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING, +) +from redturtle.prenotazioni.tests.helpers import WEEK_TABLE_SCHEMA class TestPausesOverride(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_prenotazione_email_sent_to_managers.py b/src/redturtle/prenotazioni/tests/test_prenotazione_email_sent_to_managers.py index b525697c..4db60b0f 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazione_email_sent_to_managers.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazione_email_sent_to_managers.py @@ -1,22 +1,20 @@ # -*- coding: UTF-8 -*- +import email +import unittest +from datetime import date, datetime, timedelta + +import pytz from collective.contentrules.mailfromfield.actions.mail import MailFromFieldAction -from datetime import date -from datetime import datetime -from datetime import timedelta from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles from plone.contentrules.rule.interfaces import IExecutable from Products.CMFCore.WorkflowCore import ActionSucceededEvent -from redturtle.prenotazioni.adapters.booker import IBooker -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 -import email -import pytz -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING @implementer(IObjectEvent) diff --git a/src/redturtle/prenotazioni/tests/test_prenotazione_events.py b/src/redturtle/prenotazioni/tests/test_prenotazione_events.py index 68efce04..36d731dd 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazione_events.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazione_events.py @@ -1,20 +1,18 @@ # -*- coding: UTF-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import email +import unittest +from datetime import date, datetime, timedelta + +import pytz from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING +from plone.app.testing import TEST_USER_ID, setRoles from zope.event import notify from zope.interface import implementer from zope.interface.interfaces import IObjectEvent -import email -import pytz -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING @implementer(IObjectEvent) 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 1cd69594..322333fc 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazione_searchable_item_serializer.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import timedelta +import unittest +from datetime import date, timedelta + from dateutil import parser from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles from plone.restapi.serializer.converters import json_compatible -from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING from zope.component import getMultiAdapter from zope.globalrequest import getRequest from zope.i18n import translate -import unittest +from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING class TestPrenotazioniSearch(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py b/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py index b8f73638..eb3b9ce7 100644 --- a/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py +++ b/src/redturtle/prenotazioni/tests/test_prenotazioni_search.py @@ -1,22 +1,24 @@ # -*- coding: utf-8 -*- +import unittest from copy import deepcopy -from datetime import date -from datetime import timedelta -from dateutil import parser +from datetime import date, timedelta from io import BytesIO + +import openpyxl +import transaction +from dateutil import parser from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID -from plone.app.testing import TEST_USER_PASSWORD +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + TEST_USER_PASSWORD, + setRoles, +) from plone.restapi.testing import RelativeSession from plone.testing.zope import Browser -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING -import openpyxl -import transaction -import unittest +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING class TestPrenotazioniSearch(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_send_ical.py b/src/redturtle/prenotazioni/tests/test_send_ical.py index 433d9fc9..bc10a79b 100644 --- a/src/redturtle/prenotazioni/tests/test_send_ical.py +++ b/src/redturtle/prenotazioni/tests/test_send_ical.py @@ -1,25 +1,23 @@ # -*- coding: UTF-8 -*- # TODO: Evaluate if we can join the prenotazioni event tests with the tests below so # as now the ical is being added in the templates adaptes used py plone event +import base64 +import email +import unittest +from datetime import date, datetime, timedelta + from collective.contentrules.mailfromfield.actions.mail import MailFromFieldAction -from datetime import date -from datetime import datetime -from datetime import timedelta from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles from plone.contentrules.rule.interfaces import IExecutable 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 zope.component import getMultiAdapter from zope.interface import implementer from zope.interface.interfaces import IObjectEvent -import base64 -import email -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.prenotazione_event import MovedPrenotazione +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING @implementer(IObjectEvent) diff --git a/src/redturtle/prenotazioni/tests/test_setup.py b/src/redturtle/prenotazioni/tests/test_setup.py index 45e43231..100fa701 100644 --- a/src/redturtle/prenotazioni/tests/test_setup.py +++ b/src/redturtle/prenotazioni/tests/test_setup.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -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 - import unittest +from plone import api +from plone.app.testing import TEST_USER_ID, setRoles + +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_INTEGRATION_TESTING try: from Products.CMFPlone.utils import get_installer @@ -40,6 +39,7 @@ def test_product_installed(self): def test_browserlayer(self): """Test that IRedturtlePrenotazioniLayer is registered.""" from plone.browserlayer import utils + from redturtle.prenotazioni.interfaces import IRedturtlePrenotazioniLayer self.assertIn(IRedturtlePrenotazioniLayer, utils.registered_layers()) @@ -87,6 +87,7 @@ 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 self.assertNotIn(IRedturtlePrenotazioniLayer, utils.registered_layers()) diff --git a/src/redturtle/prenotazioni/tests/test_stringinterp.py b/src/redturtle/prenotazioni/tests/test_stringinterp.py index 3fb1ebf6..146d5952 100644 --- a/src/redturtle/prenotazioni/tests/test_stringinterp.py +++ b/src/redturtle/prenotazioni/tests/test_stringinterp.py @@ -1,17 +1,15 @@ # -*- coding: UTF-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta +import unittest +from datetime import date, datetime, timedelta + +import pytz from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_ID, setRoles from plone.stringinterp.interfaces import IStringSubstitution -from redturtle.prenotazioni.adapters.booker import IBooker -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING from zope.component import getAdapter -import pytz -import unittest +from redturtle.prenotazioni.adapters.booker import IBooker +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING class TestStringInterp(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_utils.py b/src/redturtle/prenotazioni/tests/test_utils.py index dff0be74..63329e87 100644 --- a/src/redturtle/prenotazioni/tests/test_utils.py +++ b/src/redturtle/prenotazioni/tests/test_utils.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -from redturtle.prenotazioni import datetime_with_tz -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +import unittest import pytz -import unittest + +from redturtle.prenotazioni import datetime_with_tz +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING class TestUtils(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_vacation_api.py b/src/redturtle/prenotazioni/tests/test_vacation_api.py index 772299b6..4d9db774 100644 --- a/src/redturtle/prenotazioni/tests/test_vacation_api.py +++ b/src/redturtle/prenotazioni/tests/test_vacation_api.py @@ -1,18 +1,19 @@ # -*- coding: utf-8 -*- -from datetime import date -from datetime import datetime -from datetime import timedelta -from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID -from plone.restapi.testing import RelativeSession -from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING +import unittest +from datetime import date, datetime, timedelta import pytz import transaction -import unittest +from plone import api +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) +from plone.restapi.testing import RelativeSession + +from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING class TestVacationgApi(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/tests/test_week_table_overrides.py b/src/redturtle/prenotazioni/tests/test_week_table_overrides.py index 1e0a6271..dcaf22e9 100644 --- a/src/redturtle/prenotazioni/tests/test_week_table_overrides.py +++ b/src/redturtle/prenotazioni/tests/test_week_table_overrides.py @@ -1,17 +1,22 @@ # -*- coding: utf-8 -*- +import json +import unittest from datetime import date + from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.serializer.converters import json_compatible 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 -import json -import unittest +from redturtle.prenotazioni.testing import ( + REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING, + REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING, +) class TestContextState(unittest.TestCase): diff --git a/src/redturtle/prenotazioni/upgrades.py b/src/redturtle/prenotazioni/upgrades.py index 979c93d9..b65887bf 100644 --- a/src/redturtle/prenotazioni/upgrades.py +++ b/src/redturtle/prenotazioni/upgrades.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +import logging + +import pytz from plone import api from plone.app.contentrules.actions.workflow import WorkflowAction from plone.app.contentrules.conditions.portaltype import PortalTypeCondition @@ -8,14 +11,10 @@ from plone.app.upgrade.utils import loadMigrationProfile from plone.app.workflow.remap import remap_workflow from plone.contentrules.engine.interfaces import IRuleStorage +from zope.component import getUtility, queryUtility + from redturtle.prenotazioni import _ from redturtle.prenotazioni.events.prenotazione import set_booking_code -from zope.component import getUtility -from zope.component import queryUtility - -import logging -import pytz - logger = logging.getLogger(__name__) @@ -300,8 +299,10 @@ def to_1600_popolate_templates(context): def to_1600_upgrade_contentrules(context): - from plone.contentrules.engine.interfaces import IRuleAssignmentManager - from plone.contentrules.engine.interfaces import IRuleStorage + from plone.contentrules.engine.interfaces import ( + IRuleAssignmentManager, + IRuleStorage, + ) rules_to_delete = [ "booking-accepted", diff --git a/src/redturtle/prenotazioni/utilities/dateutils.py b/src/redturtle/prenotazioni/utilities/dateutils.py index a91cb717..72612721 100644 --- a/src/redturtle/prenotazioni/utilities/dateutils.py +++ b/src/redturtle/prenotazioni/utilities/dateutils.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -from datetime import datetime -from datetime import time -from datetime import timedelta -from plone.app.event.base import default_timezone -from redturtle.prenotazioni import tznow +from datetime import datetime, time, timedelta import six +from plone.app.event.base import default_timezone + +from redturtle.prenotazioni import tznow def hm2handm(hm): diff --git a/src/redturtle/prenotazioni/utilities/urls.py b/src/redturtle/prenotazioni/utilities/urls.py index a22a36af..03e86a7a 100644 --- a/src/redturtle/prenotazioni/utilities/urls.py +++ b/src/redturtle/prenotazioni/utilities/urls.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -from six.moves.urllib.parse import urlencode - import six +from six.moves.urllib.parse import urlencode def urlify(url="", paths=[], params={}): diff --git a/src/redturtle/prenotazioni/utils/migration.py b/src/redturtle/prenotazioni/utils/migration.py index 595d3e36..4aad2396 100644 --- a/src/redturtle/prenotazioni/utils/migration.py +++ b/src/redturtle/prenotazioni/utils/migration.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from zope.globalrequest import getRequest - try: from collective.exportimport.interfaces import IMigrationMarker except ImportError: diff --git a/src/redturtle/prenotazioni/viewlets/app_io.py b/src/redturtle/prenotazioni/viewlets/app_io.py index e5240970..7f67345e 100644 --- a/src/redturtle/prenotazioni/viewlets/app_io.py +++ b/src/redturtle/prenotazioni/viewlets/app_io.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- from plone.app.layout.viewlets.common import ViewletBase -from redturtle.prenotazioni.config import NOTIFICATIONS_LOGS from zope.annotation.interfaces import IAnnotations +from redturtle.prenotazioni.config import NOTIFICATIONS_LOGS + class Viewlet(ViewletBase): def available(self): diff --git a/src/redturtle/prenotazioni/vocabularies/gates.py b/src/redturtle/prenotazioni/vocabularies/gates.py index 80dab940..f660ec0f 100644 --- a/src/redturtle/prenotazioni/vocabularies/gates.py +++ b/src/redturtle/prenotazioni/vocabularies/gates.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary @implementer(IVocabularyFactory) diff --git a/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py b/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py index 9ffde5a9..7768d53d 100644 --- a/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py +++ b/src/redturtle/prenotazioni/vocabularies/requirable_booking_fields.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from redturtle.prenotazioni import _ -from redturtle.prenotazioni.config import REQUIRABLE_AND_VISIBLE_FIELDS from zope.i18n import translate from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary + +from redturtle.prenotazioni import _ +from redturtle.prenotazioni.config import REQUIRABLE_AND_VISIBLE_FIELDS @implementer(IVocabularyFactory) diff --git a/src/redturtle/prenotazioni/vocabularies/tipologies.py b/src/redturtle/prenotazioni/vocabularies/tipologies.py index 79fb4e24..f76c7bf1 100644 --- a/src/redturtle/prenotazioni/vocabularies/tipologies.py +++ b/src/redturtle/prenotazioni/vocabularies/tipologies.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from redturtle.prenotazioni.content.prenotazione import Prenotazione from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary + +from redturtle.prenotazioni.content.prenotazione import Prenotazione @implementer(IVocabularyFactory) diff --git a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py index fdc7fe44..5672183d 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py @@ -6,8 +6,7 @@ from zope.globalrequest import getRequest from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary class VocabItem(object): diff --git a/src/redturtle/prenotazioni/vocabularies/voc_months.py b/src/redturtle/prenotazioni/vocabularies/voc_months.py index cb449950..6fdca630 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_months.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_months.py @@ -2,8 +2,7 @@ from plone import api from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary @implementer(IVocabularyFactory) diff --git a/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py b/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py index e379b6ad..92e5ac59 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_ore_inizio.py @@ -3,8 +3,7 @@ from zope.globalrequest import getRequest from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary class VocabItem(object):