From 4b1b2b13a5b52d1ad2bd45c5f33451e93de6327d Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 20 May 2022 15:53:31 +0200 Subject: [PATCH] Fix timezone issue --- shiftregister/app/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shiftregister/app/models.py b/shiftregister/app/models.py index 99acf19..3c4891c 100644 --- a/shiftregister/app/models.py +++ b/shiftregister/app/models.py @@ -4,6 +4,7 @@ from django.shortcuts import reverse from datetime import timedelta from django.utils import timezone from django.db.models import F, Count, Q, ExpressionWrapper, Case, When +from django.template import Context, Template from phonenumber_field.modelfields import PhoneNumberField from dynamic_preferences.registries import global_preferences_registry @@ -137,7 +138,10 @@ class ShiftRegistration(models.Model): def send_reminder(self): url = reverse("shift", kwargs={"shiftid": self.shift.pk}) - text = f"Deine kontakt-Schicht beginnt um {self.shift.start_at.strftime('%H:%M')}, bitte komm 15 Minuten vorher an den Treffpunkt. https://kontakt.rocks{url}" + template = Template( + 'Deine kontakt-Schicht beginnt um {{ start_at|date:"H:i" }}, bitte komm 15 Minuten vorher an den Treffpunkt. https://kontakt.rocks{{ url }}' + ) + text = template.render(Context({"start_at": self.shift.start_at, "url": url})) msg = Message(to=self.helper, text=text) msg.save() self.reminder_sent = True