diff --git a/OpenOversight/app/main/forms.py b/OpenOversight/app/main/forms.py index 85cf25175..da6a7b0cf 100644 --- a/OpenOversight/app/main/forms.py +++ b/OpenOversight/app/main/forms.py @@ -240,6 +240,9 @@ class LinkForm(Form): default="", validators=[AnyOf(allowed_values(LINK_CHOICES))], ) + has_content_warning = BooleanField( + "Include content warning?", default=True, validators=[Optional()] + ) def validate(self, extra_validators=None): success = super(LinkForm, self).validate(extra_validators=extra_validators) diff --git a/OpenOversight/app/main/views.py b/OpenOversight/app/main/views.py index f054a0fc0..a05e1ca50 100644 --- a/OpenOversight/app/main/views.py +++ b/OpenOversight/app/main/views.py @@ -2374,6 +2374,7 @@ def new(self, form: FlaskForm = None): link_type=form.link_type.data, description=form.description.data, author=form.author.data, + has_content_warning=form.has_content_warning.data, created_by=current_user.id, last_updated_by=current_user.id, ) diff --git a/OpenOversight/app/models/database.py b/OpenOversight/app/models/database.py index 0fdbe41f9..347ad1465 100644 --- a/OpenOversight/app/models/database.py +++ b/OpenOversight/app/models/database.py @@ -623,6 +623,7 @@ class Link(BaseModel, TrackUpdates): link_type = db.Column(db.String(100), index=True) description = db.Column(db.Text(), nullable=True) author = db.Column(db.String(255), nullable=True) + has_content_warning = db.Column(db.Boolean, nullable=False, default=False) @validates("url") def validate_url(self, key, url): diff --git a/OpenOversight/app/static/css/openoversight.css b/OpenOversight/app/static/css/openoversight.css index 9d2fab2a6..d8d467109 100644 --- a/OpenOversight/app/static/css/openoversight.css +++ b/OpenOversight/app/static/css/openoversight.css @@ -679,3 +679,15 @@ tr:hover .row-actions { .bottom-margin { margin-bottom: 2rem; } + +.video-container .overlay { + align-items: center; + background: black; + color: white; + display: flex; + height: 100%; + justify-content: center; + position: absolute; + top: 0; + width: 100%; +} diff --git a/OpenOversight/app/static/js/contentWarning.js b/OpenOversight/app/static/js/contentWarning.js new file mode 100644 index 000000000..cefcbb0e3 --- /dev/null +++ b/OpenOversight/app/static/js/contentWarning.js @@ -0,0 +1,24 @@ +function createOverlay(container) { + const warningText = $( + "

Content Warning

This video may be disturbing for some viewers

" + ) + const hide = $('') + hide.click(() => overlay.css("display", "none")) + + const wrapper = $("
") + wrapper.append(warningText) + wrapper.append(hide) + + const overlay = $('
') + overlay.append(wrapper) + container.append(overlay) +} + +$(document).ready(() => { + $(".video-container").each((index, element) => { + const container = $(element) + if (container.data("has-content-warning")) { + createOverlay(container) + } + }) +}) diff --git a/OpenOversight/app/templates/incident_detail.html b/OpenOversight/app/templates/incident_detail.html index 04d565691..5ea9ce516 100644 --- a/OpenOversight/app/templates/incident_detail.html +++ b/OpenOversight/app/templates/incident_detail.html @@ -76,4 +76,5 @@

Incident Description

{% endif %} + {% endblock content %} diff --git a/OpenOversight/app/templates/officer.html b/OpenOversight/app/templates/officer.html index caf7c2c9a..9291fe7d7 100644 --- a/OpenOversight/app/templates/officer.html +++ b/OpenOversight/app/templates/officer.html @@ -136,4 +136,5 @@

{# end row #} + {% endblock content %} diff --git a/OpenOversight/app/templates/partials/links_and_videos_row.html b/OpenOversight/app/templates/partials/links_and_videos_row.html index a345fdb8f..7be25de4d 100644 --- a/OpenOversight/app/templates/partials/links_and_videos_row.html +++ b/OpenOversight/app/templates/partials/links_and_videos_row.html @@ -6,6 +6,10 @@

Links

{% for link in list %}
  • {{ link.title or link.url }} + {% if link.has_content_warning %} + Content Warning + {% endif %} {% if officer and (is_admin_or_coordinator or link.created_by == current_user.id) %} Edit @@ -30,10 +34,6 @@

    Links

    {% endif %} {% endfor %} - {% if officer and (current_user.is_admin_or_coordinator(officer.department)) %} -
    New Link/Video - {% endif %} {% for type, list in obj.links | groupby("link_type") %} {% if type == "video" %}

    Videos

    @@ -53,7 +53,8 @@

    Videos

    {% endif %} -
    +