diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 855edf1e..1477234f 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -121,20 +121,6 @@ class StatusForm(CustomForm): fields = ["user", "content", "content_warning", "sensitive", "privacy"] -def get_form_from_status(status): - """ form-ify a status (for delete and redraft) """ - if isinstance(status, models.Review): - return ReviewForm(instance=status) - if isinstance(status, models.Comment): - return CommentForm(instance=status) - if isinstance(status, models.Quotation): - return QuotationForm(instance=status) - if status.reply_parent: - return ReplyForm(instance=status) - else: - return StatusForm(instance=status) - - class EditUserForm(CustomForm): class Meta: model = models.User diff --git a/bookwyrm/templates/compose.html b/bookwyrm/templates/compose.html index a6da73e6..7c5d8933 100644 --- a/bookwyrm/templates/compose.html +++ b/bookwyrm/templates/compose.html @@ -8,6 +8,7 @@

{% trans "Compose status" %}

+{% with 0|uuid as uuid %}
{% if book %}
@@ -18,13 +19,13 @@
{% endif %}
- {% if not form %} + {% if not draft %} {% include 'snippets/create_status.html' %} {% else %} {% include 'snippets/create_status_form.html' %} {% endif %}
- +{{ form.ap_p }} +{% endwith %} {% endblock %} - diff --git a/bookwyrm/templates/snippets/content_warning_field.html b/bookwyrm/templates/snippets/content_warning_field.html index c90138e9..b645a29c 100644 --- a/bookwyrm/templates/snippets/content_warning_field.html +++ b/bookwyrm/templates/snippets/content_warning_field.html @@ -1,5 +1,12 @@ {% load i18n %} -
+
- +
diff --git a/bookwyrm/templates/snippets/create_status_form.html b/bookwyrm/templates/snippets/create_status_form.html index c70a0e58..7f5573e1 100644 --- a/bookwyrm/templates/snippets/create_status_form.html +++ b/bookwyrm/templates/snippets/create_status_form.html @@ -4,11 +4,11 @@ {% csrf_token %} - + {% if type == 'review' %}
- +
{% endif %}
@@ -29,9 +29,9 @@ {% trans "Rating" %}
- + {% for i in '12345'|make_list %} - + @@ -41,17 +41,17 @@ {% endif %} {% if type == 'quotation' %} - + {% else %} {% include 'snippets/content_warning_field.html' with parent_status=status %} - + {% endif %}
{% if type == 'quotation' %}
{% include 'snippets/content_warning_field.html' with parent_status=status %} - +
{% elif type == 'comment' %}
@@ -64,12 +64,12 @@
- +
@@ -81,20 +81,25 @@ {% endif %}
{% endif %} - + {# bottom bar #}
{% trans "Include spoiler alert" as button_text %} - {% include 'snippets/toggle/toggle_button.html' with text=button_text icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=status.content_warning %} + {% firstof draft.content_warning status.content_warning as pressed %} + {% include 'snippets/toggle/toggle_button.html' with text=button_text icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=pressed %}
{% if type == 'direct' %} {% else %} + {% if draft %} + {% include 'snippets/privacy_select.html' with current=draft.privacy %} + {% else %} {% include 'snippets/privacy_select.html' with current=reply_parent.privacy %} + {% endif %} {% endif %}
diff --git a/bookwyrm/templates/snippets/status/status_options.html b/bookwyrm/templates/snippets/status/status_options.html index 7cc74f07..c476bfbf 100644 --- a/bookwyrm/templates/snippets/status/status_options.html +++ b/bookwyrm/templates/snippets/status/status_options.html @@ -19,6 +19,7 @@ +{% if status.status_type != 'GeneratedNote' %}
  • +{% endif %} {% else %} {# things you can do to other people's statuses #}
  • diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index 1b4f8977..b224c1a9 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -75,7 +75,7 @@ class CreateStatus(View): # update a readthorugh, if needed edit_readthrough(request) - return redirect(request.headers.get("Referer", "/")) + return redirect("/") @method_decorator(login_required, name="dispatch") @@ -101,16 +101,24 @@ class DeleteAndRedraft(View): def post(self, request, status_id): """ delete and tombstone a status """ - status = get_object_or_404(models.Status, id=status_id) - - # don't let people delete other people's statuses - if status.user != request.user and not request.user.has_perm("moderate_post"): + status = get_object_or_404( + models.Status.objects.select_subclasses(), id=status_id + ) + if isinstance(status, models.GeneratedNote): return HttpResponseBadRequest() + # don't let people redraft other people's statuses + if status.user != request.user: + return HttpResponseBadRequest() - data = {"form": forms.get_form_from_status(status)} + data = { + "draft": status, + "type": status.status_type.lower(), + } if hasattr(status, "book"): data["book"] = status.book + elif status.mention_books: + data["book"] = status.mention_books.first() # perform deletion status.delete()