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

Uncrispify service forms in seedDB #3103

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions python/nav/web/seeddb/page/service/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
from django.db import transaction
from django.urls import reverse

from crispy_forms.helper import FormHelper

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


class ServiceChoiceForm(forms.Form):
"""For for editing services"""
"""Form for editing services"""

def __init__(self, *args, **kwargs):
super(ServiceChoiceForm, self).__init__(*args, **kwargs)
Expand All @@ -46,8 +45,7 @@ def __init__(self, *args, **kwargs):
widget=forms.Select(attrs={'class': 'select2'}),
)

self.helper = FormHelper(self)
self.helper.form_tag = False
self.attrs = set_flat_form_attributes()

@staticmethod
def _build_checker_choices():
Expand Down Expand Up @@ -77,10 +75,7 @@ class ServiceForm(forms.Form):
handler = forms.CharField(widget=forms.HiddenInput)
netbox = forms.IntegerField(widget=forms.HiddenInput)

def __init__(self, *args, **kwargs):
super(ServiceForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
attrs = set_flat_form_attributes()


class ServicePropertyForm(forms.Form):
Expand All @@ -99,8 +94,7 @@ def __init__(self, *args, **kwargs):
for arg, descr in opt_args:
self.fields[arg] = forms.CharField(required=False, help_text=descr)

self.helper = FormHelper(self)
self.helper.form_tag = False
self.attrs = set_flat_form_attributes()


def service_edit(request, service_id=None):
Expand Down
9 changes: 6 additions & 3 deletions python/nav/web/templates/seeddb/service_netbox_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "seeddb/base.html" %}
{% load crispy_forms_tags %}

{% block content %}

Expand All @@ -16,11 +15,15 @@ <h4>
<form id="service_checker_add_form" action="" method="post">
<fieldset>
<legend>Add new service checker</legend>
{% crispy choice_form %}
{% if choice_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=choice_form %}
{% else %}
{{ choice_form }}
{% endif %}
<input type="submit" value="Continue" class="button small"/>
</fieldset>
</form>

</div>
</div>

Expand Down
13 changes: 10 additions & 3 deletions python/nav/web/templates/seeddb/service_property_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "seeddb/base.html" %}
{% load crispy_forms_tags %}

{% block content %}

Expand All @@ -20,9 +19,17 @@ <h4>
<form action="" method="post">
<fieldset>
<legend>Attributes</legend>
{% crispy service_form %}
{% if service_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=service_form %}
{% else %}
{{ service_form }}
{% endif %}
{% if property_form.fields %}
{% crispy property_form %}
{% if property_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=property_form %}
{% else %}
{{ property_form }}
{% endif %}
{% else %}
<div class="alert-box">
There are no attributes for this service.
Expand Down
Loading