Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src/onegov/org/cronjobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,11 @@ def send_monthly_ticket_statistics(request: OrgRequest) -> None:
)


@OrgApp.cronjob(hour=6, minute=5, timezone='Europe/Zurich')
@OrgApp.cronjob(hour='*', minute='*/5', timezone='Europe/Zurich')
def send_daily_resource_usage_overview(request: OrgRequest) -> None:
today = to_timezone(utcnow(), 'Europe/Zurich')
weekday = WEEKDAYS[today.weekday()]
current_time = f'{today.hour:02d}:{today.minute:02d}'

# get all recipients which require an e-mail today
recipients_q = (
Expand All @@ -561,11 +562,13 @@ def send_daily_resource_usage_overview(request: OrgRequest) -> None:

# If the key 'daily_reservations' doesn't exist, the recipient was
# created before anything else was an option, therefore it must be true
# Legacy recipients without 'daily_reservations_times' default to 06:00.
recipients = [
(address, content['resources'])
for address, content in recipients_q
if content.get('daily_reservations', True)
and weekday in content['send_on']
and current_time in content.get('daily_reservations_times', ['06:00'])
]

if not recipients:
Expand Down
47 changes: 44 additions & 3 deletions src/onegov/org/forms/resource_recipient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import re

from onegov.form import Form
from onegov.form.fields import MultiCheckboxField
from onegov.form.fields import MultiCheckboxField, TagsField
from onegov.org import _
from onegov.reservation import Resource, ResourceCollection
from wtforms.fields import EmailField
Expand All @@ -15,6 +17,8 @@
from onegov.org.request import OrgRequest


_TIME_RE = re.compile(r'^([01]\d|2[0-3]):([0-5]\d)$')

WEEKDAYS = (
('MO', _('Mo')),
('TU', _('Tu')),
Expand Down Expand Up @@ -56,8 +60,8 @@ class ResourceRecipientForm(Form):
label=_('Daily Reservations'),
fieldset=_('Notifications *'),
description=_("On each day selected below, a notification with the "
"day's reservations will be sent to the recipient above "
"at 06:00."),
"day's reservations will be sent to the recipient "
"above."),
)

customer_messages = BooleanField(
Expand Down Expand Up @@ -93,13 +97,47 @@ class ResourceRecipientForm(Form):
render_kw={'prefix_label': False, 'class_': 'oneline-checkboxes'}
)

daily_reservations_times = TagsField(
label=_('Delivery Times'),
fieldset='Tage und Ressourcen',
description=_('e.g. 07:05'),
depends_on=('daily_reservations', 'y'),
)

resources = MultiCheckboxField(
label=_('Resources'),
fieldset='Tage und Ressourcen',
validators=[InputRequired()],
choices=None
)

def ensure_valid_delivery_times(self) -> bool | None:
if not self.daily_reservations.data:
return None

times = self.daily_reservations_times.data
if not times:
self.daily_reservations_times.errors.append( # type: ignore[attr-defined]
_('Please enter at least one delivery time.')
)
return False

for t in times:
m = _TIME_RE.match(t)
if not m:
self.daily_reservations_times.errors.append( # type: ignore[attr-defined]
_('Invalid time "${time}". Use HH:MM format (e.g. 06:00).',
mapping={'time': t})
)
return False
if int(m.group(2)) % 5 != 0:
self.daily_reservations_times.errors.append( # type: ignore[attr-defined]
_('Minutes must be a multiple of 5 (e.g. 06:10, 16:35).')
)
return False

return None

def ensure_at_least_one_notification(self) -> bool | None:
if not (
self.new_reservations.data
Expand All @@ -113,6 +151,9 @@ def ensure_at_least_one_notification(self) -> bool | None:
return None

def on_request(self) -> None:
if not self.request.POST and not self.daily_reservations_times.data:
self.daily_reservations_times.data = ['06:00'] # legacy default

default_group = self.request.translate(_('General'))

self.resources.choices = [
Expand Down
51 changes: 38 additions & 13 deletions src/onegov/org/locale/de_CH/LC_MESSAGES/onegov.org.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2026-06-11 11:12+0200\n"
"POT-Creation-Date: 2026-06-19 09:20+0200\n"
"PO-Revision-Date: 2022-03-15 10:21+0100\n"
"Last-Translator: Marc Sommerhalder <marc.sommerhalder@seantis.ch>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -1975,11 +1975,10 @@ msgstr "Tägliche Reservationen"

msgid ""
"On each day selected below, a notification with the day's reservations will "
"be sent to the recipient above at 06:00."
"be sent to the recipient above."
msgstr ""
"An jedem unten ausgewählten Tag wird eine Benachrichtigung mit den "
"Reservierungen des Tages um 06:00 Uhr an den oben genannten Empfänger "
"gesendet."
"Reservierungen des Tages an den oben genannten Empfänger gesendet."

msgid "Customer Messages"
msgstr "Kunden Nachrichten"
Expand All @@ -1992,9 +1991,6 @@ msgstr ""
"Reservierung hinzufügt, wird eine eine Benachrichtigung an den oben "
"genannten Empfänger gesendet."

msgid "Internal Comments"
msgstr "Internes Kommentarfeld"

msgid "Internal Notes"
msgstr "Interne Notizen"

Expand All @@ -2019,6 +2015,26 @@ msgstr ""
msgid "Send on"
msgstr "Senden am"

msgid "Delivery Times"
msgstr "Zustellungszeiten"

msgid "e.g. 07:05"
msgstr "z.B. 07:05"

#. type: ignore[attr-defined]
msgid "Please enter at least one delivery time."
msgstr "Bitte mindestens eine Zustellungszeit eingeben."

#. type: ignore[attr-defined]
#, python-format
msgid "Invalid time \"${time}\". Use HH:MM format (e.g. 06:00)."
msgstr ""
"Ungültige Zeit \"${time}\". Bitte im Format HH:MM eingeben (z.B. 06:00)."

#. type: ignore[attr-defined]
msgid "Minutes must be a multiple of 5 (e.g. 06:10, 16:35)."
msgstr "Minuten müssen ein Vielfaches von 5 sein (z.B. 06:10, 16:35)."

msgid "Please add at least one notification."
msgstr "Bitte wählen sie mindestens eine Benachrichtigung."

Expand Down Expand Up @@ -3735,9 +3751,6 @@ msgstr "Der Eintrag wurde übernommen"
msgid "The entry is not valid, please adjust it"
msgstr "Der Eintrag ist nicht gültig, bitte korrigieren"

msgid "An entry with this name already exists"
msgstr "Ein Eintrag mit diesem Namen existiert bereits"

msgid "Your directory submission has been adopted"
msgstr "Ihr Verzeichniseintrag wurde übernommen"

Expand Down Expand Up @@ -3907,6 +3920,12 @@ msgstr ""
msgid "Delete content"
msgstr "Inhalt löschen"

msgid "Internal Comments"
msgstr "Internes Kommentarfeld"

msgid "Administrative"
msgstr "Administrativ"

msgid "Photo album"
msgstr "Fotoalbum"

Expand Down Expand Up @@ -6523,9 +6542,6 @@ msgstr "Kunden-Login bestätigen"
msgid "A link was added to the clipboard"
msgstr "Ein Verweis wurde in die Zwischenablage kopiert"

msgid "Administrative"
msgstr "Administrativ"

msgid "Added a new directory"
msgstr "Ein neues Verzeichnis wurde hinzugefügt"

Expand Down Expand Up @@ -8029,6 +8045,15 @@ msgstr "Der Benutzer wurde erfolgreich erstellt"
msgid "Please enter your e-mail address in order to continue"
msgstr "Bitte geben Sie ihre E-Mail Adresse ein um fortzufahren"

#~ msgid "e.g. 07:00 or 07:00, 14:30"
#~ msgstr "z.B. 07:00 oder 07:00, 14:30"

#~ msgid "Minutes must be a multiple of 5 (e.g. 06:00, 06:30)."
#~ msgstr "Minuten müssen ein Vielfaches von 5 sein (z.B. 06:00, 06:30)."

#~ msgid "An entry with this name already exists"
#~ msgstr "Ein Eintrag mit diesem Namen existiert bereits"

#~ msgid "Back"
#~ msgstr "Zurück"

Expand Down
49 changes: 37 additions & 12 deletions src/onegov/org/locale/fr_CH/LC_MESSAGES/onegov.org.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2026-06-11 11:12+0200\n"
"POT-Creation-Date: 2026-06-19 09:20+0200\n"
"PO-Revision-Date: 2022-03-15 10:50+0100\n"
"Last-Translator: Marc Sommerhalder <marc.sommerhalder@seantis.ch>\n"
"Language-Team: French\n"
Expand Down Expand Up @@ -1979,10 +1979,10 @@ msgstr "Réservations quotidiennes"

msgid ""
"On each day selected below, a notification with the day's reservations will "
"be sent to the recipient above at 06:00."
"be sent to the recipient above."
msgstr ""
"Pour chaque jour sélectionné ci-dessous, une notification avec les "
"réservations du jour sera envoyée au destinataire ci-dessus à 6h00.."
"réservations du jour sera envoyée au destinataire ci-dessus."

msgid "Customer Messages"
msgstr "Messages des clients"
Expand All @@ -1994,9 +1994,6 @@ msgstr ""
"Chaque fois qu'un client ajoute un message au ticket pour une réservation, "
"une notification est envoyée au destinataire ci-dessus."

msgid "Internal Comments"
msgstr "Commentaires internes"

msgid "Internal Notes"
msgstr "Notes internes"

Expand All @@ -2020,6 +2017,25 @@ msgstr ""
msgid "Send on"
msgstr "Envoyer sur"

msgid "Delivery Times"
msgstr "Heures d'envoi"

msgid "e.g. 07:05"
msgstr "p.ex. 07:05"

#. type: ignore[attr-defined]
msgid "Please enter at least one delivery time."
msgstr "Veuillez saisir au moins une heure d'envoi."

#. type: ignore[attr-defined]
#, python-format
msgid "Invalid time \"${time}\". Use HH:MM format (e.g. 06:00)."
msgstr "Heure invalide \"${time}\". Utiliser le format HH:MM (p.ex. 06:00)."

#. type: ignore[attr-defined]
msgid "Minutes must be a multiple of 5 (e.g. 06:10, 16:35)."
msgstr "Les minutes doivent être un multiple de 5 (p.ex. 06:10, 16:35)."

msgid "Please add at least one notification."
msgstr "Veuillez ajouter au moins une notification."

Expand Down Expand Up @@ -3743,9 +3759,6 @@ msgstr "La proposition a été adoptée"
msgid "The entry is not valid, please adjust it"
msgstr "L'entrée n'est pas valide, veuillez la rectifier"

msgid "An entry with this name already exists"
msgstr "Une entrée du même nom existe déjà"

msgid "Your directory submission has been adopted"
msgstr "Votre proposition de répertoire a été adoptée"

Expand Down Expand Up @@ -3915,6 +3928,12 @@ msgstr ""
msgid "Delete content"
msgstr "Supprimer le contenu"

msgid "Internal Comments"
msgstr "Commentaires internes"

msgid "Administrative"
msgstr "Administratif"

msgid "Photo album"
msgstr "Album photo"

Expand Down Expand Up @@ -6538,9 +6557,6 @@ msgstr "Confirmer la connexion du client"
msgid "A link was added to the clipboard"
msgstr "Un lien a été ajouté au presse-papiers"

msgid "Administrative"
msgstr "Administratif"

msgid "Added a new directory"
msgstr "Ajout d'un nouveau dossier"

Expand Down Expand Up @@ -8040,6 +8056,15 @@ msgstr "L'utilisateur a bien été créé"
msgid "Please enter your e-mail address in order to continue"
msgstr "Veuillez saisir votre adresse e-mail pour continuer"

#~ msgid "e.g. 07:00 or 07:00, 14:30"
#~ msgstr "p.ex. 07:00 ou 07:00, 14:30"

#~ msgid "Minutes must be a multiple of 5 (e.g. 06:00, 06:30)."
#~ msgstr "Les minutes doivent être un multiple de 5 (p.ex. 06:00, 06:30)."

#~ msgid "An entry with this name already exists"
#~ msgstr "Une entrée du même nom existe déjà"

#~ msgid "Back"
#~ msgstr "Retour"

Expand Down
Loading
Loading