Commit 57979689 by Kálmán Viktor

network: add rule list table to firewall detail

parent 6562e1be
......@@ -255,3 +255,26 @@ class FirewallTable(Table):
attrs = {'class': 'table table-striped'}
fields = ('pk', 'name', )
order_by = 'pk'
class FirewallRuleTable(Table):
color_desc = TemplateColumn(
template_name="network/columns/rule-short-description.html",
verbose_name=_("Short description"),
orderable=False,
)
actions = TemplateColumn(
template_name="network/columns/firewall-rule-actions.html",
verbose_name=_("Actions"),
orderable=False,
)
class Meta:
model = Rule
template = "django_tables2/table_no_page.html"
attrs = {'class': 'table table-striped table-hover table-condensed',
'id': "rule-list-table"}
fields = ('color_desc', 'extra', 'direction',
'action', 'proto', 'actions')
order_by = '-pk'
empty_text = _("No related rules found.")
{% load i18n %}
<div style="white-space: nowrap;">
<a href="{% url "network.rule_delete" pk=record.pk %}?next={{ request.path }}"><i class="fa fa-times"></i></a>
<a href="{% url "network.rule" pk=record.pk %}"><i class="fa fa-pencil"></i></a>
</div>
{% load i18n %}
{% load l10n %}
<div style="white-space: nowrap;">
<a href="{% url "network.rule_delete" pk=record.pk %}?from={{ request.path }}"><i class="fa fa-times"></i></a>
<a href="{% url "network.rule_delete" pk=record.pk %}?next={{ request.path }}"><i class="fa fa-times"></i></a>
<a href="{% url "network.rule" pk=record.pk %}"><i class="fa fa-pencil"></i></a>
</div>
......@@ -31,7 +31,7 @@
</div>
{% endif %}
<form action="" method="post">{% csrf_token %}
<input type="hidden" value="{{ request.GET.from }}" name="next" />
<input type="hidden" value="{{ request.GET.next }}" name="next" />
{% if confirmation %}
<label><p>
{% trans "If you are really sure, type in the object's name!" %}
......
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title-page %}{{ switch_port_pk }} | {% trans "firewall" %}{% endblock %}
{% block title-page %}{{ object.name }} | {% trans "firewall" %}{% endblock %}
{% block content %}
<div class="page-header">
......@@ -18,4 +19,13 @@
{% crispy form %}
</div>
</div>
<div class="page-header">
<h2>{% trans "Related rules" %}</h2>
</div>
<div class="row">
<div class="col-sm-12">
{% render_table rule_table %}
</div>
</div>
{% endblock %}
......@@ -35,7 +35,7 @@
{% for group in group_rule_list %}
<div>
<h4 id="{{ group.pk }}_group_pk">{{ group.name }}
<a href="{% url "network.remove_host_group" pk=host_pk group_pk=group.pk %}?from={{ request.path }}">
<a href="{% url "network.remove_host_group" pk=host_pk group_pk=group.pk %}?next={{ request.path }}">
<i class="fa fa-times" style="vertical-align: middle;"></i></a>
<a href="{% url "network.group" group.pk %}">
<i class="fa fa-pencil" style="vertical-align: middle;"></i></a>
......
......@@ -35,7 +35,7 @@ from .tables import (
HostTable, VlanTable, SmallHostTable, DomainTable, GroupTable,
RecordTable, BlacklistItemTable, RuleTable, VlanGroupTable,
SmallRuleTable, SmallGroupRuleTable, SmallRecordTable, SwitchPortTable,
SmallDhcpTable, FirewallTable
SmallDhcpTable, FirewallTable, FirewallRuleTable,
)
from .forms import (
HostForm, VlanForm, DomainForm, GroupForm, RecordForm, BlacklistItemForm,
......@@ -312,6 +312,9 @@ class FirewallDetail(LoginRequiredMixin, SuperuserRequiredMixin,
def get_context_data(self, **kwargs):
context = super(FirewallDetail, self).get_context_data(**kwargs)
rules = Rule.objects.filter(firewall=self.object)
context['rule_table'] = FirewallRuleTable(rules,
request=self.request)
return context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment