Commit 57979689 by Kálmán Viktor

network: add rule list table to firewall detail

parent 6562e1be
...@@ -255,3 +255,26 @@ class FirewallTable(Table): ...@@ -255,3 +255,26 @@ class FirewallTable(Table):
attrs = {'class': 'table table-striped'} attrs = {'class': 'table table-striped'}
fields = ('pk', 'name', ) fields = ('pk', 'name', )
order_by = 'pk' 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 i18n %}
{% load l10n %} {% load l10n %}
<div style="white-space: nowrap;"> <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> <a href="{% url "network.rule" pk=record.pk %}"><i class="fa fa-pencil"></i></a>
</div> </div>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
{% endif %} {% endif %}
<form action="" method="post">{% csrf_token %} <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 %} {% if confirmation %}
<label><p> <label><p>
{% trans "If you are really sure, type in the object's name!" %} {% trans "If you are really sure, type in the object's name!" %}
......
{% extends "network/base.html" %} {% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %} {% load i18n %}
{% load staticfiles %} {% load staticfiles %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block title-page %}{{ switch_port_pk }} | {% trans "firewall" %}{% endblock %} {% block title-page %}{{ object.name }} | {% trans "firewall" %}{% endblock %}
{% block content %} {% block content %}
<div class="page-header"> <div class="page-header">
...@@ -18,4 +19,13 @@ ...@@ -18,4 +19,13 @@
{% crispy form %} {% crispy form %}
</div> </div>
</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 %} {% endblock %}
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
{% for group in group_rule_list %} {% for group in group_rule_list %}
<div> <div>
<h4 id="{{ group.pk }}_group_pk">{{ group.name }} <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> <i class="fa fa-times" style="vertical-align: middle;"></i></a>
<a href="{% url "network.group" group.pk %}"> <a href="{% url "network.group" group.pk %}">
<i class="fa fa-pencil" style="vertical-align: middle;"></i></a> <i class="fa fa-pencil" style="vertical-align: middle;"></i></a>
......
...@@ -35,7 +35,7 @@ from .tables import ( ...@@ -35,7 +35,7 @@ from .tables import (
HostTable, VlanTable, SmallHostTable, DomainTable, GroupTable, HostTable, VlanTable, SmallHostTable, DomainTable, GroupTable,
RecordTable, BlacklistItemTable, RuleTable, VlanGroupTable, RecordTable, BlacklistItemTable, RuleTable, VlanGroupTable,
SmallRuleTable, SmallGroupRuleTable, SmallRecordTable, SwitchPortTable, SmallRuleTable, SmallGroupRuleTable, SmallRecordTable, SwitchPortTable,
SmallDhcpTable, FirewallTable SmallDhcpTable, FirewallTable, FirewallRuleTable,
) )
from .forms import ( from .forms import (
HostForm, VlanForm, DomainForm, GroupForm, RecordForm, BlacklistItemForm, HostForm, VlanForm, DomainForm, GroupForm, RecordForm, BlacklistItemForm,
...@@ -312,6 +312,9 @@ class FirewallDetail(LoginRequiredMixin, SuperuserRequiredMixin, ...@@ -312,6 +312,9 @@ class FirewallDetail(LoginRequiredMixin, SuperuserRequiredMixin,
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(FirewallDetail, self).get_context_data(**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 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