Merge pull request #396 from mouse-reeve/content-warnings
Content warnings
This commit is contained in:
commit
c0dc3c5c05
|
@ -23,6 +23,7 @@ class Note(ActivityObject):
|
||||||
cc: List[str] = field(default_factory=lambda: [])
|
cc: List[str] = field(default_factory=lambda: [])
|
||||||
replies: Dict = field(default_factory=lambda: {})
|
replies: Dict = field(default_factory=lambda: {})
|
||||||
inReplyTo: str = ''
|
inReplyTo: str = ''
|
||||||
|
summary: str = ''
|
||||||
tag: List[Link] = field(default_factory=lambda: [])
|
tag: List[Link] = field(default_factory=lambda: [])
|
||||||
attachment: List[Image] = field(default_factory=lambda: [])
|
attachment: List[Image] = field(default_factory=lambda: [])
|
||||||
sensitive: bool = False
|
sensitive: bool = False
|
||||||
|
@ -53,7 +54,7 @@ class Comment(Note):
|
||||||
class Review(Comment):
|
class Review(Comment):
|
||||||
''' a full book review '''
|
''' a full book review '''
|
||||||
name: str
|
name: str
|
||||||
rating: int
|
rating: int = None
|
||||||
type: str = 'Review'
|
type: str = 'Review'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,25 +60,29 @@ class RatingForm(CustomForm):
|
||||||
class ReviewForm(CustomForm):
|
class ReviewForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Review
|
model = models.Review
|
||||||
fields = ['user', 'book', 'name', 'content', 'rating', 'privacy']
|
fields = [
|
||||||
|
'user', 'book', 'name', 'content', 'content_warning', 'rating',
|
||||||
|
'privacy']
|
||||||
|
|
||||||
|
|
||||||
class CommentForm(CustomForm):
|
class CommentForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Comment
|
model = models.Comment
|
||||||
fields = ['user', 'book', 'content', 'privacy']
|
fields = ['user', 'book', 'content', 'content_warning', 'privacy']
|
||||||
|
|
||||||
|
|
||||||
class QuotationForm(CustomForm):
|
class QuotationForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Quotation
|
model = models.Quotation
|
||||||
fields = ['user', 'book', 'quote', 'content', 'privacy']
|
fields = [
|
||||||
|
'user', 'book', 'quote', 'content', 'content_warning', 'privacy']
|
||||||
|
|
||||||
|
|
||||||
class ReplyForm(CustomForm):
|
class ReplyForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Status
|
model = models.Status
|
||||||
fields = ['user', 'content', 'reply_parent', 'privacy']
|
fields = [
|
||||||
|
'user', 'content', 'content_warning', 'reply_parent', 'privacy']
|
||||||
|
|
||||||
|
|
||||||
class EditUserForm(CustomForm):
|
class EditUserForm(CustomForm):
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 3.0.7 on 2020-12-17 03:17
|
||||||
|
|
||||||
|
import bookwyrm.models.fields
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bookwyrm', '0025_auto_20201217_0046'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='status',
|
||||||
|
name='content_warning',
|
||||||
|
field=bookwyrm.models.fields.CharField(blank=True, max_length=500, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -18,6 +18,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
mention_users = fields.TagField('User', related_name='mention_user')
|
mention_users = fields.TagField('User', related_name='mention_user')
|
||||||
mention_books = fields.TagField('Edition', related_name='mention_book')
|
mention_books = fields.TagField('Edition', related_name='mention_book')
|
||||||
local = models.BooleanField(default=True)
|
local = models.BooleanField(default=True)
|
||||||
|
content_warning = fields.CharField(
|
||||||
|
max_length=500, blank=True, null=True, activitypub_field='summary')
|
||||||
privacy = fields.PrivacyField(max_length=255)
|
privacy = fields.PrivacyField(max_length=255)
|
||||||
sensitive = fields.BooleanField(default=False)
|
sensitive = fields.BooleanField(default=False)
|
||||||
# created date is different than publish date because of federated posts
|
# created date is different than publish date because of federated posts
|
||||||
|
|
|
@ -26,6 +26,16 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% endif %}
|
{% 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>
|
||||||
|
|
||||||
{% if type == 'quote' %}
|
{% if type == 'quote' %}
|
||||||
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
|
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -6,6 +6,14 @@
|
||||||
<input type="hidden" name="reply_parent" value="{{ activity.id }}">
|
<input type="hidden" name="reply_parent" value="{{ activity.id }}">
|
||||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||||
<div class="column">
|
<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>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<textarea class="textarea" name="content" placeholder="Leave a comment..." id="id_content_{{ activity.id }}-{{ uuid }}" required="true"></textarea>
|
<textarea class="textarea" name="content" placeholder="Leave a comment..." id="id_content_{{ activity.id }}-{{ uuid }}" required="true"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,28 @@
|
||||||
{% load bookwyrm_tags %}
|
{% load bookwyrm_tags %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
{% if status.status_type == 'Review' %}
|
{% if status.status_type == 'Review' %}
|
||||||
<h3>
|
<div>
|
||||||
|
<h3 class="title is-5 has-subtitle">
|
||||||
{% if status.name %}{{ status.name }}<br>{% endif %}
|
{% if status.name %}{{ status.name }}<br>{% endif %}
|
||||||
{% include 'snippets/stars.html' with rating=status.rating %}
|
|
||||||
</h3>
|
</h3>
|
||||||
|
<p class="subtitle">{% include 'snippets/stars.html' with rating=status.rating %}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if status.content_warning %}
|
||||||
|
<div class="toggle-content">
|
||||||
|
<p>{{ status.content_warning }}</p>
|
||||||
|
<input class="toggle-control" type="radio" name="toggle-status-cw-{{ status.id }}" id="hide-status-cw-{{ status.id }}" checked>
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<label class="button is-small" for="show-status-cw-{{ status.id }}" tabindex="0" role="button">Show More</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input class="toggle-control" type="radio" name="toggle-status-cw-{{ status.id }}" id="show-status-cw-{{ status.id }}">
|
||||||
|
{% endif %}
|
||||||
|
<div{% if status.content_warning %} class="toggle-content hidden"{% endif %}>
|
||||||
|
{% if status.content_warning %}
|
||||||
|
<label class="button is-small" for="hide-status-cw-{{ status.id }}" tabindex="0" role="button">Show Less</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if status.quote %}
|
{% if status.quote %}
|
||||||
|
@ -34,6 +52,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if not hide_book %}
|
{% if not hide_book %}
|
||||||
{% if status.book or status.mention_books.count %}
|
{% if status.book or status.mention_books.count %}
|
||||||
|
|
Loading…
Reference in New Issue