Skip to content

Commit

Permalink
feat: add a property for a small and large agency logo
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed Nov 7, 2024
1 parent 31dcf32 commit 7da368c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.1.2 on 2024-11-07 16:51

import benefits.core.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0030_enrollmentevent_extra_claims"),
]

operations = [
migrations.AddField(
model_name="transitagency",
name="logo_large",
field=models.ImageField(
default=None,
help_text="The large version of the transit agency's logo.",
upload_to=benefits.core.models.agency_logo_large,
),
),
migrations.AddField(
model_name="transitagency",
name="logo_small",
field=models.ImageField(
default=None,
help_text="The small version of the transit agency's logo.",
upload_to=benefits.core.models.agency_logo_small,
),
),
]
17 changes: 17 additions & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from functools import cached_property
import importlib
import logging
import os
import uuid

from django.conf import settings
Expand Down Expand Up @@ -126,6 +127,16 @@ def __str__(self):
return self.name


def agency_logo_small(instance, filename):
base, ext = os.path.splitext(filename)
return f"static/img/agencies/{instance.slug}-sm" + ext


def agency_logo_large(instance, filename):
base, ext = os.path.splitext(filename)
return f"static/img/agencies/{instance.slug}-lg" + ext


class TransitAgency(models.Model):
"""An agency offering transit service."""

Expand Down Expand Up @@ -191,6 +202,12 @@ class TransitAgency(models.Model):
help_text="The group of users who are allowed to do in-person eligibility verification and enrollment.",
related_name="+",
)
logo_large = models.ImageField(
default=None, upload_to=agency_logo_large, help_text="The large version of the transit agency's logo."
)
logo_small = models.ImageField(
default=None, upload_to=agency_logo_small, help_text="The small version of the transit agency's logo."
)

def __str__(self):
return self.long_name
Expand Down

0 comments on commit 7da368c

Please sign in to comment.