From 34a2afc788061da8dc8f8472dbea68315c29fd9d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Dec 2020 11:05:37 -0800 Subject: [PATCH 1/2] Change text on cw button --- .../snippets/content_warning_field.html | 18 ++++++++++++++++++ .../templates/snippets/create_status_form.html | 9 +-------- bookwyrm/templates/snippets/reply_form.html | 11 ++--------- 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 bookwyrm/templates/snippets/content_warning_field.html diff --git a/bookwyrm/templates/snippets/content_warning_field.html b/bookwyrm/templates/snippets/content_warning_field.html new file mode 100644 index 000000000..1787c0a86 --- /dev/null +++ b/bookwyrm/templates/snippets/content_warning_field.html @@ -0,0 +1,18 @@ +
+
+ + +
+ +
+ + +
+
+ diff --git a/bookwyrm/templates/snippets/create_status_form.html b/bookwyrm/templates/snippets/create_status_form.html index 70062db4d..a0c6b817d 100644 --- a/bookwyrm/templates/snippets/create_status_form.html +++ b/bookwyrm/templates/snippets/create_status_form.html @@ -27,14 +27,7 @@ {% endif %} -
- - - -
+ {% include 'snippets/content_warning_field.html' %} {% if type == 'quote' %} diff --git a/bookwyrm/templates/snippets/reply_form.html b/bookwyrm/templates/snippets/reply_form.html index 65aa3e46a..787a3ac54 100644 --- a/bookwyrm/templates/snippets/reply_form.html +++ b/bookwyrm/templates/snippets/reply_form.html @@ -6,19 +6,12 @@
-
- - - -
+ + {% include 'snippets/content_warning_field.html' with parent_status=activity %}
-
{% include 'snippets/privacy_select.html' with current=activity.privacy %} From 2799ed68e30c8078c13cd0e4bc423a27bc71df82 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 17 Dec 2020 11:32:09 -0800 Subject: [PATCH 2/2] Propogate content warning from parent --- bookwyrm/forms.py | 15 +++++++++++---- bookwyrm/outgoing.py | 6 +++++- .../templates/snippets/content_warning_field.html | 15 ++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 454836bb7..1422b4b9a 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -61,28 +61,35 @@ class ReviewForm(CustomForm): class Meta: model = models.Review fields = [ - 'user', 'book', 'name', 'content', 'content_warning', 'rating', + 'user', 'book', + 'name', 'content', 'rating', + 'content_warning', 'sensitive', 'privacy'] class CommentForm(CustomForm): class Meta: model = models.Comment - fields = ['user', 'book', 'content', 'content_warning', 'privacy'] + fields = [ + 'user', 'book', 'content', + 'content_warning', 'sensitive', + 'privacy'] class QuotationForm(CustomForm): class Meta: model = models.Quotation fields = [ - 'user', 'book', 'quote', 'content', 'content_warning', 'privacy'] + 'user', 'book', 'quote', 'content', + 'content_warning', 'sensitive', 'privacy'] class ReplyForm(CustomForm): class Meta: model = models.Status fields = [ - 'user', 'content', 'content_warning', 'reply_parent', 'privacy'] + 'user', 'content', 'content_warning', 'sensitive', + 'reply_parent', 'privacy'] class EditUserForm(CustomForm): diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index 475bfc218..65a253e95 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -209,7 +209,11 @@ def handle_delete_status(user, status): def handle_status(user, form): ''' generic handler for statuses ''' - status = form.save() + status = form.save(commit=False) + if not status.sensitive and status.content_warning: + # the cw text field remains populated hen you click "remove" + status.content_warning = None + status.save() # inspect the text for user tags text = status.content diff --git a/bookwyrm/templates/snippets/content_warning_field.html b/bookwyrm/templates/snippets/content_warning_field.html index 1787c0a86..e2f561f24 100644 --- a/bookwyrm/templates/snippets/content_warning_field.html +++ b/bookwyrm/templates/snippets/content_warning_field.html @@ -1,18 +1,19 @@ +{% with uuid as uuid %}
- +
- +
- +{% endwith %}