[beers] Fix error in cover reference, add adminf or beer producers

This commit is contained in:
2024-10-22 17:44:46 -04:00
parent 59765b14ca
commit 0bda3f6fd8
3 changed files with 16 additions and 7 deletions

View File

@ -10,6 +10,13 @@ class BeerInline(admin.TabularInline):
extra = 0
@admin.register(Beer)
class BeerProducer(admin.ModelAdmin):
date_hierarchy = "created"
list_display = ("uuid",)
search_fields = ("name",)
@admin.register(Beer)
class BeerAdmin(admin.ModelAdmin):
date_hierarchy = "created"

View File

@ -14,6 +14,7 @@ class BeerProducer(TimeStampedModel):
description = models.TextField(**BNULL)
location = models.CharField(max_length=255, **BNULL)
beeradvocate_id = models.CharField(max_length=255, **BNULL)
untappd_id = models.CharField(max_length=255, **BNULL)
def find_or_create(cls, title: str) -> "BeerProducer":
return cls.objects.filter(title=title).first()
@ -27,22 +28,21 @@ class Beer(ScrobblableMixin):
non_alcoholic = models.BooleanField(default=False)
beeradvocate_id = models.CharField(max_length=255, **BNULL)
beeradvocate_score = models.SmallIntegerField(**BNULL)
beeradvocate_image = models.ImageField(
upload_to="beers/beeradvcoate/", **BNULL
)
beeradvocate_image_small = ImageSpecField(
source="cover",
untappd_image = models.ImageField(upload_to="beers/untappd/", **BNULL)
untappd_image_small = ImageSpecField(
source="untappd_image",
processors=[ResizeToFit(100, 100)],
format="JPEG",
options={"quality": 60},
)
beeradvocate_image_medium = ImageSpecField(
source="cover",
untappd_image_medium = ImageSpecField(
source="untappd_image",
processors=[ResizeToFit(300, 300)],
format="JPEG",
options={"quality": 75},
)
untappd_id = models.CharField(max_length=255, **BNULL)
untappd_rating = models.FloatField(**BNULL)
producer = models.ForeignKey(
BeerProducer, on_delete=models.DO_NOTHING, **BNULL
)

View File

@ -30,6 +30,7 @@ SCROBBLE_CONTENT_URLS = {
"-i": "https://www.imdb.com/title/",
"-s": "https://www.thesportsdb.com/event/",
"-g": "https://boardgamegeek.com/boardgame/",
"-d": "https://beeradvocate.com/beer/profile/",
"-b": "https://www.amazon.com/",
"-t": "https://app.todoist.com/app/task/{id}",
}
@ -42,6 +43,7 @@ MANUAL_SCROBBLE_FNS = {
"-s": "manual_scrobble_event",
"-i": "manual_scrobble_video",
"-g": "manual_scrobble_board_game",
"-d": "manual_scrobble_beer",
"-w": "manual_scrobble_webpage",
"-t": "manual_scrobble_task",
}