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 ErrorLogSearchForm #3129

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
32 changes: 21 additions & 11 deletions python/nav/web/radius/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column, Submit
from nav.web.crispyforms import (
set_flat_form_attributes,
FormColumn,
FormRow,
SubmitField,
)

from nav.util import is_valid_cidr

Expand Down Expand Up @@ -146,17 +152,21 @@ class ErrorLogSearchForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ErrorLogSearchForm, self).__init__(*args, **kwargs)
css_class = 'medium-4'
self.helper = FormHelper()
self.helper.form_action = ''
self.helper.form_method = 'GET'
self.helper.form_class = 'custom'
self.helper.layout = Layout(
Row(
Column('query', css_class=css_class),
Column('log_entry_type', css_class=css_class),
Column('time', css_class=css_class),
),
Submit('send', 'Search', css_class='small'),
self.attrs = set_flat_form_attributes(
form_method='get',
form_class='custom',
form_fields=[
FormRow(
fields=[
FormColumn(fields=[self['query']], css_classes=css_class),
FormColumn(
fields=[self['log_entry_type']], css_classes=css_class
),
FormColumn(fields=[self['time']], css_classes=css_class),
]
),
SubmitField(value='Search', css_classes='small'),
],
)


Expand Down
7 changes: 5 additions & 2 deletions python/nav/web/templates/radius/error_log.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "radius/base.html" %}
{% load crispy_forms_tags %}
{% load report %}

{% block content %}
Expand All @@ -16,7 +15,11 @@ <h4 class="subheader">Search in radius error logs</h4>
</div>

<div id="forms">
{% crispy form %}
{% if form.attrs %}
{% include 'custom_crispy_templates/flat_form.html' %}
{% else %}
{{ form }}
{% endif %}
</div>

{% if form.is_bound %}
Expand Down
Loading