Преглед на файлове

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

Colin Powell преди 8 месеца
родител
ревизия
0bda3f6fd8
променени са 3 файла, в които са добавени 16 реда и са изтрити 7 реда
  1. 7 0
      vrobbler/apps/beers/admin.py
  2. 7 7
      vrobbler/apps/beers/models.py
  3. 2 0
      vrobbler/apps/scrobbles/constants.py

+ 7 - 0
vrobbler/apps/beers/admin.py

@@ -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"

+ 7 - 7
vrobbler/apps/beers/models.py

@@ -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
     )

+ 2 - 0
vrobbler/apps/scrobbles/constants.py

@@ -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",
 }