[beers] Fix error in cover reference, add adminf or beer producers
This commit is contained in:
@ -10,6 +10,13 @@ class BeerInline(admin.TabularInline):
|
|||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Beer)
|
||||||
|
class BeerProducer(admin.ModelAdmin):
|
||||||
|
date_hierarchy = "created"
|
||||||
|
list_display = ("uuid",)
|
||||||
|
search_fields = ("name",)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Beer)
|
@admin.register(Beer)
|
||||||
class BeerAdmin(admin.ModelAdmin):
|
class BeerAdmin(admin.ModelAdmin):
|
||||||
date_hierarchy = "created"
|
date_hierarchy = "created"
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class BeerProducer(TimeStampedModel):
|
|||||||
description = models.TextField(**BNULL)
|
description = models.TextField(**BNULL)
|
||||||
location = models.CharField(max_length=255, **BNULL)
|
location = models.CharField(max_length=255, **BNULL)
|
||||||
beeradvocate_id = 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":
|
def find_or_create(cls, title: str) -> "BeerProducer":
|
||||||
return cls.objects.filter(title=title).first()
|
return cls.objects.filter(title=title).first()
|
||||||
@ -27,22 +28,21 @@ class Beer(ScrobblableMixin):
|
|||||||
non_alcoholic = models.BooleanField(default=False)
|
non_alcoholic = models.BooleanField(default=False)
|
||||||
beeradvocate_id = models.CharField(max_length=255, **BNULL)
|
beeradvocate_id = models.CharField(max_length=255, **BNULL)
|
||||||
beeradvocate_score = models.SmallIntegerField(**BNULL)
|
beeradvocate_score = models.SmallIntegerField(**BNULL)
|
||||||
beeradvocate_image = models.ImageField(
|
untappd_image = models.ImageField(upload_to="beers/untappd/", **BNULL)
|
||||||
upload_to="beers/beeradvcoate/", **BNULL
|
untappd_image_small = ImageSpecField(
|
||||||
)
|
source="untappd_image",
|
||||||
beeradvocate_image_small = ImageSpecField(
|
|
||||||
source="cover",
|
|
||||||
processors=[ResizeToFit(100, 100)],
|
processors=[ResizeToFit(100, 100)],
|
||||||
format="JPEG",
|
format="JPEG",
|
||||||
options={"quality": 60},
|
options={"quality": 60},
|
||||||
)
|
)
|
||||||
beeradvocate_image_medium = ImageSpecField(
|
untappd_image_medium = ImageSpecField(
|
||||||
source="cover",
|
source="untappd_image",
|
||||||
processors=[ResizeToFit(300, 300)],
|
processors=[ResizeToFit(300, 300)],
|
||||||
format="JPEG",
|
format="JPEG",
|
||||||
options={"quality": 75},
|
options={"quality": 75},
|
||||||
)
|
)
|
||||||
untappd_id = models.CharField(max_length=255, **BNULL)
|
untappd_id = models.CharField(max_length=255, **BNULL)
|
||||||
|
untappd_rating = models.FloatField(**BNULL)
|
||||||
producer = models.ForeignKey(
|
producer = models.ForeignKey(
|
||||||
BeerProducer, on_delete=models.DO_NOTHING, **BNULL
|
BeerProducer, on_delete=models.DO_NOTHING, **BNULL
|
||||||
)
|
)
|
||||||
|
|||||||
@ -30,6 +30,7 @@ SCROBBLE_CONTENT_URLS = {
|
|||||||
"-i": "https://www.imdb.com/title/",
|
"-i": "https://www.imdb.com/title/",
|
||||||
"-s": "https://www.thesportsdb.com/event/",
|
"-s": "https://www.thesportsdb.com/event/",
|
||||||
"-g": "https://boardgamegeek.com/boardgame/",
|
"-g": "https://boardgamegeek.com/boardgame/",
|
||||||
|
"-d": "https://beeradvocate.com/beer/profile/",
|
||||||
"-b": "https://www.amazon.com/",
|
"-b": "https://www.amazon.com/",
|
||||||
"-t": "https://app.todoist.com/app/task/{id}",
|
"-t": "https://app.todoist.com/app/task/{id}",
|
||||||
}
|
}
|
||||||
@ -42,6 +43,7 @@ MANUAL_SCROBBLE_FNS = {
|
|||||||
"-s": "manual_scrobble_event",
|
"-s": "manual_scrobble_event",
|
||||||
"-i": "manual_scrobble_video",
|
"-i": "manual_scrobble_video",
|
||||||
"-g": "manual_scrobble_board_game",
|
"-g": "manual_scrobble_board_game",
|
||||||
|
"-d": "manual_scrobble_beer",
|
||||||
"-w": "manual_scrobble_webpage",
|
"-w": "manual_scrobble_webpage",
|
||||||
"-t": "manual_scrobble_task",
|
"-t": "manual_scrobble_task",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user