Commit f4ef13d8 by Kálmán Viktor

network: add record views

parent acd0d3fe
......@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Row, HTML
from crispy_forms.layout import Div, ButtonHolder, Submit, BaseInput
from firewall.models import Host, Vlan, Domain, Group
from firewall.models import Host, Vlan, Domain, Group, Record
class LinkButton(BaseInput):
......@@ -127,6 +127,39 @@ class HostForm(ModelForm):
model = Host
class RecordForm(ModelForm):
helper = FormHelper()
helper.layout = Layout(
Div(
Row(
Div(
Fieldset(
'Identity',
'name',
'domain',
'type',
'address',
'ttl',
'host',
'description',
'owner',
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
),
ButtonHolder(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy(
'network.record_list'))
),
css_class="form-horizontal"))
class Meta:
model = Record
class VlanForm(ModelForm):
helper = FormHelper()
helper.layout = Layout(
......
from django_tables2 import Table, A
from django_tables2.columns import LinkColumn
from firewall.models import Host, Vlan, Domain, Group
from firewall.models import Host, Vlan, Domain, Group, Record
class DomainTable(Table):
......@@ -46,6 +46,18 @@ class SmallHostTable(Table):
order_by = ('vlan', 'hostname', )
class RecordTable(Table):
fqdn = LinkColumn('network.record', args=[A('pk')])
class Meta:
model = Record
attrs = {'class': 'table table-striped table-condensed'}
fields = ('type', 'fqdn', 'address', 'ttl', 'host',
'owner', )
sequence = ('type', 'fqdn', )
order_by = 'name'
class VlanTable(Table):
name = LinkColumn('network.vlan', args=[A('vid')])
......
......@@ -9,7 +9,8 @@
{% include "network/menu-item.html" with href=u text="Domains" %}
{% url network.group_list as u %}
{% include "network/menu-item.html" with href=u text="Groups" %}
{% url network.record_list as u %}
{% include "network/menu-item.html" with href=u text="Records" %}
{# <li><a href="/vlans/">{% trans "Vlans" %}</a></li> #}
{# <li><a href="/vlangroups/">{% trans "Vlan groups" %}</a></li> #}
......
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block content %}
<div class="page-heading">
<h1>{{ fqdn }} <small>details of record</small></h1>
</div>
{% crispy form %}
{% endblock %}
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block content %}
<div class="page-heading">
<h1>Records <small>list of all records</small></h1>
</div>
{% render_table table %}
{% endblock %}
from django.conf.urls import patterns, url
from .views import (IndexView, HostList, HostDetail, VlanList, VlanDetail,
DomainList, DomainDetail, GroupList, GroupDetail)
DomainList, DomainDetail, GroupList, GroupDetail,
RecordList, RecordDetail)
urlpatterns = patterns(
......@@ -14,6 +15,9 @@ urlpatterns = patterns(
url('^groups/(?P<pk>\d+)/$', GroupDetail.as_view(), name='network.group'),
url('^hosts/$', HostList.as_view(), name='network.host_list'),
url('^hosts/(?P<pk>\d+)/$', HostDetail.as_view(), name='network.host'),
url('^records/$', RecordList.as_view(), name='network.record_list'),
url('^records/(?P<pk>\d+)/$', RecordDetail.as_view(),
name='network.record'),
url('^vlans/$', VlanList.as_view(), name='network.vlan_list'),
url('^vlans/(?P<vid>\d+)/$', VlanDetail.as_view(), name='network.vlan'),
)
......@@ -4,10 +4,10 @@ from django.core.urlresolvers import reverse_lazy
from django_tables2 import SingleTableView
from firewall.models import Host, Vlan, Domain, Group
from firewall.models import Host, Vlan, Domain, Group, Record
from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable,
GroupTable)
from .forms import HostForm, VlanForm, DomainForm, GroupForm
GroupTable, RecordTable)
from .forms import HostForm, VlanForm, DomainForm, GroupForm, RecordForm
class IndexView(TemplateView):
......@@ -78,6 +78,28 @@ class HostDetail(UpdateView):
return reverse_lazy('network.host', kwargs=self.kwargs)
class RecordList(SingleTableView):
model = Record
table_class = RecordTable
template_name = "network/record-list.html"
class RecordDetail(UpdateView):
model = Record
template_name = "network/record-edit.html"
form_class = RecordForm
def get_context_data(self, **kwargs):
context = super(RecordDetail, self).get_context_data(**kwargs)
q = Record.objects.get(pk=self.object.pk).fqdn
context['fqdn'] = q
return context
def get_success_url(self):
if 'pk' in self.kwargs:
return reverse_lazy('network.record', kwargs=self.kwargs)
class VlanList(SingleTableView):
model = Vlan
table_class = VlanTable
......
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