WIP: fix reading status ending in the future

This commit is contained in:
Laura Pircalaboiu 2022-10-11 13:41:07 +02:00 committed by x3005504
parent 44ce12405b
commit aeeb2c3442

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