From 3356c652eecef652dc0f1c37665c665c678d23c3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 8 Jun 2021 11:55:18 -0700 Subject: [PATCH] Adds standalone modal views for reading steps --- bookwyrm/templates/reading_progress/finish.html | 14 ++++++++++++++ bookwyrm/templates/reading_progress/start.html | 2 +- bookwyrm/templates/reading_progress/want.html | 14 ++++++++++++++ bookwyrm/views/reading.py | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/templates/reading_progress/finish.html create mode 100644 bookwyrm/templates/reading_progress/want.html diff --git a/bookwyrm/templates/reading_progress/finish.html b/bookwyrm/templates/reading_progress/finish.html new file mode 100644 index 00000000..a9f60f04 --- /dev/null +++ b/bookwyrm/templates/reading_progress/finish.html @@ -0,0 +1,14 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %} +{% blocktrans trimmed with book_title=book.title %} +Finish "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block content %} + +{% include "snippets/shelve_button/finish_reading_modal.html" with book=book active=True %} + +{% endblock %} diff --git a/bookwyrm/templates/reading_progress/start.html b/bookwyrm/templates/reading_progress/start.html index c5d3f91b..9c457947 100644 --- a/bookwyrm/templates/reading_progress/start.html +++ b/bookwyrm/templates/reading_progress/start.html @@ -9,6 +9,6 @@ Start "{{ book_title }}" {% block content %} -{% include "snippets/shelve_button/start_reading_modal.html" active=True %} +{% include "snippets/shelve_button/start_reading_modal.html" with book=book active=True %} {% endblock %} diff --git a/bookwyrm/templates/reading_progress/want.html b/bookwyrm/templates/reading_progress/want.html new file mode 100644 index 00000000..8e75d470 --- /dev/null +++ b/bookwyrm/templates/reading_progress/want.html @@ -0,0 +1,14 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %} +{% blocktrans trimmed with book_title=book.title %} +Want to Read "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block content %} + +{% include "snippets/shelve_button/want_to_read_modal.html" with book=book active=True no_body=True %} + +{% endblock %} diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index cb382330..28809383 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -7,6 +7,7 @@ from dateutil.parser import ParserError from django.contrib.auth.decorators import login_required from django.http import HttpResponseBadRequest, HttpResponseNotFound from django.shortcuts import get_object_or_404, redirect +from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View from django.views.decorators.http import require_POST @@ -20,6 +21,11 @@ from .helpers import get_edition, handle_reading_status class WantToRead(View): """consider reading a book""" + def get(self, request, book_id): + """modal page""" + book = get_edition(book_id) + return TemplateResponse(request, "reading_progress/want.html", {"book": book}) + def post(self, request, book_id): """desire a book""" desired_shelf = models.Shelf.objects.filter( @@ -33,6 +39,11 @@ class WantToRead(View): class StartReading(View): """begin a book""" + def get(self, request, book_id): + """modal page""" + book = get_edition(book_id) + return TemplateResponse(request, "reading_progress/start.html", {"book": book}) + def post(self, request, book_id): """begin reading a book""" desired_shelf = models.Shelf.objects.filter( @@ -46,6 +57,11 @@ class StartReading(View): class FinishReading(View): """finish a book""" + def get(self, request, book_id): + """modal page""" + book = get_edition(book_id) + return TemplateResponse(request, "reading_progress/finish.html", {"book": book}) + def post(self, request, book_id): """a user completed a book, yay""" desired_shelf = models.Shelf.objects.filter(