diff --git a/bookwyrm/templates/snippets/create_status/layout.html b/bookwyrm/templates/snippets/create_status/layout.html index 1343316f..d824e270 100644 --- a/bookwyrm/templates/snippets/create_status/layout.html +++ b/bookwyrm/templates/snippets/create_status/layout.html @@ -17,7 +17,7 @@ reply_parent: the Status object this post will be in reply to, if applicable
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 8296493b..e6c9ad0b 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -328,6 +328,11 @@ urlpatterns = [ views.CreateStatus.as_view(), name="create-status", ), + re_path( + r"^post/(?P\w+)/(?P\d+)/?$", + views.CreateStatus.as_view(), + name="create-status", + ), re_path( r"^delete-status/(?P\d+)/?$", views.DeleteStatus.as_view(), diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index cddb5f59..0b6db899 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -40,11 +40,6 @@ class EditStatus(View): } return TemplateResponse(request, "compose.html", data) - def post(self, request, status_id): - """save an edited status""" - status = get_object_or_404(models.Status.select_subclasses(), id=status_id) - status.raise_not_editable(request.user) - # pylint: disable= no-self-use @method_decorator(login_required, name="dispatch") @@ -57,12 +52,20 @@ class CreateStatus(View): data = {"book": book} return TemplateResponse(request, "compose.html", data) - def post(self, request, status_type): + def post(self, request, status_type, existing_status_id=None): """create status of whatever type""" + if existing_status_id: + existing_status = get_object_or_404( + models.Status.select_subclasses(), id=existing_status_id + ) + existing_status.raise_not_editable(request.user) + status_type = status_type[0].upper() + status_type[1:] try: - form = getattr(forms, f"{status_type}Form")(request.POST) + form = getattr(forms, f"{status_type}Form")( + request.POST, instance=existing_status + ) except AttributeError: return HttpResponseBadRequest() if not form.is_valid():