From 7abf8e9d59439a3d89d22e84b27bbe28c2f2ce7e Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Tue, 17 Mar 2020 15:17:41 +0100 Subject: [PATCH] Fix use of datetime in announcement form --- aleksis/core/forms.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aleksis/core/forms.py b/aleksis/core/forms.py index 501e2691b..aa9d9f8fc 100644 --- a/aleksis/core/forms.py +++ b/aleksis/core/forms.py @@ -1,4 +1,4 @@ -from datetime import time +from datetime import time, datetime from typing import Optional from django import forms @@ -167,9 +167,9 @@ class AnnouncementForm(ExtensibleForm): def __init__(self, *args, **kwargs): if "instance" not in kwargs: kwargs["initial"] = { - "valid_from_date": timezone.now(), + "valid_from_date": datetime.now(), "valid_from_time": time(0, 0), - "valid_until_date": timezone.now(), + "valid_until_date": datetime.now(), "valid_until_time": time(23, 59), } else: @@ -195,10 +195,10 @@ class AnnouncementForm(ExtensibleForm): until_date = data["valid_until_date"] until_time = data["valid_until_time"] - valid_from = timezone.datetime.combine(from_date, from_time) - valid_until = timezone.datetime.combine(until_date, until_time) + valid_from = datetime.combine(from_date, from_time) + valid_until = datetime.combine(until_date, until_time) - if valid_until < timezone.now(): + if valid_until < datetime.now(): raise ValidationError( _("You are not allowed to create announcements which are only valid in the past.") ) -- GitLab