From 4cf9bca5aa535fd50b6bb23a6229697629eda1de Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Apr 2021 14:32:34 -0700 Subject: [PATCH] Adds compose view --- bookwyrm/templates/compose.html | 30 ++++++++++++++++++++++++++++++ bookwyrm/urls.py | 5 +++++ bookwyrm/views/status.py | 16 ++++++++++------ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 bookwyrm/templates/compose.html diff --git a/bookwyrm/templates/compose.html b/bookwyrm/templates/compose.html new file mode 100644 index 000000000..a6da73e6c --- /dev/null +++ b/bookwyrm/templates/compose.html @@ -0,0 +1,30 @@ +{% extends 'layout.html' %} +{% load i18n %} +{% load bookwyrm_tags %} + +{% block title %}{% trans "Compose status" %}{% endblock %} +{% block content %} +
+

{% trans "Compose status" %}

+
+ +
+ {% if book %} +
+ +

{% include 'snippets/book_titleby.html' with book=book %}

+
+ {% endif %} +
+ {% if not form %} + {% include 'snippets/create_status.html' %} + {% else %} + {% include 'snippets/create_status_form.html' %} + {% endif %} +
+
+ +{% endblock %} + diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 828d46bf5..463988065 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -202,6 +202,11 @@ urlpatterns = [ re_path( r"%s/replies(.json)?/?$" % status_path, views.Replies.as_view(), name="replies" ), + re_path( + r"^post/?$", + views.CreateStatus.as_view(), + name="create-status", + ), re_path( r"^post/(?P\w+)/?$", views.CreateStatus.as_view(), diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index b68b73399..10b9ebf8f 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -12,7 +12,6 @@ from bookwyrm import forms, models from bookwyrm.sanitize_html import InputHtmlParser from bookwyrm.settings import DOMAIN from bookwyrm.utils import regex -from .feed import feed_page_data from .helpers import handle_remote_webfinger from .reading import edit_readthrough @@ -22,6 +21,12 @@ from .reading import edit_readthrough class CreateStatus(View): """ the view for *posting* """ + def get(self, request): + """ compose view (used for delete-and-redraft """ + book = get_object_or_404(models.Edition, id=request.GET.get("book")) + data = {"book": book} + return TemplateResponse(request, "compose.html", data) + def post(self, request, status_type): """ create status of whatever type """ status_type = status_type[0].upper() + status_type[1:] @@ -103,14 +108,13 @@ class DeleteAndRedraft(View): return HttpResponseBadRequest() # TODO: get the correct form (maybe a generic form) - redraft_form = forms.StatusForm(instance=status) + data = {"form": forms.StatusForm(instance=status)} + if hasattr(status, "book"): + data["book"] = status.book # perform deletion status.delete() - data = feed_page_data(request.user) - # TODO: set up the correct edit state - data["redraft_form"] = redraft_form - return TemplateResponse(request, "feed/feed.html") + return TemplateResponse(request, "compose.html", data) def find_mentions(content):