Skip to content

Commit

Permalink
Add new SensitiveMedia and MediaReport models
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Dec 11, 2023
1 parent 8459241 commit 77dc679
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 57 deletions.
4 changes: 2 additions & 2 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from api.admin.site import openverse_admin
from api.models import PENDING, Audio, AudioReport, ContentProvider, Image, ImageReport
from api.models.media import AbstractDeletedMedia, AbstractMatureMedia
from api.models.media import AbstractDeletedMedia, AbstractSensitiveMedia


admin.site = openverse_admin
Expand Down Expand Up @@ -72,7 +72,7 @@ def has_add_permission(self, *args, **kwargs):


for klass in [
*AbstractMatureMedia.__subclasses__(),
*AbstractSensitiveMedia.__subclasses__(),
*AbstractDeletedMedia.__subclasses__(),
]:
admin.site.register(klass, MediaSubreportAdmin)
Expand Down
21 changes: 21 additions & 0 deletions api/api/migrations/0055_rename_imagereport_nsfwreport_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.7 on 2023-12-11 04:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("api", "0054_throttledapplication_post_logout_redirect_uris"),
]

operations = [
migrations.RenameModel(
old_name="ImageReport",
new_name="NsfwReport",
),
migrations.RenameModel(
old_name="AudioReport",
new_name="NsfwReportAudio",
),
]
271 changes: 271 additions & 0 deletions api/api/migrations/0056_sensitiveaudio_sensitiveimage_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# Generated by Django 4.2.7 on 2023-12-11 06:32

import api.models.media
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("api", "0055_rename_imagereport_nsfwreport_and_more"),
]

operations = [
migrations.CreateModel(
name="SensitiveAudio",
fields=[
("created_on", models.DateTimeField(auto_now_add=True)),
(
"media_obj",
models.OneToOneField(
db_column="identifier",
db_constraint=False,
help_text="The reference to the sensitive audio.",
on_delete=django.db.models.deletion.DO_NOTHING,
primary_key=True,
related_name="sensitive_audio",
serialize=False,
to="api.audio",
to_field="identifier",
),
),
],
options={
"verbose_name_plural": "Sensitive audio",
},
bases=(api.models.media.PerformIndexUpdateMixin, models.Model),
),
migrations.CreateModel(
name="SensitiveImage",
fields=[
("created_on", models.DateTimeField(auto_now_add=True)),
(
"media_obj",
models.OneToOneField(
db_column="identifier",
db_constraint=False,
help_text="The reference to the sensitive image.",
on_delete=django.db.models.deletion.DO_NOTHING,
primary_key=True,
related_name="sensitive_image",
serialize=False,
to="api.image",
to_field="identifier",
),
),
],
options={
"abstract": False,
},
bases=(api.models.media.PerformIndexUpdateMixin, models.Model),
),
migrations.AlterField(
model_name="nsfwreport",
name="media_obj",
field=models.ForeignKey(
db_column="identifier",
db_constraint=False,
help_text="The reference to the image being reported.",
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="nsfw_image_report",
to="api.image",
to_field="identifier",
),
),
migrations.AlterField(
model_name="nsfwreport",
name="reason",
field=models.CharField(
choices=[
("sensitive", "sensitive"),
("dmca", "dmca"),
("other", "other"),
],
help_text="The reason to report media to Openverse.",
max_length=20,
),
),
migrations.AlterField(
model_name="nsfwreport",
name="status",
field=models.CharField(
choices=[
("pending_review", "pending_review"),
("sensitive_filtered", "sensitive_filtered"),
("deindexed", "deindexed"),
("no_action", "no_action"),
],
default="pending_review",
max_length=20,
),
),
migrations.AlterField(
model_name="nsfwreportaudio",
name="media_obj",
field=models.ForeignKey(
db_column="identifier",
db_constraint=False,
help_text="The reference to the audio being reported.",
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="nsfw_audio_report",
to="api.audio",
to_field="identifier",
),
),
migrations.AlterField(
model_name="nsfwreportaudio",
name="reason",
field=models.CharField(
choices=[
("sensitive", "sensitive"),
("dmca", "dmca"),
("other", "other"),
],
help_text="The reason to report media to Openverse.",
max_length=20,
),
),
migrations.AlterField(
model_name="nsfwreportaudio",
name="status",
field=models.CharField(
choices=[
("pending_review", "pending_review"),
("sensitive_filtered", "sensitive_filtered"),
("deindexed", "deindexed"),
("no_action", "no_action"),
],
default="pending_review",
max_length=20,
),
),
migrations.CreateModel(
name="ImageReport",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"reason",
models.CharField(
choices=[
("sensitive", "sensitive"),
("dmca", "dmca"),
("other", "other"),
],
help_text="The reason to report media to Openverse.",
max_length=20,
),
),
(
"description",
models.TextField(
blank=True,
help_text="The explanation on why media is being reported.",
max_length=500,
null=True,
),
),
(
"status",
models.CharField(
choices=[
("pending_review", "pending_review"),
("sensitive_filtered", "sensitive_filtered"),
("deindexed", "deindexed"),
("no_action", "no_action"),
],
default="pending_review",
max_length=20,
),
),
(
"media_obj",
models.ForeignKey(
db_column="identifier",
db_constraint=False,
help_text="The reference to the image being reported.",
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="image_report",
to="api.image",
to_field="identifier",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="AudioReport",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"reason",
models.CharField(
choices=[
("sensitive", "sensitive"),
("dmca", "dmca"),
("other", "other"),
],
help_text="The reason to report media to Openverse.",
max_length=20,
),
),
(
"description",
models.TextField(
blank=True,
help_text="The explanation on why media is being reported.",
max_length=500,
null=True,
),
),
(
"status",
models.CharField(
choices=[
("pending_review", "pending_review"),
("sensitive_filtered", "sensitive_filtered"),
("deindexed", "deindexed"),
("no_action", "no_action"),
],
default="pending_review",
max_length=20,
),
),
(
"media_obj",
models.ForeignKey(
db_column="identifier",
db_constraint=False,
help_text="The reference to the audio being reported.",
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="audio_report",
to="api.audio",
to_field="identifier",
),
),
],
options={
"abstract": False,
},
),
]
12 changes: 11 additions & 1 deletion api/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
AudioSet,
DeletedAudio,
MatureAudio,
NsfwReportAudio,
SensitiveAudio,
)
from api.models.image import (
DeletedImage,
Image,
ImageList,
ImageReport,
MatureImage,
NsfwReport,
SensitiveImage,
)
from api.models.image import DeletedImage, Image, ImageList, ImageReport, MatureImage
from api.models.media import (
DEINDEXED,
DMCA,
Expand Down
Loading

0 comments on commit 77dc679

Please sign in to comment.