From 640c12f7215dbb725885692b3f3e2f0e14376485 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Sun, 27 Feb 2022 18:19:58 +0100 Subject: [PATCH] Reformat --- aleksis/apps/chronos/model_extensions.py | 5 +---- aleksis/apps/chronos/preferences.py | 9 ++++++--- aleksis/apps/chronos/util/notifications.py | 12 +++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/aleksis/apps/chronos/model_extensions.py b/aleksis/apps/chronos/model_extensions.py index ce6c1810..1cbe2eca 100644 --- a/aleksis/apps/chronos/model_extensions.py +++ b/aleksis/apps/chronos/model_extensions.py @@ -1,10 +1,7 @@ -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 diff --git a/aleksis/apps/chronos/preferences.py b/aleksis/apps/chronos/preferences.py index 7b3857c0..c76e6752 100644 --- a/aleksis/apps/chronos/preferences.py +++ b/aleksis/apps/chronos/preferences.py @@ -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 diff --git a/aleksis/apps/chronos/util/notifications.py b/aleksis/apps/chronos/util/notifications.py index 25216a2e..2c7d7dbc 100644 --- a/aleksis/apps/chronos/util/notifications.py +++ b/aleksis/apps/chronos/util/notifications.py @@ -1,14 +1,15 @@ 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() -- GitLab