Skip to content

Commit

Permalink
Use newer way of uncrispifying forms
Browse files Browse the repository at this point in the history
This removes our old idea of adding templates and uses the new way that reimplemented crispy fields
  • Loading branch information
johannaengland committed Oct 10, 2024
1 parent 6a7754b commit 8339f1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 3 additions & 1 deletion python/nav/web/seeddb/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from nav.models.cabling import Cabling
from nav.oids import OID
from nav.web.crispyforms import set_flat_form_attributes

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -312,7 +313,6 @@ class DeviceGroupForm(forms.ModelForm):
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
Expand All @@ -322,6 +322,8 @@ def __init__(self, *args, **kwargs):
initial['netboxes'] = [n.pk for n in kwargs['instance'].netboxes.all()]
forms.ModelForm.__init__(self, *args, **kwargs)

self.attrs = set_flat_form_attributes()

class Meta(object):
model = NetboxGroup
fields = '__all__'
Expand Down
3 changes: 0 additions & 3 deletions python/nav/web/templates/seeddb/_form_fields.html

This file was deleted.

6 changes: 2 additions & 4 deletions python/nav/web/templates/seeddb/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ <h4>{{ title }}
<form class="seeddb-edit" action="" method="post">
<fieldset>
<legend>Attributes</legend>
{% if form.no_crispy %}
{% block formfields %}
{% include "seeddb/_form_fields.html" %}
{% endblock %}
{% if form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' %}
{% else %}
{% block crispyfields %}
{{ form|crispy }}
Expand Down

0 comments on commit 8339f1e

Please sign in to comment.