Optionally serve housing counselor data from S3 #3107
Merged
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.
This commit introdces a new
HOUSING_COUNSELOR_S3
feature flag that unlocks serving of HUD housing counselor JSON and PDF from a fixed location on S3, instead of the default behavior of dynamically generating on the fly.This feature flag is configured to look in the URL for a query string parameter
s3=True
, e.g. visiting the URLhttp://localhost:8000/find-a-housing-counselor/?zipcode=18020&s3=True
This will query JSON housing counselor data used to fill out the template from files like
https://s3.amazonaws.com/files.consumerfinance.gov/a/assets/hud/jsons/18020.json
(this uses the
AWS_STORAGE_BUCKET_NAME
Django setting).The PDF download link then also changes to just download directly from a prerendered file on S3 like
https://s3.amazonaws.com/files.consumerfinance.gov/a/assets/hud/pdfs/18020.pdf
The pre-existing JSON data format differs slightly from that generated by the django-hud project, mainly by returning lists of languages/services as JSON lists as opposed to comma-delimited strings. For this reason, this commit also includes changes to the existing
housing_counselor.html
andhousing_counselor_pdf.html
files to assume a more standard JSON format.Additions
HOUSING_COUNSELOR_S3
feature flag enabled with a query string?s3=True
that enables using S3 for housing counselor JSON and PDFs.Changes
Testing
AWS_STORAGE_BUCKET_NAME=files.consumerfinance.gov
.Screenshots
Slight visual change: the PDF download link now (correctly?) includes the PDF icon as is consistent elsewhere on the site.
Notes
Checklist