Add image dimensions to models, and add backfill command

This commit is contained in:
Joakim Hellsén 2026-02-12 04:56:42 +01:00
commit 4727657285
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
7 changed files with 299 additions and 7 deletions

View file

@ -104,12 +104,26 @@ class Game(auto_prefetch.Model):
verbose_name="Box art URL",
)
box_art_file = models.FileField(
box_art_file = models.ImageField(
upload_to="games/box_art/",
blank=True,
null=True,
width_field="box_art_width",
height_field="box_art_height",
help_text="Locally cached box art image served from this site.",
)
box_art_width = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Width of cached box art image in pixels.",
)
box_art_height = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Height of cached box art image in pixels.",
)
owners = models.ManyToManyField(
Organization,
@ -332,12 +346,26 @@ class DropCampaign(auto_prefetch.Model):
default="",
help_text="URL to an image representing the campaign.",
)
image_file = models.FileField(
image_file = models.ImageField(
upload_to="campaigns/images/",
blank=True,
null=True,
width_field="image_width",
height_field="image_height",
help_text="Locally cached campaign image served from this site.",
)
image_width = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
)
image_height = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
)
start_at = models.DateTimeField(
null=True,
blank=True,
@ -577,12 +605,26 @@ class DropBenefit(auto_prefetch.Model):
default="",
help_text="URL to the benefit's image asset.",
)
image_file = models.FileField(
image_file = models.ImageField(
upload_to="benefits/images/",
blank=True,
null=True,
width_field="image_width",
height_field="image_height",
help_text="Locally cached benefit image served from this site.",
)
image_width = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
)
image_height = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
)
created_at = models.DateTimeField(
null=True,
help_text=("Timestamp when the benefit was created. This is from Twitch API and not auto-generated."),
@ -834,12 +876,26 @@ class RewardCampaign(auto_prefetch.Model):
default="",
help_text="URL to an image representing the reward campaign.",
)
image_file = models.FileField(
image_file = models.ImageField(
upload_to="reward_campaigns/images/",
blank=True,
null=True,
width_field="image_width",
height_field="image_height",
help_text="Locally cached reward campaign image served from this site.",
)
image_width = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
)
image_height = models.PositiveIntegerField(
null=True,
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
)
is_sitewide = models.BooleanField(
default=False,
help_text="Whether the reward campaign is sitewide.",