diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 7ba7bd97b..b9ff59c2e 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -478,3 +478,19 @@ class SortListForm(forms.Form): ("descending", _("Descending")), ), ) + + +class ReadThroughForm(CustomForm): + def clean(self): + """make sure the email isn't in use by a registered user""" + cleaned_data = super().clean() + start_date = cleaned_data.get("start_date") + finish_date = cleaned_data.get("finish_date") + if start_date > finish_date: + self.add_error( + "finish_date", _("Reading finish date cannot be before start date.") + ) + + class Meta: + model = models.ReadThrough + fields = ["user", "book", "start_date", "finish_date"] diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 19dbccbd6..e4d13007c 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -237,29 +237,21 @@
{% trans "You don't have any reading activity for this book." %}
{% endif %} {% for readthrough in readthroughs %} - {% include 'book/readthrough.html' with readthrough=readthrough %} + {% include 'readthrough/readthrough_list.html' with readthrough=readthrough %} {% endfor %} diff --git a/bookwyrm/templates/book/delete_readthrough_modal.html b/bookwyrm/templates/readthrough/delete_readthrough_modal.html similarity index 100% rename from bookwyrm/templates/book/delete_readthrough_modal.html rename to bookwyrm/templates/readthrough/delete_readthrough_modal.html diff --git a/bookwyrm/templates/readthrough/readthrough.html b/bookwyrm/templates/readthrough/readthrough.html new file mode 100644 index 000000000..0b42017e6 --- /dev/null +++ b/bookwyrm/templates/readthrough/readthrough.html @@ -0,0 +1,15 @@ +{% extends 'layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block title %} +{% blocktrans trimmed with title=book|book_title %} +Update read dates for "{{ title }}" +{% endblocktrans %} +{% endblock %} + +{% block content %} + +{% include "readthrough/readthrough_modal.html" with book=book active=True static=True %} + +{% endblock %} diff --git a/bookwyrm/templates/snippets/readthrough_form.html b/bookwyrm/templates/readthrough/readthrough_form.html similarity index 94% rename from bookwyrm/templates/snippets/readthrough_form.html rename to bookwyrm/templates/readthrough/readthrough_form.html index 295ad7c6e..1558dada4 100644 --- a/bookwyrm/templates/snippets/readthrough_form.html +++ b/bookwyrm/templates/readthrough/readthrough_form.html @@ -4,6 +4,7 @@ {% csrf_token %} +