-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor: field defaults, optional fields, templates #2471
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
c14e109
to
8d1cd32
Compare
a088943
to
54b2042
Compare
56165d4
to
6012bff
Compare
321538f
to
7759cc7
Compare
6f4337f
to
e255665
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of nice refactors in this PR @thekaveman!
I thought these were really great changes:
- removing
null=True
for fields where it was not truly needed and default empty string worked just as well / is better - making more fields optional (basically allowing for saving an empty, inactive object that can be filled out later)
- fixing things like
group_id
andlabel
not allowing blank
I have two pieces of feedback:
- a requested change for the default values for TransitAgency's info fields
- a question on validation behavior
Let me know if you want to talk through any of these. Thanks!
dfe4ab9
to
034bcaf
Compare
034bcaf
to
6f0ed51
Compare
Rebased with new commit
This makes it less likely that an agency could go live with a misconfigured flow. Thanks for continuing to push on this one Angela, I think this is definitely the better outcome. Test this scenario
|
slug field is a SlugField for validation
- compute template fields by default - allow overriding templates
- compute some template fields by default - allow overriding templates
further simplify template requirements for flows rename agency card templates into standard naming pattern: {prefix}--{agency.slug}--agency-card.html where {prefix} is e.g. eligibility/start or enrollment/success
when active=True, validate that: - there are values for user-facing info fields like names, logos, phone, etc. - transit processor is configured correctly, if any - templates exist
when the flow's agency.active=True, validate that templates exist consolidate other EnrollmentFlow.clean() tests
change default to empty string these are stored as the empty string when blank=True Django recommends against null=True on TextFields: https://docs.djangoproject.com/en/5.1/ref/models/fields/#null
keep track of all field and template errors separately raise a ValidationError from either when present
this field is now captured on EnrollmentFlow with the other Eligibility API fields
TransitAgency cleans all of its associated EnrollmentFlows, to ensure that an agency doesn't go live with partially configured flows since TransitAgency won't have fields from EnrollmentFlow, any ValidationError that bubbles would raise a new error in Django Admin instead, catch and rethrow a ValidationError indicating the problem flow
6f0ed51
to
a8c40bb
Compare
I really like these latest changes where benefits/benefits/core/models.py Line 633 in a8c40bb
so that the user can still see the particular validation errors when an Following the testing steps, the validity of an The only downside I guess of making this change is that if the |
Ahh @lalver1 that's a really good point!! 😭 Yes, I agree with you -- I'm going to update that commit one more time 🤞 |
whether or not the agency is marked as Active since TransitAgency.clean() will call .clean() on each of its EnrollmentFlows and raise a generic error, we want to be able to see the specific problem on the EnrollmentFlow if any
Agreed, great suggestion @lalver1! It makes the scenario described in #2471 (comment), where invalid flows are linked to transit agencies, pretty much impossible, which is great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on all this @thekaveman!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @thekaveman and @angela-tran!
This PR is another step along the way of making it easier and faster to configure new
TransitAgency
andEnrollmentFlow
instances, while also ensuring a valid configuration for instances that are going live on the app.Changes
TransitAgency
slug
field a DjangoSlugField
to enforce the slugness; this field is now used to calculate template paths as welllong_name
,phone
from CST defaultsslug
following our established pattern, e.g.core/index--{slug}.html
andeligibility/index--{slug}.html
active=True
and saving validates some fields (e.g. info fields, templates must exist, all associated flows must be valid)EnrollmentFlow
and no longer needed onTransitAgency
EnrollmentFlow
system_name
field a DjangoSlugField
to enforce slugness; this field is now used to calculate template paths as wellsystem_name
orslug
following our established pattern, e.g.eligibility/start--{system_name}.html
andenrollment/success--{slug}.html
courtesy-card
eligibility/start--{slug}-agency-card.html
EnrollmentFlow
has an activeTransitAgency
, saving validates that templates exist and that either claims verification or Eligibility API verification is configured correctly.Reviewing
bin/reset_db.sh
with default fixturesTransitAgency
instances can be created with only theslug
field providedTransitAgency
requires certain info fields to have valuesTransitAgency
requires templates to exist, and the defaults are calculated from theslug
TransitAgency
requires all of its associatedEnrollmentFlow
s to be valid.EnrollmentFlow
with an activeTransitAgency
requires a valid claims or Eligibility API verification configuration.EnrollmentFlow
with an activeTransitAgency
requires templates to exist, and defaults are calculated from thesystem_name
orTransitAgency.slug
.