WIP: fix reading status ending in the future

This commit is contained in:
x3005504 2022-10-11 13:41:07 +02:00
parent 44ce12405b
commit 68b9791d8c

View file

@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _
from bookwyrm import models
from bookwyrm.models.user import FeedFilterChoices
from .custom_form import CustomForm
import datetime
# pylint: disable=missing-class-docstring
class FeedStatusTypesForm(CustomForm):
@ -58,6 +58,15 @@ class ReadThroughForm(CustomForm):
self.add_error(
"stopped_date", _("Reading stopped date cannot be before start date.")
)
current_time = datetime.datetime.now()
if current_time < stopped_date:
self.add_error(
"stopped_date", _("Reading stopped date cannot be in the future.")
)
if current_time < finish_date:
self.add_error(
"finished_date", _("Reading finished date cannot be in the future.")
)
class Meta:
model = models.ReadThrough