diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 83f0d053..b9ff59c2 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -479,6 +479,7 @@ class SortListForm(forms.Form): ), ) + class ReadThroughForm(CustomForm): def clean(self): """make sure the email isn't in use by a registered user""" diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index f0851df2..ae67c092 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -457,7 +457,7 @@ urlpatterns = [ # reading progress re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"), re_path(r"^delete-readthrough/?$", views.delete_readthrough), - re_path(r"^create-readthrough/?$", views.CreateReadThrough.as_view(), name="create-readthrough"), + re_path(r"^create-readthrough/?$", views.ReadThrough.as_view(), name="create-readthrough"), re_path(r"^delete-progressupdate/?$", views.delete_progressupdate), # shelve actions re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 092d27a6..4157e75b 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -88,7 +88,7 @@ from .list import Lists, SavedLists, List, Curate, UserLists from .list import save_list, unsave_list, delete_list, unsafe_embed_list from .notifications import Notifications from .outbox import Outbox -from .reading import CreateReadThrough, delete_readthrough, delete_progressupdate +from .reading import ReadThrough, delete_readthrough, delete_progressupdate from .reading import ReadingStatus from .rss_feed import RssFeed from .search import Search diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 22ee450a..a5d69947 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -116,10 +116,18 @@ class ReadingStatus(View): @method_decorator(login_required, name="dispatch") -class CreateReadThrough(View): +class ReadThrough(View): """Add new read dates""" - def get(self, request): + def get(self, request, book_id, readthrough_id=None): """standalone form in case of errors""" + book = get_object_or_404(models.Edition, id=book_id) + form = forms.ReadThroughForm() + data = {"form": form, "book": book} + if readthrough_id: + data["readthrough"] = get_object_or_404( + models.ReadThrough, id=readthrough_id + ) + return TemplateResponse(request, "readthrough/readthrough.html", data) def post(self, request): diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index bb69d30c..5dc8e8fa 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -159,6 +159,7 @@ def update_progress(request, book_id): # pylint: disable=unused-argument @require_POST def edit_readthrough(request): """can't use the form because the dates are too finnicky""" + # TODO: remove this, it duplicates the code in the ReadThrough view readthrough = get_object_or_404(models.ReadThrough, id=request.POST.get("id")) readthrough.raise_not_editable(request.user)