Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #161

Closed
wants to merge 120 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
bfc5913
Fix notification subject for managers
cekk Dec 7, 2023
48f6f7d
update changelog
cekk Dec 11, 2023
56fd73d
Merge branch 'master' into fix_manager_subject
cekk Dec 11, 2023
888d02e
remove fuzzty
cekk Dec 11, 2023
397270f
Update the booking type length min value
folix-01 Dec 11, 2023
7fac29d
Merge remote-tracking branch 'origin/fix_manager_subject' into staging
folix-01 Dec 11, 2023
88cbcec
update string
cekk Dec 11, 2023
b88ac51
Merge branch 'staging' of github.com:RedTurtle/redturtle.prenotazioni…
cekk Dec 11, 2023
111af5b
Merge branch 'master' into fix_manager_subject
cekk Dec 12, 2023
5b883c8
fix test
cekk Dec 12, 2023
4da79c4
feat: Booking Managers bypass futureDays checks when create new bookings
cekk Dec 12, 2023
0a127a6
Merge branch 'master' into staging
cekk Dec 12, 2023
60bfcbf
Merge branch 'bypass_future_days_feat' into staging
cekk Dec 12, 2023
eb1975f
Remove duplicated method in booker: create. Now there is only .
cekk Dec 13, 2023
339e536
Merge branch 'bypass_future_days_feat' into staging
cekk Dec 13, 2023
e6946ec
Booking notfications refactor + reminders
folix-01 Dec 7, 2023
dd52d95
Some fixes and removed old appIO field (#142)
cekk Dec 11, 2023
cc1024f
Update sms limit
folix-01 Dec 11, 2023
1769de7
Refactoring
folix-01 Dec 11, 2023
c30581e
Refactoring
folix-01 Dec 11, 2023
2a65c07
Notifications labels fix (#145)
cekk Dec 12, 2023
06ee77a
fix fieldsets
cekk Dec 12, 2023
27a3520
Refactoring
folix-01 Dec 13, 2023
9ac2e7a
Update readme
folix-01 Dec 13, 2023
798daae
Fix readme
folix-01 Dec 13, 2023
85438ca
Add flag that allows to automatically confirm bookings created by Bo…
cekk Dec 13, 2023
6c17d41
Update schema
folix-01 Dec 13, 2023
866e852
update translations
cekk Dec 13, 2023
81e0dc5
Merge branch 'auto_confirm_manager_flag' into staging
cekk Dec 13, 2023
264d0f8
Fux AppIO call
folix-01 Dec 14, 2023
305c2be
Fix AppIO call
folix-01 Dec 14, 2023
e71a373
Fix AppIO subscription check
folix-01 Dec 14, 2023
fb53485
Fix AppIO call
folix-01 Dec 14, 2023
c7d9455
Use the logstorage for appio api call
folix-01 Dec 14, 2023
d963152
fix message
cekk Dec 14, 2023
631a945
Merge branch 'fix_manager_subject' into staging
cekk Dec 14, 2023
50ba881
fix test
cekk Dec 14, 2023
a57d469
Merge branch 'fix_manager_subject' into staging
cekk Dec 14, 2023
3cd9c0a
add docstring
cekk Dec 14, 2023
3e3aaca
Merge branch 'fix_manager_subject' into staging
cekk Dec 14, 2023
ebd90d9
Update notification_sms.py
folix-01 Dec 15, 2023
32ed5b5
Update locales
folix-01 Dec 18, 2023
2b2d93c
Update locales
folix-01 Dec 18, 2023
bf34180
Hide PrenotazioniYear in add menu for restapi.
cekk Dec 18, 2023
8a042b4
Merge branch 'master' into staging
cekk Dec 18, 2023
fde4b89
Merge branch 'hide_prenotazioni_year' into staging
cekk Dec 18, 2023
9919fa5
Fix notifications supervisor logics
folix-01 Dec 18, 2023
7278180
Fix
folix-01 Dec 18, 2023
701f899
Update messages
folix-01 Dec 18, 2023
20461ef
Fix
folix-01 Dec 18, 2023
98e9ac3
Fix code
folix-01 Dec 18, 2023
d85d2ec
Fix locales
folix-01 Dec 18, 2023
d921398
Remove sms max length
folix-01 Dec 18, 2023
d77fb80
Fix
folix-01 Dec 18, 2023
fd42eb2
Fix locales
folix-01 Dec 18, 2023
51335ee
Force booking notification to managers
folix-01 Dec 19, 2023
5321e60
Turn off the AppIO notifications integration by default
folix-01 Dec 19, 2023
969e5d0
Fix naming
folix-01 Dec 20, 2023
d66f5f2
Fix naming
folix-01 Dec 20, 2023
a17c2f8
Fix namin g
folix-01 Dec 20, 2023
b7d1dcc
Merge branch 'master' into staging
cekk Dec 22, 2023
f03758f
Use the holidays constraint
folix-01 Dec 22, 2023
a551cb0
Merge branch 'validate_holidays' into staging
folix-01 Dec 22, 2023
053f635
Add the booking creation and modification date to booking serializer
folix-01 Dec 22, 2023
3e14087
Tests
folix-01 Dec 22, 2023
cd7f1ba
Merge branch 'booking_serializer_extend' into staging
folix-01 Dec 27, 2023
9301193
Update readme
folix-01 Dec 29, 2023
017671e
Update readme
folix-01 Dec 29, 2023
e86af04
typo
mamico Jan 3, 2024
cd3e0ba
merge
mamico Jan 3, 2024
09a595f
version
mamico Jan 3, 2024
126d16f
fix tests
mamico Jan 3, 2024
e0e4659
fix tests
mamico Jan 3, 2024
7babdb8
cleanup
mamico Jan 3, 2024
0f52aff
fix readme + demo profile
mamico Jan 3, 2024
01dfa4d
Merge branch 'notifications_heavy_refactoring' into staging
mamico Jan 3, 2024
823abb9
locales
mamico Jan 3, 2024
212544f
zpretty
mamico Jan 3, 2024
b03c874
logging
mamico Jan 3, 2024
ddd0bce
Merge branch 'notifications_heavy_refactoring' into staging
mamico Jan 3, 2024
2fe523c
fix demo + readme
mamico Jan 3, 2024
a96866c
Merge branch 'notifications_heavy_refactoring' into staging
mamico Jan 3, 2024
d7a7c4a
typo
mamico Jan 3, 2024
97a288a
feat: aggiunte info alle prenotazioni sull ufficio
mamico Jan 4, 2024
ba25092
Merge branch 'us_50362' into staging
mamico Jan 4, 2024
a43ec5f
cleanup
mamico Jan 4, 2024
fee6f4d
Merge branch 'master' into staging
mamico Jan 5, 2024
3e0dead
Add customizable email from in PrenotazioniFolder contents
cekk Jan 8, 2024
842e33e
Merge branch 'customizable_from_address' into staging
cekk Jan 8, 2024
4651473
fix: performance
mamico Jan 8, 2024
16786cd
fix
mamico Jan 8, 2024
1639caa
address
mamico Jan 9, 2024
b20d263
Merge branch 'us_50362' into staging
mamico Jan 9, 2024
e22b9e7
black
mamico Jan 9, 2024
05ebef3
Merge branch 'us_50362' into staging
mamico Jan 9, 2024
dba57a5
Inherit Booking moved event from the ObjectModifiedEvent
folix-01 Jan 9, 2024
4fe14b9
Merge branch 'booking_serializer_extend' into staging
folix-01 Jan 9, 2024
2ee330d
BBB
mamico Jan 9, 2024
0bb5823
BBB
mamico Jan 9, 2024
1e05a1c
Fix @available-slots view performance
folix-01 Jan 10, 2024
321ef83
Merge branch 'available_slots_performance' into staging
folix-01 Jan 10, 2024
572d9ea
Add cachetools dependency
folix-01 Jan 10, 2024
c758623
Merge branch 'available_slots_performance' into staging
folix-01 Jan 10, 2024
9fbad28
Use plone.memoize.forever
folix-01 Jan 10, 2024
0e4bfd7
Merge branch 'available_slots_performance' into staging
folix-01 Jan 10, 2024
f591c91
Comment
folix-01 Jan 10, 2024
2e32fec
Fix tests
folix-01 Jan 10, 2024
bbc0b14
Merge branch 'available_slots_performance' into staging
folix-01 Jan 10, 2024
1a8967c
Merge branch 'master' into staging
mamico Jan 11, 2024
5ed027e
Use 5min interval for pausa
folix-01 Jan 11, 2024
0b987ff
Merge branch '5_min_pause' into staging
folix-01 Jan 11, 2024
3ab53cb
Fix hour format
folix-01 Jan 11, 2024
426d915
Merge branch '5_min_pause' into staging
folix-01 Jan 11, 2024
c20cb96
Pause invariant validation
folix-01 Jan 11, 2024
eb3c261
Pass to validator invariant usage
folix-01 Jan 11, 2024
46c02fc
Flake8 requirements
folix-01 Jan 11, 2024
f3e0e4d
Merge branch '5_min_pause' into staging
folix-01 Jan 11, 2024
399e033
Test and fixes
folix-01 Jan 12, 2024
4d33cc7
Merge branch '5_min_pause' into staging
folix-01 Jan 12, 2024
600e9a7
Merge branch 'master' into staging
mamico Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Changelog
- Update the min booking type length value to 5min.
[folix-01]

- Improve manager mail notification subject to include also name and date.
[cekk]
- Fix: hidden attribute in tipologia
[mamico]

Expand All @@ -110,6 +112,8 @@ Changelog

- Remove duplicated method in booker: create. Now there is only `book`.
[cekk]
- Add flag `auto_confirm_manager` that allows to automatically confirm bookings created by Booking Managers.
[cekk]

- Hide PrenotazioniYear in add menu for restapi.
[cekk]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,4 @@ def message_text(self) -> MIMEText:
return MIMEText(text, "html", cs)
else:
return MIMEText(text, "html")

Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __call__(self, *args, **kwargs):
booking_expiration_date = booking_expiration_date.replace(
booking_date.year, booking_date.month, booking_date.day
)

return {
"@id": self.prenotazione.absolute_url(),
"UID": self.prenotazione.UID(),
Expand Down
5 changes: 2 additions & 3 deletions src/redturtle/prenotazioni/restapi/services/types/get.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder
from plone.restapi.interfaces import IExpandableElement
from plone.restapi.services.types.get import TypesInfo
from zope.component import adapter
from zope.interface import Interface
from zope.interface import implementer

from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder
from zope.interface import Interface


@implementer(IExpandableElement)
Expand Down
119 changes: 61 additions & 58 deletions src/redturtle/prenotazioni/tests/test_add_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ def setUp(self):
row["morning_end"] = "1000"
self.folder_prenotazioni.week_table = week_table

api.content.transition(obj=self.folder_prenotazioni, transition="publish")
api.content.transition(obj=type_a, transition="publish")

def create_booking(self, data: dict):
booker = IBooker(self.folder_prenotazioni)
return booker.book(data)
Expand Down Expand Up @@ -463,6 +466,64 @@ def test_booking_code_uniqueness(self):

self.assertNotEqual(booking_1.getBookingCode(), booking_2.getBookingCode())

@freeze_time(DATE_STR) # far from holidays
def test_booker_disallow_anon_creation_if_futureDays_is_set_and_passed(self):
today = date.today()
self.folder_prenotazioni.daData = today
self.folder_prenotazioni.futureDays = 6

logout()

with self.assertRaises(BookerException) as cm:
self.create_booking(
data={
"booking_date": datetime.fromisoformat(today.isoformat())
+ timedelta(hours=8, days=8),
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(
"Sorry, you can not book this slot for now.", str(cm.exception)
)

# but can create a book inside range
future_date = datetime.fromisoformat(today.isoformat()) + timedelta(
hours=8, days=5
)
book = self.create_booking(
data={
"booking_date": future_date,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(book.booking_date.date(), future_date.date())

@freeze_time(DATE_STR) # far from holidays
def test_booker_bypass_futureDays_check_if_manager(self):
today = date.today()
self.folder_prenotazioni.daData = today
self.folder_prenotazioni.futureDays = 6

logout()
login(self.portal, "jdoe")

future_date = datetime.fromisoformat(today.isoformat()) + timedelta(
hours=8, days=8
)
book = self.create_booking(
data={
"booking_date": future_date,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(book.booking_date.date(), future_date.date())

def test_booker_auto_confirm_manager_true_by_default(self):
folder_prenotazioni = api.content.create(
container=self.portal,
Expand Down Expand Up @@ -650,61 +711,3 @@ def test_booker_auto_confirm_manager_called_by_anon_does_nothing(self):
)

self.assertEqual(api.content.get_state(obj=booking), "pending")

@freeze_time(DATE_STR) # far from holidays
def test_booker_disallow_anon_creation_if_futureDays_is_set_and_passed(self):
today = date.today()
self.folder_prenotazioni.daData = today
self.folder_prenotazioni.futureDays = 6

logout()

with self.assertRaises(BookerException) as cm:
self.create_booking(
data={
"booking_date": datetime.fromisoformat(today.isoformat())
+ timedelta(hours=8, days=8),
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(
"Sorry, you can not book this slot for now.", str(cm.exception)
)

# but can create a book inside range
future_date = datetime.fromisoformat(today.isoformat()) + timedelta(
hours=8, days=5
)
book = self.create_booking(
data={
"booking_date": future_date,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(book.booking_date.date(), future_date.date())

@freeze_time(DATE_STR) # far from holidays
def test_booker_bypass_futureDays_check_if_manager(self):
today = date.today()
self.folder_prenotazioni.daData = today
self.folder_prenotazioni.futureDays = 6

logout()
login(self.portal, "jdoe")

future_date = datetime.fromisoformat(today.isoformat()) + timedelta(
hours=8, days=8
)
book = self.create_booking(
data={
"booking_date": future_date,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
}
)
self.assertEqual(book.booking_date.date(), future_date.date())
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# -*- coding: UTF-8 -*-
import unittest
from datetime import date
from datetime import datetime
from datetime import timedelta

import pytz
from plone import api
from plone.app.testing import TEST_USER_ID
from plone.app.testing import setRoles

from redturtle.prenotazioni.adapters.booker import IBooker
from redturtle.prenotazioni.behaviors.booking_folder import (
BookingNotificationSupervisorUtility,
)
from redturtle.prenotazioni.testing import (
REDTURTLE_PRENOTAZIONI_API_INTEGRATION_TESTING,
)


class TestBookingNotificationSupervisorUtility(unittest.TestCase):
layer = REDTURTLE_PRENOTAZIONI_API_INTEGRATION_TESTING
timezone = "Europe/Rome"

def setUp(self):
self.app = self.layer["app"]
self.portal = self.layer["portal"]
self.mailhost = self.portal.MailHost
self.email_subject = "Testing subject"
self.email_message = "Testing message"
self.supervisor = BookingNotificationSupervisorUtility()

setRoles(self.portal, TEST_USER_ID, ["Manager"])

self.folder_prenotazioni = api.content.create(
container=self.portal,
type="PrenotazioniFolder",
title="Prenota foo",
description="",
daData=date.today(),
gates=["Gate A"],
)

api.content.create(
type="PrenotazioneType",
title="Type A",
duration=30,
container=self.folder_prenotazioni,
gates=["all"],
)

self.today_8_0 = self.dt_local_to_utc(
datetime.now().replace(hour=8, minute=0, second=0, microsecond=0)
)
self.tomorrow_8_0 = self.today_8_0 + timedelta(1)
week_table = self.folder_prenotazioni.week_table
for data in week_table:
data["morning_start"] = "0700"
data["morning_end"] = "1000"
self.folder_prenotazioni.week_table = week_table

api.portal.set_registry_record(
"plone.portal_timezone",
self.timezone,
)

self.booking = self.create_booking()

def dt_local_to_utc(self, value):
return pytz.timezone(self.timezone).localize(value).astimezone(pytz.utc)

def create_booking(self, booking_date=None):
booker = IBooker(self.folder_prenotazioni)
if booking_date is None:
booking_date = self.tomorrow_8_0
return booker.book(
{
"booking_date": booking_date,
"booking_type": "Type A",
"title": "foo",
"email": "[email protected]",
"fiscalcode": "FISCALCODE",
"phone": "1111111111",
}
)

def test_is_email_message_allowed_positive(self):
self.folder_prenotazioni.notifications_email_enabled = True

self.assertTrue(self.supervisor.is_email_message_allowed(self.booking))

def test_is_email_message_allowed_positive_negative(self):
self.folder_prenotazioni.notifications_email_enabled = False

self.assertFalse(self.supervisor.is_email_message_allowed(self.booking))

# No email provided

self.folder_prenotazioni.notifications_email_enabled = True
self.booking.email = None

self.assertFalse(self.supervisor.is_appio_message_allowed(self.booking))

def test_is_appio_message_allowed_positive(self):
self.folder_prenotazioni.notifications_appio_enabled = True

# Mock the AppIo subscription check
self.supervisor._check_user_appio_subscription_to_booking_type = (
lambda booking: True
)

self.assertTrue(self.supervisor.is_appio_message_allowed(self.booking))

def test_is_appio_message_allowed_negative(self):
# Mock the AppIO subscription check
self.supervisor._check_user_appio_subscription_to_booking_type = (
lambda booking: True
)

self.folder_prenotazioni.notifications_appio_enabled = False

self.assertFalse(self.supervisor.is_appio_message_allowed(self.booking))

# No fiscalcode provided
self.folder_prenotazioni.notifications_appio_enabled = True
self.booking.fiscalcode = None

self.assertFalse(self.supervisor.is_appio_message_allowed(self.booking))

# User has no AppIO service subscription
self.supervisor._check_user_appio_subscription_to_booking_type = (
lambda booking: False
)
self.booking.fiscalcode = "FISCALCODE"

self.assertFalse(self.supervisor.is_appio_message_allowed(self.booking))

def test_is_sms_message_allowed_positive(self):
self.supervisor.is_email_message_allowed = lambda booking: False
self.supervisor.is_appio_message_allowed = lambda booking: False
self.folder_prenotazioni.notifications_sms_enabled = True

self.assertTrue(self.supervisor.is_sms_message_allowed(self.booking))

def test_is_sms_message_allowed_negative(self):
# Flag is False
self.supervisor.is_email_message_allowed = lambda booking: True
self.supervisor.is_appio_message_allowed = lambda booking: True
self.folder_prenotazioni.notifications_sms_enabled = False

self.assertFalse(self.supervisor.is_sms_message_allowed(self.booking))

# Email notification is allowed
self.supervisor.is_email_message_allowed = lambda booking: True
self.supervisor.is_appio_message_allowed = lambda booking: False
self.folder_prenotazioni.notifications_sms_enabled = True

self.assertFalse(self.supervisor.is_sms_message_allowed(self.booking))

# AppIO notification is allowed
self.supervisor.is_email_message_allowed = lambda booking: False
self.supervisor.is_appio_message_allowed = lambda booking: True
self.folder_prenotazioni.notifications_sms_enabled = True

self.assertFalse(self.supervisor.is_sms_message_allowed(self.booking))

# No phone number was provided
self.supervisor.is_email_message_allowed = lambda booking: True
self.supervisor.is_appio_message_allowed = lambda booking: True
self.folder_prenotazioni.notifications_sms_enabled = True

self.booking.phone = None

self.assertFalse(self.supervisor.is_sms_message_allowed(self.booking))
Loading