Try adding imagekit just once

This commit is contained in:
2023-11-30 22:52:38 +01:00
parent 6696d38638
commit 61c10db0dd
6 changed files with 79 additions and 2 deletions

View File

@ -12,6 +12,8 @@ from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django_extensions.db.models import TimeStampedModel
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill
from music.allmusic import get_allmusic_slug, scrape_data_from_allmusic
from music.bandcamp import get_bandcamp_slug
from music.theaudiodb import lookup_album_from_tadb, lookup_artist_from_tadb
@ -32,6 +34,18 @@ class Artist(TimeStampedModel):
allmusic_id = models.CharField(max_length=100, **BNULL)
bandcamp_id = models.CharField(max_length=100, **BNULL)
thumbnail = models.ImageField(upload_to="artist/", **BNULL)
thumbnail_small = ImageSpecField(
source="thumbnail",
processors=[ResizeToFill(100)],
format="JPEG",
options={"quality": 60},
)
thumbnail_medium = ImageSpecField(
source="thumbnail",
processors=[ResizeToFill(300)],
format="JPEG",
options={"quality": 75},
)
class Meta:
unique_together = [["name", "musicbrainz_id"]]
@ -152,6 +166,18 @@ class Album(TimeStampedModel):
musicbrainz_releasegroup_id = models.CharField(max_length=255, **BNULL)
musicbrainz_albumartist_id = models.CharField(max_length=255, **BNULL)
cover_image = models.ImageField(upload_to="albums/", **BNULL)
cover_image_small = ImageSpecField(
source="cover_image",
processors=[ResizeToFill(100)],
format="JPEG",
options={"quality": 60},
)
cover_image_medium = ImageSpecField(
source="cover_image",
processors=[ResizeToFill(300)],
format="JPEG",
options={"quality": 75},
)
theaudiodb_id = models.CharField(max_length=255, unique=True, **BNULL)
theaudiodb_description = models.TextField(**BNULL)
theaudiodb_year_released = models.IntegerField(**BNULL)

View File

@ -93,6 +93,7 @@ INSTALLED_APPS = [
"django.contrib.humanize",
"django_filters",
"django_extensions",
"imagekit",
"storages",
"taggit",
"rest_framework.authtoken",

View File

@ -101,6 +101,7 @@ INSTALLED_APPS = [
"django.contrib.humanize",
"django_filters",
"django_extensions",
"imagekit",
"storages",
"taggit",
"rest_framework.authtoken",

View File

@ -141,7 +141,7 @@
<tr>
<td>{{scrobble.timestamp|naturaltime}}</td>
{% if scrobble.track.album.cover_image %}
<td><a href="{{scrobble.track.album.get_absolute_url}}"><img src="{{scrobble.track.album.cover_image.url}}" width=25 height=25 style="border:1px solid black;" /></aa></td>
<td><a href="{{scrobble.track.album.get_absolute_url}}"><img src="{{scrobble.track.album.cover_image_small.url}}" width=25 height=25 style="border:1px solid black;" /></aa></td>
{% else %}
<td><a href="{{scrobble.track.album.get_absolute_url}}">{{scrobble.track.album.name}}</a></td>
{% endif %}