Feat: agency logos configurable via Admin #2514
Open
+94
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #2489
This PR implements storing the agency logos as a property on the
TransiAgency
model. The logos are saved to the application's local filesystem.Notes
Pending work (for a followup PR)
modal--agency-selector
template to use the newpng
logos and ensure that the newpng
logos display correctly on the browser (initial testing shows that the aspect ratio is off)The logo's file format
We expect the logo to be uploaded to be a
.png
file and smaller than 1MB (the default value of theclient_max_body_size size
nginx directive) due to the current nginx configuration. Otherwise, a413 request entity too large
error will be raised. If we expect larger files, we should explicitly setclient_max_body_size size
to a larger size innginx.conf
.Updating a logo
Currently, an existing logo is not overwritten if a new logo is uploaded. Instead, the new logo has the same name as the old logo but with a random string appended to the end of it.
Do we want this behavior or do we prefer to overwrite the files? If we prefer an overwrite, we may need to overrideFor the current iteration we will use this default behavior but in the future we will implement file management improvements.save
inFileSystemStorage
.Reviewing
Assuming we start from the
main
branch, withDJANGO_DB_DIR=.
, and from an exited dev containergit status
)docker compose build --no-cache client
to rebuild the app image.env
setDJANGO_DB_DIR=/home/calitp/app/data
compose.yml
, set thevolumes
of theclient
service to- ./:/home/calitp/app/data
(discard this change after this review)docker compose up -d client
to start a new app container mimicking the location of the persistent storage in the deploymentspng
for a transit agency (you can use the same file for both the small and the large logo)Exec
window (click on the app container and navigate to theExec
tab) ordocker compose exec -ti client /bin/bash
to connect to running container, confirm that the files (cst-sm.png
andcst-lg.png
, for example if the selected transit agency was CST) were created in/home/calitp/app/data/uploads/agencies