Skip to content
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

Get rid of crispy-forms #2794

Closed
59 tasks done
Tracked by #2789 ...
hmpf opened this issue Jan 5, 2024 · 6 comments
Closed
59 tasks done
Tracked by #2789 ...

Get rid of crispy-forms #2794

hmpf opened this issue Jan 5, 2024 · 6 comments
Assignees
Labels
META I contain multitudes

Comments

@hmpf
Copy link
Contributor

hmpf commented Jan 5, 2024

crispy-forms needs to be upgraded to work with Django 4.2. This is a breeze.

Unfortunately, we also use crispy-forms-foundation, and newer crispy-forms-foundation needs Foundation 6. NAV is written to use Foundation 5.

This means either upgrading Foundation to 6 or replace Foundation 5 with something else or forking crispy-forms-foundation to work with foundation 5.

Rather than follow the house-of-cards-style upgrade path, we should instead look into throwing out crispy-forms entirely and replacing it with form templates in pure Django.

CSS-classes that are not in use, can safely be removed

  • select
  • checkbox

Other things that can be removed

  • form_show_errors is a template variable that is never set in context, so removable

Initial work

Form classes that use crispy-forms FormHelper:

These form classes have been identified as using crispy-forms FormHelper in some way, through Python code. Whether they are rendered using crispy-forms template tags has not been verified.

These could individually be altered into issues and self-assigned, or they could easily be grouped as one issue per file, if so desired.

#2981 can be used as a template, of sorts, that shows in a step-wise fashion how a conversion can be achieved.
#2994 can be used as a template for most input fields in edit- and add-forms, and introduces additional pattern - conversion of required fields.
#3000 introduces a reusable uncrispyfied field template.
#3008 introduces reusable uncrispyfied templates for CheckBox() and HelpField().

nav.web.styleguide

nav.web.alertprofiles

When all Alertprofile forms that use base_detail.html (most of them) are done, then #3075 can be done

nav.web.arnold

nav.web.devicehistory

nav.web.info

nav.web.ipdevinfo

nav.web.l2trace

nav.web.macwatch

nav.web.maintenance

nav.web.messages

nav.web.navlets

nav.web.portadmin

nav.web.radius

nav.web.seeddb.forms

nav.web.seeddb.page.vlan

nav.web.seeddb.page.management_profile

nav.web.seeddb.page.netbox

nav.web.sortedstats

nav.web.status2

nav.web.syslogger

nav.web.threshold

nav.web.useradmin

nav.web.webfront

Forms that are otherwise rendered through crispy-forms template tags

Other issues that have to do with removing crispy-forms

None other have been identified thus far (but their existence cannot be precluded)

@hmpf hmpf mentioned this issue Jan 5, 2024
2 tasks
@hmpf hmpf changed the title Upgrade crispy-forms (This means either upgrading Foundation to 6 or replace Foundation 5 or forking crispy-forms-foundation to work with foundation 5.) Upgrade crispy-forms Jan 5, 2024
@hmpf
Copy link
Contributor Author

hmpf commented Mar 1, 2024

There exists no official guide to upgrading from Foundation 5 to 6. Here's an unofficial one from 2016: Updating to Zurb Foundation 6, not.

@hmpf
Copy link
Contributor Author

hmpf commented Mar 1, 2024

If it is only the forms that use Foundation, we could just switch to a different theme in crispy-forms. We need to find out where and how Foundation is being used.

@hmpf
Copy link
Contributor Author

hmpf commented Mar 1, 2024

Direct use in python:

python/nav/web/radius/forms.py:24:from crispy_forms_foundation.layout import Layout, Row, Column, Submit
python/nav/web/navlets/forms.py:6:from crispy_forms_foundation import layout
python/nav/web/devicehistory/forms.py:23:from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column, Field
python/nav/web/messages/forms.py:20:from crispy_forms_foundation.layout import Submit
python/nav/web/l2trace/forms.py:18:from crispy_forms_foundation.layout import Layout, Row, Column, Submit, Field
python/nav/web/threshold/forms.py:21:from crispy_forms_foundation.layout import Layout, Fieldset, Submit, Row, Column
python/nav/web/crispyforms.py:20:from crispy_forms_foundation.layout import Field, Submit, Button
python/nav/web/ipdevinfo/forms.py:20:from crispy_forms_foundation.layout import Layout, Row, Column, Field, Submit
python/nav/web/styleguide.py:21:from crispy_forms_foundation.layout import Layout, Column, Row, Fieldset
python/nav/web/maintenance/forms.py:20:from crispy_forms_foundation.layout import Layout, Row, Column, Field
python/nav/web/alertprofiles/forms.py:27:from crispy_forms_foundation.layout import Layout, Row, Column, Field, Submit, HTML
python/nav/web/arnold/forms.py:22:from crispy_forms_foundation.layout import Layout, Fieldset, Div, Row, Submit, Column
python/nav/web/status2/forms.py:24:from crispy_forms_foundation.layout import (
python/nav/web/syslogger/forms.py:7:from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column, Field
python/nav/web/useradmin/forms.py:25:from crispy_forms_foundation.layout import (
python/nav/web/templates/foundation-5/README.txt:1:Place templates for globally overriding crispy_forms_foundation templates in this directory.
python/nav/web/portadmin/forms.py:20:from crispy_forms_foundation.layout import Layout, Row, Column, Submit
python/nav/web/info/forms.py:21:from crispy_forms_foundation.layout import Layout, Row, Column, Submit, Field
python/nav/web/webfront/forms.py:22:from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column, HTML, Submit
python/nav/web/sortedstats/forms.py:21:from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column
python/nav/web/seeddb/page/netbox/forms.py:23:from crispy_forms_foundation.layout import (
python/nav/web/seeddb/page/vlan.py:22:from crispy_forms_foundation.layout import Layout, Row, Column, Fieldset
python/nav/web/seeddb/forms/__init__.py:25:from crispy_forms_foundation.layout import Layout, Field, Fieldset, Row, Column

@hmpf
Copy link
Contributor Author

hmpf commented Mar 1, 2024

Usage in javascript. Number is count of times foundation is mentioned in the file, comments excluded.

5 python/nav/web/static/js/src/info_room_rack.js
4 python/nav/web/static/js/src/seeddb_add_patch.js
4 python/nav/web/static/js/src/plugins/delegate_tooltip.js
4 python/nav/web/static/js/libs/foundation.min.js
3 python/nav/web/static/js/src/subnetmatrix.js
3 python/nav/web/static/js/src/portadmin.js
3 python/nav/web/static/js/src/plugins/navlet_controller.js
3 python/nav/web/static/js/src/devicehistory.js
2 python/nav/web/static/js/src/seeddb.js
2 python/nav/web/static/js/src/main.js
2 python/nav/web/static/js/src/ipam/views/subnetallocator.js
2 python/nav/web/static/js/src/info_room.js
2 python/nav/web/static/js/libs/datatables.min.js
1 python/nav/web/static/js/src/webfront.js
1 python/nav/web/static/js/src/threshold.js
1 python/nav/web/static/js/src/status2/views.js
1 python/nav/web/static/js/src/radius.js
1 python/nav/web/static/js/src/plugins/navlets_controller.js
1 python/nav/web/static/js/src/netmap/control_view.js
1 python/nav/web/static/js/src/ipam/app.js
1 python/nav/web/static/js/require_config.js

Noe that the datatables we use seems to depend on Foundation as well.

@hmpf
Copy link
Contributor Author

hmpf commented Mar 1, 2024

Usage in html, {% load crispy_forms_tags%} and {% load crispy_forms_fields %} excluded. Number is count of times crispy is mentioned in the file.

3 python/nav/web/templates/webfront/preferences.html
3 python/nav/web/templates/useradmin/group_detail.html
3 python/nav/web/templates/useradmin/account_detail.html
2 python/nav/web/templates/seeddb/service_property_form.html
2 python/nav/web/templates/seeddb/management-profile/edit.html
2 python/nav/web/templates/seeddb/list.html
2 python/nav/web/templates/seeddb/edit_prefix.html
2 python/nav/web/templates/seeddb/edit_device_group.html
2 python/nav/web/templates/seeddb/edit.html
2 python/nav/web/templates/foundation-5/field.html
2 python/nav/web/templates/custom_crispy_templates/field_helptext_as_icon.html
1 python/nav/web/templates/webfront/login.html
1 python/nav/web/templates/useradmin/userinfo.html
1 python/nav/web/templates/useradmin/token_edit.html
1 python/nav/web/templates/threshold/set_threshold.html
1 python/nav/web/templates/syslogger/frag-search.html
1 python/nav/web/templates/status2/status.html
1 python/nav/web/templates/sortedstats/sortedstats.html
1 python/nav/web/templates/seeddb/service_netbox_form.html
1 python/nav/web/templates/seeddb/netbox_wizard.html
1 python/nav/web/templates/seeddb/edit_vlan.html
1 python/nav/web/templates/radius/error_log.html
1 python/nav/web/templates/radius/account_log.html
1 python/nav/web/templates/radius/account_charts.html
1 python/nav/web/templates/portadmin/base.html
1 python/nav/web/templates/navlets/status2_edit.html
1 python/nav/web/templates/navlets/room_map_view.html
1 python/nav/web/templates/navlets/room_location_status_edit.html
1 python/nav/web/templates/navlets/portadmin_view.html
1 python/nav/web/templates/navlets/graph_edit.html
1 python/nav/web/templates/navlets/alert_edit.html
1 python/nav/web/templates/messages/save.html
1 python/nav/web/templates/maintenance/new_task.html
1 python/nav/web/templates/macwatch/addmacwatch.html
1 python/nav/web/templates/l2trace/l2trace.html
1 python/nav/web/templates/ipdevinfo/sensor-details.html
1 python/nav/web/templates/ipdevinfo/search.html
1 python/nav/web/templates/ipdevinfo/modules.html
1 python/nav/web/templates/info/vlan/base.html
1 python/nav/web/templates/info/room/base.html
1 python/nav/web/templates/info/prefix/base.html
1 python/nav/web/templates/info/netboxgroup/list_groups.html
1 python/nav/web/templates/info/location/base.html
1 python/nav/web/templates/info/base.html
1 python/nav/web/templates/devicehistory/history_view.html
1 python/nav/web/templates/devicehistory/history_search.html
1 python/nav/web/templates/custom_crispy_templates/horizontal_checkbox.html
1 python/nav/web/templates/arnold/search.html
1 python/nav/web/templates/arnold/quarantinevlans.html
1 python/nav/web/templates/arnold/manualdetain.html
1 python/nav/web/templates/arnold/manualdetain-step2.html
1 python/nav/web/templates/arnold/justifications.html
1 python/nav/web/templates/arnold/edit_detention_profile.html
1 python/nav/web/templates/alertprofiles/timeperiod_form.html
1 python/nav/web/templates/alertprofiles/timeperiod_edit.html
1 python/nav/web/templates/alertprofiles/subscription_form.html
1 python/nav/web/templates/alertprofiles/base_detail.html

@lunkwill42
Copy link
Member

All tasks have been closed and the crispy-dependencies completely removed. It seems we are finally at the end of this. I guess the next step is start testing on Django 4.12 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
META I contain multitudes
Projects
None yet
Development

No branches or pull requests

2 participants