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

@ -0,0 +1,144 @@
# Generated by Django 6.0.2 on 2026-02-12 03:41
from __future__ import annotations
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
"""Add image height and width fields to DropBenefit, DropCampaign, Game, and RewardCampaign, then update ImageFields to use them.""" # noqa: E501
dependencies = [
("twitch", "0010_rewardcampaign_image_file_rewardcampaign_image_url"),
]
operations = [
migrations.AddField(
model_name="dropbenefit",
name="image_height",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="dropbenefit",
name="image_width",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="dropcampaign",
name="image_height",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="dropcampaign",
name="image_width",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="game",
name="box_art_height",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Height of cached box art image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="game",
name="box_art_width",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Width of cached box art image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="rewardcampaign",
name="image_height",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Height of cached image in pixels.",
null=True,
),
),
migrations.AddField(
model_name="rewardcampaign",
name="image_width",
field=models.PositiveIntegerField(
blank=True,
editable=False,
help_text="Width of cached image in pixels.",
null=True,
),
),
migrations.AlterField(
model_name="dropbenefit",
name="image_file",
field=models.ImageField(
blank=True,
height_field="image_height",
help_text="Locally cached benefit image served from this site.",
null=True,
upload_to="benefits/images/",
width_field="image_width",
),
),
migrations.AlterField(
model_name="dropcampaign",
name="image_file",
field=models.ImageField(
blank=True,
height_field="image_height",
help_text="Locally cached campaign image served from this site.",
null=True,
upload_to="campaigns/images/",
width_field="image_width",
),
),
migrations.AlterField(
model_name="game",
name="box_art_file",
field=models.ImageField(
blank=True,
height_field="box_art_height",
help_text="Locally cached box art image served from this site.",
null=True,
upload_to="games/box_art/",
width_field="box_art_width",
),
),
migrations.AlterField(
model_name="rewardcampaign",
name="image_file",
field=models.ImageField(
blank=True,
height_field="image_height",
help_text="Locally cached reward campaign image served from this site.",
null=True,
upload_to="reward_campaigns/images/",
width_field="image_width",
),
),
]