diff --git a/bookwyrm/forms/forms.py b/bookwyrm/forms/forms.py index 4aa1e5758..ea6093750 100644 --- a/bookwyrm/forms/forms.py +++ b/bookwyrm/forms/forms.py @@ -1,4 +1,5 @@ """ using django model forms """ +import datetime from django import forms from django.forms import widgets from django.utils.translation import gettext_lazy as _ @@ -7,7 +8,6 @@ from bookwyrm import models from bookwyrm.models.user import FeedFilterChoices from .custom_form import CustomForm - # pylint: disable=missing-class-docstring class FeedStatusTypesForm(CustomForm): class Meta: @@ -58,6 +58,21 @@ class ReadThroughForm(CustomForm): self.add_error( "stopped_date", _("Reading stopped date cannot be before start date.") ) + current_time = datetime.datetime.now() + if ( + stopped_date is not None + and current_time.timestamp() < stopped_date.timestamp() + ): + self.add_error( + "stopped_date", _("Reading stopped date cannot be in the future.") + ) + if ( + finish_date is not None + and current_time.timestamp() < finish_date.timestamp() + ): + self.add_error( + "finish_date", _("Reading finished date cannot be in the future.") + ) class Meta: model = models.ReadThrough