Skip to content
Snippets Groups Projects
Verified Commit d0b7fcaa authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add preferences for timetable change notifications

parent 637d35d9
No related branches found
No related tags found
1 merge request!242Resolve "Notification for changes in the substitution plan"
......@@ -171,6 +171,9 @@ Person.add_permission(
@receiver(timetable_data_changed)
def send_notifications(sender: Revision, **kwargs):
"""Send notifications to users about the changes."""
if not get_site_preferences()["chronos__send_notifications"]:
return
for change in sender.changes.values():
if change.deleted:
continue
......@@ -360,11 +363,12 @@ def send_notifications(sender: Revision, **kwargs):
)
for recipient in recipients:
n = Notification(
recipient=recipient,
sender=_("Timetable"),
title=_("There are current changes to your timetable."),
description=description,
link=url,
)
n.save()
if recipient.preferences["chronos__send_notifications"]:
n = Notification(
recipient=recipient,
sender=_("Timetable"),
title=_("There are current changes to your timetable."),
description=description,
link=url,
)
n.save()
......@@ -78,3 +78,19 @@ class TimeForSendingNotifications(TimePreference):
default = time(17, 00)
verbose_name = _("Time for sending notifications for the next day")
required = True
@site_preferences_registry.register
class SendNotifications(BooleanPreference):
section = chronos
name = "send_notifications"
default = True
verbose_name = _("Send notifications for current timetable changes")
@person_preferences_registry.register
class SendNotificationsPerson(BooleanPreference):
section = chronos
name = "send_notifications"
default = True
verbose_name = _("Send notifications for current timetable changes")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment