Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Move thumbnails to `MediaMixin` to provide the thumbnail field to audio sets
Dhruv Bhanushalidcfcc226be74
diff --git a/openverse_api/catalog/api/migrations/0039_audio_set_thumbs.py b/openverse_api/catalog/api/migrations/0039_audio_set_thumbs.pynew file mode 100644index 000000000..83ff131c7--- /dev/null+++ b/openverse_api/catalog/api/migrations/0039_audio_set_thumbs.py@@ -0,0 +1,18 @@+# Generated by Django 3.2.7 on 2021-10-11 15:48++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ('api', '0038_filetypes'),+ ]++ operations = [+ migrations.AddField(+ model_name='audioset',+ name='thumbnail',+ field=models.URLField(blank=True, help_text='The thumbnail for the media.', max_length=1000, null=True),+ ),+ ]diff --git a/openverse_api/catalog/api/models/media.py b/openverse_api/catalog/api/models/media.pyindex 415abbb46..6e52490bc 100644--- a/openverse_api/catalog/api/models/media.py+++ b/openverse_api/catalog/api/models/media.py@@ -25,10 +25,6 @@ class AbstractMedia(IdentifierMixin, MediaMixin, OpenLedgerModel):information common to all media types indexed by Openverse."""- thumbnail = models.URLField(- max_length=1000, blank=True, null=True, help_text="The thumbnail for the media."- )-watermarked = models.BooleanField(blank=True, null=True)license = models.CharField(max_length=50)diff --git a/openverse_api/catalog/api/models/mixins.py b/openverse_api/catalog/api/models/mixins.pyindex 898d2094e..047f6c30f 100644--- a/openverse_api/catalog/api/models/mixins.py+++ b/openverse_api/catalog/api/models/mixins.py@@ -53,6 +53,11 @@ class MediaMixin(models.Model):creator = models.CharField(max_length=2000, blank=True, null=True)creator_url = models.URLField(max_length=2000, blank=True, null=True)+ # Because all forms of media have a thumbnail for visual representation+ thumbnail = models.URLField(+ max_length=1000, blank=True, null=True, help_text="The thumbnail for the media."+ )+class Meta:abstract = True