-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing the size of the quotas/forms.py and views.py #1315
Conversation
return initial | ||
|
||
|
||
class QuotaSuspensionType(TextChoices): |
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.
Could also split this out into a forms/constants.py
quotas/forms/base.py
Outdated
from quotas import validators | ||
from quotas.constants import QUOTA_ORIGIN_EXCLUSIONS_FORMSET_PREFIX | ||
|
||
CATEGORY_HELP_TEXT = "Categories are required for the TAP database but will not appear as a TARIC3 object in your workbasket" |
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.
These could also go in a constants file but for now it's probably fine for them to live in here
from geo_areas.models import GeographicalArea | ||
from quotas import models | ||
from quotas import validators | ||
from quotas.constants import QUOTA_EXCLUSIONS_FORMSET_PREFIX |
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.
Looks like the only values we have in this constants file are used in forms only so I think it makes sense to move this to quotas/forms/constants.py
and add some of the other ones that appear in here. Some might need renaming to avoid clashes
@@ -0,0 +1,309 @@ | |||
from crispy_forms_gds.helper import FormHelper | |||
|
|||
# from crispy_forms_gds.layout import Button |
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.
Commented code
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1315 +/- ##
==========================================
- Coverage 93.18% 93.16% -0.02%
==========================================
Files 643 651 +8
Lines 49409 49556 +147
Branches 5305 5308 +3
==========================================
+ Hits 46041 46171 +130
- Misses 2711 2728 +17
Partials 657 657 ☔ View full report in Codecov by Sentry. |
Refactor of
quotas/views.py
andforms.py
Why
Both the
views.py
andforms.py
files are getting large (>1,000 lines long)These are only going to grow further as we add functionality. Reducing the size of the files makes them easier to comprehend.
What
forms
andviews
folder.forms.py
andviews.py
files to bebase.py
and puts them in the respective folders.wizards.py
filesDefinitions
model to adefinitions.py
fileviews/mixins.py
react_forms.py
Note that the BulkQuotaDefinitionCreate wizard is a work in progress.