Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2020-12-17 11:33:52 -08:00
commit 0cd9f81431
5 changed files with 38 additions and 22 deletions

View file

@ -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):

View file

@ -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

View file

@ -0,0 +1,19 @@
{% with uuid as uuid %}
<div class="control">
<div>
<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-{{ uuid }}">Add spoilers/content warning</label>
</div>
</div>
<div>
<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-{{ 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 %}

View file

@ -27,14 +27,7 @@
</fieldset>
{% endif %}
<div class="control">
<label class="button is-small" role="button" tabindex="0" for="include-spoilers-{{ book.id }}-{{ type }}">Add spoilers/content warning</label>
<input type="checkbox" class="toggle-control" id="include-spoilers-{{ book.id }}-{{ type }}">
<div class="toggle-content hidden">
<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!">
</div>
</div>
{% include 'snippets/content_warning_field.html' %}
{% if type == 'quote' %}
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>

View file

@ -6,19 +6,12 @@
<input type="hidden" name="reply_parent" value="{{ activity.id }}">
<input type="hidden" name="user" value="{{ request.user.id }}">
<div class="column">
<div class="control">
<label class="button is-small" role="button" tabindex="0" for="include-spoilers-{{ book.id }}-{{ type }}">Add spoilers/content warning</label>
<input type="checkbox" class="toggle-control" id="include-spoilers-{{ book.id }}-{{ type }}">
<div class="toggle-content hidden">
<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!">
</div>
</div>
{% include 'snippets/content_warning_field.html' with parent_status=activity %}
<div class="field">
<textarea class="textarea" name="content" placeholder="Leave a comment..." id="id_content_{{ activity.id }}-{{ uuid }}" required="true"></textarea>
</div>
</div>
<div class="column is-narrow">
<div class="field">
{% include 'snippets/privacy_select.html' with current=activity.privacy %}