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

Reformat

parent 3a28ee0b
No related branches found
No related tags found
1 merge request!242Resolve "Notification for changes in the substitution plan"
import zoneinfo
from datetime import date, timedelta
from datetime import date
from typing import Optional, Union
from django.conf import settings
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from jsonstore import BooleanField
......
......@@ -78,6 +78,7 @@ class DaysInAdvanceNotifications(IntegerPreference):
default = 1
verbose_name = _("How many days in advance users should be notified about timetable changes?")
@site_preferences_registry.register
class TimeForSendingNotifications(TimePreference):
section = chronos
......@@ -85,9 +86,11 @@ class TimeForSendingNotifications(TimePreference):
default = time(17, 00)
verbose_name = _("Time for sending notifications about timetable changes")
required = True
help_text = _("This is only used for scheduling notifications "
"which doesn't affect the time period configured above. "
"All other notifications affecting the next days are sent immediately.")
help_text = _(
"This is only used for scheduling notifications "
"which doesn't affect the time period configured above. "
"All other notifications affecting the next days are sent immediately."
)
@site_preferences_registry.register
......
import zoneinfo
from datetime import datetime, timedelta
from typing import Union
from urllib.parse import urljoin
from django.conf import settings
from django.urls import reverse
from django.utils import timezone
from django.utils.formats import date_format
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext
from django.utils import timezone
from datetime import timedelta, datetime
from aleksis.core.models import Notification, Person
from aleksis.core.util.core_helpers import get_site_preferences
......@@ -194,8 +195,9 @@ def send_notifications_for_object(
send_at = timezone.now()
else:
# Schedule for later
send_at = datetime.combine(dt_start.date() - timedelta(days=number_of_days), send_time).replace(tzinfo=zoneinfo.ZoneInfo(settings.TIME_ZONE))
send_at = datetime.combine(
dt_start.date() - timedelta(days=number_of_days), send_time
).replace(tzinfo=zoneinfo.ZoneInfo(settings.TIME_ZONE))
for recipient in recipients:
if recipient.preferences["chronos__send_notifications"]:
......@@ -205,6 +207,6 @@ def send_notifications_for_object(
title=_("There are current changes to your timetable."),
description=description,
link=url,
send_at=send_at
send_at=send_at,
)
n.save()
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