Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new SensitiveMedia and MediaReport models #3510

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
from django.contrib import admin

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 import (
PENDING,
Audio,
AudioReport,
ContentProvider,
Image,
ImageReport,
NsfwReport,
NsfwReportAudio,
)
from api.models.media import (
AbstractDeletedMedia,
AbstractMatureMedia,
AbstractSensitiveMedia,
)


admin.site = openverse_admin
Expand Down Expand Up @@ -56,11 +69,21 @@ class ImageReportAdmin(MediaReportAdmin):
media_specific_list_display = ("image_url",)


@admin.register(NsfwReport)
class NsfwReportAdmin(MediaReportAdmin):
media_specific_list_display = ("image_url",)


@admin.register(AudioReport)
class AudioReportAdmin(MediaReportAdmin):
media_specific_list_display = ("audio_url",)


@admin.register(NsfwReportAudio)
class NsfwReportAudioAdmin(MediaReportAdmin):
media_specific_list_display = ("audio_url",)


class MediaSubreportAdmin(admin.ModelAdmin):
exclude = ("media_obj",)
search_fields = ("media_obj__identifier",)
Expand All @@ -73,6 +96,7 @@ def has_add_permission(self, *args, **kwargs):

for klass in [
*AbstractMatureMedia.__subclasses__(),
*AbstractSensitiveMedia.__subclasses__(),
*AbstractDeletedMedia.__subclasses__(),
]:
admin.site.register(klass, MediaSubreportAdmin)
Expand Down
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
Loading