mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Merge pull request #2316 from redshiftss/bugfix/reading-status-future
Make it so that finishing a book cannot happen in the future
This commit is contained in:
commit
b02ad2ec68
1 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue