From 25ce6c1c477cb8e3111d655828c0e61f670e40b5 Mon Sep 17 00:00:00 2001 From: Ilona Podliashanyk Date: Thu, 19 Sep 2024 18:01:18 +0200 Subject: [PATCH] Use non-crispy DeviceGroupForm in seeddb --- python/nav/web/seeddb/forms/__init__.py | 11 +++-------- python/nav/web/seeddb/page/netboxgroup.py | 1 - .../nav/web/templates/seeddb/edit_device_group.html | 5 ----- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 python/nav/web/templates/seeddb/edit_device_group.html diff --git a/python/nav/web/seeddb/forms/__init__.py b/python/nav/web/seeddb/forms/__init__.py index 6f67e1e897..fc866a275f 100644 --- a/python/nav/web/seeddb/forms/__init__.py +++ b/python/nav/web/seeddb/forms/__init__.py @@ -22,7 +22,7 @@ from django.utils.safestring import mark_safe from crispy_forms.helper import FormHelper -from crispy_forms_foundation.layout import Layout, Field, Fieldset, Row, Column +from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column from nav.django.forms import HStoreField from nav.web.crispyforms import LabelSubmit @@ -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 def __init__(self, *args, **kwargs): # If the form is based on an existing model instance, populate the @@ -380,13 +382,6 @@ def __init__(self, *args, **kwargs): initial = kwargs.setdefault('initial', {}) initial['netboxes'] = [n.pk for n in kwargs['instance'].netboxes.all()] forms.ModelForm.__init__(self, *args, **kwargs) - self.helper = FormHelper() - self.helper.form_tag = False - self.helper.layout = Layout( - 'id', - 'description', - Field('netboxes', css_class='select2'), - ) class Meta(object): model = NetboxGroup diff --git a/python/nav/web/seeddb/page/netboxgroup.py b/python/nav/web/seeddb/page/netboxgroup.py index 22e6fb8ddb..c11e812de1 100644 --- a/python/nav/web/seeddb/page/netboxgroup.py +++ b/python/nav/web/seeddb/page/netboxgroup.py @@ -118,7 +118,6 @@ def netboxgroup_edit(request, netboxgroup_id=None): DeviceGroupForm, netboxgroup_id, 'seeddb-netboxgroup-edit', - template='seeddb/edit_device_group.html', extra_context=extra_context, ) diff --git a/python/nav/web/templates/seeddb/edit_device_group.html b/python/nav/web/templates/seeddb/edit_device_group.html deleted file mode 100644 index 1d57c64635..0000000000 --- a/python/nav/web/templates/seeddb/edit_device_group.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "seeddb/edit.html" %} -{% load crispy_forms_tags %} -{% block crispyfields %} -{% crispy form %} -{% endblock %}