From 8025f3b563c392a2a66fdec7ec0b465d5ebbb9c5 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 17 Oct 2024 08:56:31 +0200 Subject: [PATCH 1/4] Change comment to not mention crispy --- python/nav/web/seeddb/forms/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/nav/web/seeddb/forms/__init__.py b/python/nav/web/seeddb/forms/__init__.py index e2170eef9a..5bdc5eef0b 100644 --- a/python/nav/web/seeddb/forms/__init__.py +++ b/python/nav/web/seeddb/forms/__init__.py @@ -126,7 +126,7 @@ def cut_branch(field, klass, pk): return [c for c in field.choices if c[0] not in descendant_ids] -# non-crispy helpers +# helpers def get_single_layout(heading, row): From 1379c1b5202ae611badad8f1b0af773ce3ad51b9 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 17 Oct 2024 08:58:51 +0200 Subject: [PATCH 2/4] Remove checks if form has been uncrispified All SeedDB forms are uncrispified by now --- python/nav/web/templates/seeddb/edit.html | 12 +++--------- python/nav/web/templates/seeddb/list.html | 11 +---------- .../web/templates/seeddb/service_netbox_form.html | 6 +----- .../web/templates/seeddb/service_property_form.html | 12 ++---------- 4 files changed, 7 insertions(+), 34 deletions(-) diff --git a/python/nav/web/templates/seeddb/edit.html b/python/nav/web/templates/seeddb/edit.html index 0c68208a30..a4d0cf0a76 100644 --- a/python/nav/web/templates/seeddb/edit.html +++ b/python/nav/web/templates/seeddb/edit.html @@ -1,6 +1,4 @@ {% extends "seeddb/base.html" %} -{% load crispy_forms_tags %} - {% block base_header_additional_head %} {{ block.super }} @@ -41,13 +39,9 @@

{{ title }}
Attributes - {% if form.attrs %} - {% include 'custom_crispy_templates/_form_content.html' %} - {% else %} - {% block crispyfields %} - {{ form|crispy }} - {% endblock %} - {% endif %} + {% block crispyfields %} + {% include 'custom_crispy_templates/_form_content.html' %} + {% endblock %}
diff --git a/python/nav/web/templates/seeddb/list.html b/python/nav/web/templates/seeddb/list.html index d1ff5bc3ca..f286f4a9a4 100644 --- a/python/nav/web/templates/seeddb/list.html +++ b/python/nav/web/templates/seeddb/list.html @@ -1,23 +1,14 @@ {% extends "seeddb/base.html" %} -{% load crispy_forms_tags %} {% block content %} {% if filter_form %} {% if filter_form.base_fields|length >= 3 %} - {% if filter_form.attrs %} - {% include 'custom_crispy_templates/flat_form.html' with form=filter_form %} - {% else %} - {{ filter_form }} - {% endif %} + {% include 'custom_crispy_templates/flat_form.html' with form=filter_form %} {% else %}
- {% if filter_form.attrs %} {% include 'custom_crispy_templates/flat_form.html' with form=filter_form %} - {% else %} - {% crispy filter_form %} - {% endif %}
{% endif %} diff --git a/python/nav/web/templates/seeddb/service_netbox_form.html b/python/nav/web/templates/seeddb/service_netbox_form.html index a2024f9c1f..72c6059000 100644 --- a/python/nav/web/templates/seeddb/service_netbox_form.html +++ b/python/nav/web/templates/seeddb/service_netbox_form.html @@ -15,11 +15,7 @@

Add new service checker - {% if choice_form.attrs %} - {% include 'custom_crispy_templates/_form_content.html' with form=choice_form %} - {% else %} - {{ choice_form }} - {% endif %} + {% include 'custom_crispy_templates/_form_content.html' with form=choice_form %}
diff --git a/python/nav/web/templates/seeddb/service_property_form.html b/python/nav/web/templates/seeddb/service_property_form.html index 4c9c50bfe1..b93706168b 100644 --- a/python/nav/web/templates/seeddb/service_property_form.html +++ b/python/nav/web/templates/seeddb/service_property_form.html @@ -19,17 +19,9 @@

Attributes - {% if service_form.attrs %} - {% include 'custom_crispy_templates/_form_content.html' with form=service_form %} - {% else %} - {{ service_form }} - {% endif %} + {% include 'custom_crispy_templates/_form_content.html' with form=service_form %} {% if property_form.fields %} - {% if property_form.attrs %} - {% include 'custom_crispy_templates/_form_content.html' with form=property_form %} - {% else %} - {{ property_form }} - {% endif %} + {% include 'custom_crispy_templates/_form_content.html' with form=property_form %} {% else %}
There are no attributes for this service. From 4ca48c5651dec35b896dec248b21179a2a1af5ca Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 17 Oct 2024 08:59:07 +0200 Subject: [PATCH 3/4] Rename block to not mention crispy --- python/nav/web/templates/seeddb/edit.html | 2 +- python/nav/web/templates/seeddb/edit_prefix.html | 2 +- python/nav/web/templates/seeddb/edit_vlan.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/nav/web/templates/seeddb/edit.html b/python/nav/web/templates/seeddb/edit.html index a4d0cf0a76..3fd9f1901a 100644 --- a/python/nav/web/templates/seeddb/edit.html +++ b/python/nav/web/templates/seeddb/edit.html @@ -39,7 +39,7 @@

{{ title }}
Attributes - {% block crispyfields %} + {% block formfields %} {% include 'custom_crispy_templates/_form_content.html' %} {% endblock %}
diff --git a/python/nav/web/templates/seeddb/edit_prefix.html b/python/nav/web/templates/seeddb/edit_prefix.html index 1c81a208fc..cd4e24761c 100644 --- a/python/nav/web/templates/seeddb/edit_prefix.html +++ b/python/nav/web/templates/seeddb/edit_prefix.html @@ -1,5 +1,5 @@ {% extends "seeddb/edit.html" %} -{% block crispyfields %} +{% block formfields %} {{ block.super }} {% include 'custom_crispy_templates/_form_content.html' with form=vlan_form %} {% endblock %} diff --git a/python/nav/web/templates/seeddb/edit_vlan.html b/python/nav/web/templates/seeddb/edit_vlan.html index 41dc68e875..49a808f9f9 100644 --- a/python/nav/web/templates/seeddb/edit_vlan.html +++ b/python/nav/web/templates/seeddb/edit_vlan.html @@ -1,5 +1,5 @@ {% extends "seeddb/edit.html" %} -{% block crispyfields %} +{% block formfields %}

Net type
{{ object.net_type }}

From f9e31db30f0ff6b59c7f4b0ed931c17052e5affb Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 17 Oct 2024 08:59:58 +0200 Subject: [PATCH 4/4] Remove not needed set_flat_form_attributes calls They can be removed since they do not set anything --- python/nav/web/seeddb/page/service/edit.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/python/nav/web/seeddb/page/service/edit.py b/python/nav/web/seeddb/page/service/edit.py index 146528691e..a52443525a 100644 --- a/python/nav/web/seeddb/page/service/edit.py +++ b/python/nav/web/seeddb/page/service/edit.py @@ -24,7 +24,6 @@ from nav.models.service import Service, ServiceProperty from nav.models.manage import Netbox -from nav.web.crispyforms import set_flat_form_attributes from nav.web.servicecheckers import get_description, load_checker_classes from nav.web.message import new_message, Messages from nav.web.seeddb.page.service import ServiceInfo @@ -45,8 +44,6 @@ def __init__(self, *args, **kwargs): widget=forms.Select(attrs={'class': 'select2'}), ) - self.attrs = set_flat_form_attributes() - @staticmethod def _build_checker_choices(): checkers = load_checker_classes() @@ -75,8 +72,6 @@ class ServiceForm(forms.Form): handler = forms.CharField(widget=forms.HiddenInput) netbox = forms.IntegerField(widget=forms.HiddenInput) - attrs = set_flat_form_attributes() - class ServicePropertyForm(forms.Form): """Form for editing service properties""" @@ -94,8 +89,6 @@ def __init__(self, *args, **kwargs): for arg, descr in opt_args: self.fields[arg] = forms.CharField(required=False, help_text=descr) - self.attrs = set_flat_form_attributes() - def service_edit(request, service_id=None): """Controller for editing services"""