mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-16 12:15:46 +00:00
Merge pull request #396 from mouse-reeve/content-warnings
Content warnings
This commit is contained in:
commit
c0dc3c5c05
7 changed files with 94 additions and 31 deletions
|
@ -23,6 +23,7 @@ class Note(ActivityObject):
|
|||
cc: List[str] = field(default_factory=lambda: [])
|
||||
replies: Dict = field(default_factory=lambda: {})
|
||||
inReplyTo: str = ''
|
||||
summary: str = ''
|
||||
tag: List[Link] = field(default_factory=lambda: [])
|
||||
attachment: List[Image] = field(default_factory=lambda: [])
|
||||
sensitive: bool = False
|
||||
|
@ -53,7 +54,7 @@ class Comment(Note):
|
|||
class Review(Comment):
|
||||
''' a full book review '''
|
||||
name: str
|
||||
rating: int
|
||||
rating: int = None
|
||||
type: str = 'Review'
|
||||
|
||||
|
||||
|
|
|
@ -60,25 +60,29 @@ class RatingForm(CustomForm):
|
|||
class ReviewForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Review
|
||||
fields = ['user', 'book', 'name', 'content', 'rating', 'privacy']
|
||||
fields = [
|
||||
'user', 'book', 'name', 'content', 'content_warning', 'rating',
|
||||
'privacy']
|
||||
|
||||
|
||||
class CommentForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Comment
|
||||
fields = ['user', 'book', 'content', 'privacy']
|
||||
fields = ['user', 'book', 'content', 'content_warning', 'privacy']
|
||||
|
||||
|
||||
class QuotationForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Quotation
|
||||
fields = ['user', 'book', 'quote', 'content', 'privacy']
|
||||
fields = [
|
||||
'user', 'book', 'quote', 'content', 'content_warning', 'privacy']
|
||||
|
||||
|
||||
class ReplyForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Status
|
||||
fields = ['user', 'content', 'reply_parent', 'privacy']
|
||||
fields = [
|
||||
'user', 'content', 'content_warning', 'reply_parent', 'privacy']
|
||||
|
||||
|
||||
class EditUserForm(CustomForm):
|
||||
|
|
19
bookwyrm/migrations/0026_status_content_warning.py
Normal file
19
bookwyrm/migrations/0026_status_content_warning.py
Normal file
|
@ -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_books = fields.TagField('Edition', related_name='mention_book')
|
||||
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)
|
||||
sensitive = fields.BooleanField(default=False)
|
||||
# created date is different than publish date because of federated posts
|
||||
|
|
|
@ -26,6 +26,16 @@
|
|||
</div>
|
||||
</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>
|
||||
|
||||
{% if type == 'quote' %}
|
||||
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
|
||||
{% else %}
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
<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>
|
||||
<div class="field">
|
||||
<textarea class="textarea" name="content" placeholder="Leave a comment..." id="id_content_{{ activity.id }}-{{ uuid }}" required="true"></textarea>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,28 @@
|
|||
{% load bookwyrm_tags %}
|
||||
<div class="block">
|
||||
{% if status.status_type == 'Review' %}
|
||||
<h3>
|
||||
<div>
|
||||
<h3 class="title is-5 has-subtitle">
|
||||
{% if status.name %}{{ status.name }}<br>{% endif %}
|
||||
{% include 'snippets/stars.html' with rating=status.rating %}
|
||||
</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 %}
|
||||
|
||||
{% if status.quote %}
|
||||
|
@ -33,6 +51,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not hide_book %}
|
||||
|
|
Loading…
Reference in a new issue