-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add content warnings for videos/links (#1102)
## Fixes issue Fixes #493 ## Description of Changes *This change is cherry-picked from OrcaCollective#457 Adds content warnings to links and videos ## Notes for Deployment There's an alembic migration that will need to be run ## Screenshots (if appropriate) New checkbox "Include content warning?" which is checked by default per #493 (comment) ![1](https://github.com/lucyparsons/OpenOversight/assets/66500457/9ea246c7-3f08-48c0-8940-181b676f8c34) How links and videos will look when a content warning is added: ![2](https://github.com/lucyparsons/OpenOversight/assets/66500457/b4d815bc-9919-47f0-ab00-e5fa7bdea024) ## Tests and Linting - [x] This branch is up-to-date with the `develop` branch. - [x] `pytest` passes on my local development environment. - [x] `pre-commit` passes on my local development environment. --------- Co-authored-by: michplunkett <5885605+michplunkett@users.noreply.github.com>
- Loading branch information
1 parent
d11b9a2
commit d989873
Showing
13 changed files
with
217 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function createOverlay(container) { | ||
const warningText = $( | ||
"<span><h3>Content Warning</h3><p>This video may be disturbing for some viewers</p></span>" | ||
) | ||
const hide = $('<button type="button" class="btn btn-lg">Show video</button>') | ||
hide.click(() => overlay.css("display", "none")) | ||
|
||
const wrapper = $("<div>") | ||
wrapper.append(warningText) | ||
wrapper.append(hide) | ||
|
||
const overlay = $('<div class="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) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
OpenOversight/migrations/versions/2024-06-05-0203_939ea0f2b26d_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Add has_content_warning column to link model | ||
Revision ID: 939ea0f2b26d | ||
Revises: 52d3f6a21dd9 | ||
Create Date: 2024-06-05 02:03:29.168771 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
revision = "939ea0f2b26d" | ||
down_revision = "52d3f6a21dd9" | ||
|
||
|
||
def upgrade(): | ||
# This is not expected to impact performance: https://dba.stackexchange.com/a/216153 | ||
with op.batch_alter_table("links", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"has_content_warning", | ||
sa.Boolean(), | ||
nullable=False, | ||
server_default="false", | ||
) | ||
) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("links", schema=None) as batch_op: | ||
batch_op.drop_column("has_content_warning") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters