Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Remove SourceLogo #987

Merged
merged 2 commits into from
Oct 26, 2022
Merged
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
13 changes: 1 addition & 12 deletions api/catalog/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from django.contrib import admin

from catalog.api.admin.site import openverse_admin
from catalog.api.models import (
PENDING,
AudioReport,
ContentProvider,
ImageReport,
SourceLogo,
)
from catalog.api.models import PENDING, AudioReport, ContentProvider, ImageReport
from catalog.api.models.media import AbstractDeletedMedia, AbstractMatureMedia


Expand Down Expand Up @@ -73,13 +67,8 @@ def has_add_permission(self, *args, **kwargs):
admin.site.register(klass, MediaSubreportAdmin)


class InlineImage(admin.TabularInline):
model = SourceLogo


@admin.register(ContentProvider)
class ProviderAdmin(admin.ModelAdmin):
list_display = ("provider_name", "provider_identifier", "media_type")
search_fields = ("provider_name", "provider_identifier")
exclude = ("notes",)
inlines = [InlineImage]
16 changes: 16 additions & 0 deletions api/catalog/api/migrations/0051_delete_sourcelogo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.1 on 2022-10-24 23:48

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0050_audio_model_plural_names'),
]

operations = [
migrations.DeleteModel(
name='SourceLogo',
),
]
2 changes: 1 addition & 1 deletion api/catalog/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
OTHER,
PENDING,
)
from catalog.api.models.models import ContentProvider, SourceLogo, Tag
from catalog.api.models.models import ContentProvider, Tag
from catalog.api.models.oauth import (
OAuth2Registration,
OAuth2Verification,
Expand Down
5 changes: 0 additions & 5 deletions api/catalog/api/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class Meta:
db_table = "content_provider"


class SourceLogo(models.Model):
source = models.OneToOneField(ContentProvider, on_delete=models.CASCADE)
image = models.ImageField()


class Tag(OpenLedgerModel):
foreign_identifier = models.CharField(max_length=255, blank=True, null=True)
name = models.CharField(max_length=1000, blank=True, null=True)
Expand Down
19 changes: 3 additions & 16 deletions api/catalog/api/serializers/provider_serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from rest_framework import serializers

from drf_yasg.utils import swagger_serializer_method

from catalog.api.models import ContentProvider, SourceLogo
from catalog.api.models import ContentProvider


class ProviderSerializer(serializers.ModelSerializer):
Expand All @@ -18,8 +16,8 @@ class ProviderSerializer(serializers.ModelSerializer):
source="domain_name",
help_text="The URL of the source, e.g. https://www.flickr.com",
)
logo_url = serializers.SerializerMethodField(
help_text="The URL to a logo of the source.",
logo_url = serializers.ReadOnlyField(
default=None, help_text="Deprecated and unused. Always `null`."
)
media_count = serializers.SerializerMethodField(
help_text="The number of media items indexed from the source.",
Expand All @@ -35,17 +33,6 @@ class Meta:
"media_count",
]

@swagger_serializer_method(serializer_or_field=serializers.URLField)
def get_logo_url(self, obj):
try:
source_logo = obj.sourcelogo
except SourceLogo.DoesNotExist:
return None
logo_path = source_logo.image.url
request = self.context.get("request")
if request is not None:
return request.build_absolute_uri(logo_path)

def get_media_count(self, obj) -> int:
source_counts = self.context.get("source_counts")
return source_counts.get(obj.provider_identifier)
4 changes: 0 additions & 4 deletions api/catalog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
# Where to collect static files in production/development deployments
STATIC_ROOT = "/var/api_static_content/static"

# Logo uploads
MEDIA_ROOT = "/var/api_media/"
MEDIA_URL = "/media/"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/

Expand Down