Propogate content warning from parent

This commit is contained in:
Mouse Reeve 2020-12-17 11:32:09 -08:00
parent 34a2afc788
commit 2799ed68e3
3 changed files with 24 additions and 12 deletions

View file

@ -61,28 +61,35 @@ class ReviewForm(CustomForm):
class Meta: class Meta:
model = models.Review model = models.Review
fields = [ fields = [
'user', 'book', 'name', 'content', 'content_warning', 'rating', 'user', 'book',
'name', 'content', 'rating',
'content_warning', 'sensitive',
'privacy'] 'privacy']
class CommentForm(CustomForm): class CommentForm(CustomForm):
class Meta: class Meta:
model = models.Comment model = models.Comment
fields = ['user', 'book', 'content', 'content_warning', 'privacy'] fields = [
'user', 'book', 'content',
'content_warning', 'sensitive',
'privacy']
class QuotationForm(CustomForm): class QuotationForm(CustomForm):
class Meta: class Meta:
model = models.Quotation model = models.Quotation
fields = [ fields = [
'user', 'book', 'quote', 'content', 'content_warning', 'privacy'] 'user', 'book', 'quote', 'content',
'content_warning', 'sensitive', 'privacy']
class ReplyForm(CustomForm): class ReplyForm(CustomForm):
class Meta: class Meta:
model = models.Status model = models.Status
fields = [ fields = [
'user', 'content', 'content_warning', 'reply_parent', 'privacy'] 'user', 'content', 'content_warning', 'sensitive',
'reply_parent', 'privacy']
class EditUserForm(CustomForm): class EditUserForm(CustomForm):

View file

@ -209,7 +209,11 @@ def handle_delete_status(user, status):
def handle_status(user, form): def handle_status(user, form):
''' generic handler for statuses ''' ''' 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 # inspect the text for user tags
text = status.content text = status.content

View file

@ -1,18 +1,19 @@
{% with uuid as uuid %}
<div class="control"> <div class="control">
<div> <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"> <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> </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"> <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="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_{{ book.id }}_{{ type }}">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_{{ book.id }}_{{ type }}" placeholder="Spoilers ahead!" value="{{ parent_status.content_warning }}"> <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> </div>
</div> </div>
{% endwith %}