forked from mirrors/bookwyrm
Propogate content warning from parent
This commit is contained in:
parent
34a2afc788
commit
2799ed68e3
3 changed files with 24 additions and 12 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
{% with uuid as uuid %}
|
||||
<div class="control">
|
||||
<div>
|
||||
<input type="radio" class="toggle-control" name="content-warning-toggle" id="hide-spoilers-{{ book.id }}-{{ type }}" {% if not parent_status.content_warning %}checked{% endif %}>
|
||||
<input type="radio" class="toggle-control" name="sensitive" value="false" id="hide-spoilers-{{ uuid }}" {% if not parent_status.content_warning %}checked{% endif %}>
|
||||
<div class="toggle-content hidden">
|
||||
<label class="button is-small" role="button" tabindex="0" for="include-spoilers-{{ book.id }}-{{ type }}">Add spoilers/content warning</label>
|
||||
<label class="button is-small" role="button" tabindex="0" for="include-spoilers-{{ uuid }}">Add spoilers/content warning</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="radio" class="toggle-control" id="include-spoilers-{{ book.id }}-{{ type }}" name="content-warning-toggle" {% if parent_status.content_warning %}checked{% endif %}>
|
||||
<input type="radio" class="toggle-control" id="include-spoilers-{{ uuid }}" name="sensitive" value="true" {% if parent_status.content_warning %}checked{% endif %}>
|
||||
<div class="toggle-content hidden">
|
||||
<label class="button is-small" role="button" tabindex="0" for="hide-spoilers-{{ book.id }}-{{ type }}">Remove spoilers/content warning</label>
|
||||
<label class="is-sr-only" for="id_content_warning_{{ book.id }}_{{ type }}">Spoilers/content warning:</label>
|
||||
<input type="text" name="content_warning" maxlength="255" class="input" id="id_content_warning_{{ book.id }}_{{ type }}" placeholder="Spoilers ahead!" value="{{ parent_status.content_warning }}">
|
||||
<label class="button is-small" role="button" tabindex="0" for="hide-spoilers-{{ uuid }}">Remove spoilers/content warning</label>
|
||||
<label class="is-sr-only" for="id_content_warning_{{ uuid }}">Spoilers/content warning:</label>
|
||||
<input type="text" name="content_warning" maxlength="255" class="input" id="id_content_warning_{{ uuid }}" placeholder="Spoilers ahead!"{% if parent_status.content_warning %} value="{{ parent_status.content_warning }}"{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endwith %}
|
||||
|
|
Loading…
Reference in a new issue