-
Notifications
You must be signed in to change notification settings - Fork 39
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
Uncrispyfy DeviceGroupForm in seeddb #2994
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
Test results 9 files 9 suites 8m 57s ⏱️ Results for commit 7fe2f74. ♻️ This comment has been updated with latest results. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2994 +/- ##
==========================================
+ Coverage 56.30% 56.59% +0.28%
==========================================
Files 602 602
Lines 43728 43728
Branches 48 48
==========================================
+ Hits 24622 24746 +124
+ Misses 19094 18970 -124
Partials 12 12 ☔ View full report in Codecov by Sentry. |
Seems like edit- and add-forms in Anyway, with |
Is mostly universal, yet fields that require extra classes (like f.e. select2) need extra logic. Meaning that with few tweaks this template has a potential to fix all add/edit templates in /seeddb. Will finish and showcase this in a separate PR fixup
6af5ca9
to
25ce6c1
Compare
@@ -372,6 +372,8 @@ class DeviceGroupForm(forms.ModelForm): | |||
netboxes = forms.ModelMultipleChoiceField( | |||
queryset=Netbox.objects.all(), required=False | |||
) | |||
netboxes.widget.attrs.update({"class": "select2"}) | |||
no_crispy = True |
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.
When crispy is gone we will no longer need "no_crsipy" for choosing which form to show. It is still useful to hold extra form attributes though, like with the filter forms.
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.
Yes, we can remove no_crispy = True
completely once all edit/add forms i seeddb are converted. Because then we can safely remove the {% if form.no_crispy %}
-block from the seeddb/edit.html
that was added in this PR and render {% include "seeddb/_form_fields.html" %}
by default there
Are you considerimg adding django-widget-tweaks for the special casing? |
I was really tempted to add it while working on this one and investigating the situation with other edit/add forms in seeddb, but there was not overwhelmingly definite need so far. But will see how it goes with conversion of other fields, might happen that |
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.
Only a small cosmetic suggestion
Co-authored-by: Johanna England <[email protected]>
Closes #2988
Introduces extra pattern - uncrispyfying of the required fields.