DRAFT django modernization#1564
Draft
annamontare-nava wants to merge 34 commits into
Draft
Conversation
Moved `phone_regex` validator up to the apps level and use it for in both `accounts/models.py` and `dot_ext/models.py`.
This is to align to the spec. Also, add a TODO comment about something confusing
This should make all the models consistently using TextField + URLValidator for URLs
This matches all the other URLs
Best practice is to commit migrations in the same commit as the changes to the models, so I will try to do this going forward.
This is the default for URLValidator, but we set it explicitly on the TextField to make it clear.
This does suggest that it might be easy for the different fields to become out of sync.
Contributor
Author
|
Noticed that a lot of fields are named "uri" when it might be more specific to say "url". I assume this would not be worth changing? |
Change the max_length to match the associated field, and use the same validator as in the model.
Will be mentioned to reviewers
Contributor
|
@annamontare-nava what is the latest here? Will this branch be picked up again in the future? |
Contributor
Author
I think Jimmy suggested I prioritize other work, so haven't worked on it in a bit, but I'd like to pick it up in the future and finish the work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What needs to happen to get this ready for review:
JIRA Ticket:
epic: BB2-4543
What Does This PR Do?
Changes to Django models to migrate
CharField's toTextField's, makemax_lengthsettings consistent with specs, and align validators across fields.Also, fix a doc comment and remove duplicate code.
I did not include Ruff changes to hopefully make this easier to review.
What Should Reviewers Watch For?
If you're reviewing this PR, please check for these things in particular:
max_lengthseemed to match what oauth2_provider had formax_length, but not the actual length of the values. I changed them to match the actual length, and left a note, but would we prefer having them match what's in oauth2_provider?statefields still have amax_length?For fields that are URLs, I chose to make all of them
TextField's withURLValidator's and an explicitmax_lengthof 2048. Counterproposals:- Make all URLs
URLField's. Pros: uses the tools Django provides, arguably what a new person to the project might expect the fields to be. Cons: Is aCharFieldsubclass; there have been issues with the defaultmax_lengthin the past, so we'd have to set a larger one.- Make a subclass of
TextFieldthat includes the validator and our chosenmax_length, and make all URLs use that. Pros: It's aTextField, codifies the consistent handling of URLs across models. Cons: might still be easy to forget in new code.Validation
What Security Implications Does This PR Have?
Please indicate if this PR does any of the following:
security engineer's approval.
Any Migrations?
etc)