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 14, 2024
1 parent dd2a52a commit 8a7bebb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
32 changes: 32 additions & 0 deletions benefits/core/migrations/0031_transitagency_logo.py
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,
),
),
]
24 changes: 24 additions & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from functools import cached_property
import importlib
import logging
import os
import uuid

from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.contrib.auth.models import Group, User
from django.db import models
from django.urls import reverse
Expand Down Expand Up @@ -126,6 +128,16 @@ def __str__(self):
return self.name


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


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


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

Expand Down Expand Up @@ -191,6 +203,18 @@ 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,
storage=FileSystemStorage,
help_text="The large version of the transit agency's logo.",
)
logo_small = models.ImageField(
default=None,
upload_to=agency_logo_small,
storage=FileSystemStorage,
help_text="The small version of the transit agency's logo.",
)

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

0 comments on commit 8a7bebb

Please sign in to comment.