Commit e743c410 by Kálmán Viktor

network: add domain views

parent b8d5a382
...@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper ...@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Row, HTML from crispy_forms.layout import Layout, Fieldset, Row, HTML
from crispy_forms.layout import Div, ButtonHolder, Submit, BaseInput from crispy_forms.layout import Div, ButtonHolder, Submit, BaseInput
from firewall.models import Host, Vlan from firewall.models import Host, Vlan, Domain
class LinkButton(BaseInput): class LinkButton(BaseInput):
...@@ -25,6 +25,34 @@ class LinkButton(BaseInput): ...@@ -25,6 +25,34 @@ class LinkButton(BaseInput):
super(LinkButton, self).__init__(name, text, *args, **kwargs) super(LinkButton, self).__init__(name, text, *args, **kwargs)
class DomainForm(ModelForm):
helper = FormHelper()
helper.layout = Layout(
Div(
Row(
Div(
Fieldset(
'Identity',
'name',
'owner',
'ttl',
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
),
ButtonHolder(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy(
'network.domain_list'))
),
css_class="form-horizontal"))
class Meta:
model = Domain
class HostForm(ModelForm): class HostForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
......
from django_tables2 import Table, A from django_tables2 import Table, A
from django_tables2.columns import LinkColumn from django_tables2.columns import LinkColumn
from firewall.models import Host, Vlan from firewall.models import Host, Vlan, Domain
class DomainTable(Table):
name = LinkColumn('network.domain', args=[A('pk')])
class Meta:
model = Domain
attrs = {'class': 'table table-striped table-condensed'}
fields = ('name', 'owner', 'ttl', )
order_by = ('name', )
class HostTable(Table): class HostTable(Table):
......
{% 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>{{ form.hostname.value }} <small>details of host</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>Domains <small>list of all domains</small></h1>
</div>
{% render_table table %}
{% endblock %}
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
{% include "network/menu-item.html" with href=u text="Hosts" %} {% include "network/menu-item.html" with href=u text="Hosts" %}
{% url network.vlan_list as u %} {% url network.vlan_list as u %}
{% include "network/menu-item.html" with href=u text="Vlans" %} {% include "network/menu-item.html" with href=u text="Vlans" %}
{% url network.domain_list as u %}
{% include "network/menu-item.html" with href=u text="Domains" %}
{# <li><a href="/vlans/">{% trans "Vlans" %}</a></li> #} {# <li><a href="/vlans/">{% trans "Vlans" %}</a></li> #}
{# <li><a href="/vlangroups/">{% trans "Vlan groups" %}</a></li> #} {# <li><a href="/vlangroups/">{% trans "Vlan groups" %}</a></li> #}
......
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from .views import IndexView, HostList, HostDetail, VlanList, VlanDetail from .views import (IndexView, HostList, HostDetail, VlanList, VlanDetail,
DomainList, DomainDetail)
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url('^$', IndexView.as_view(), name='network.index'), url('^$', IndexView.as_view(), name='network.index'),
url('^domains/$', DomainList.as_view(), name='network.domain_list'),
url('^domains/(?P<pk>\d+)/$', DomainDetail.as_view(),
name='network.domain'),
url('^hosts/$', HostList.as_view(), name='network.host_list'), url('^hosts/$', HostList.as_view(), name='network.host_list'),
url('^hosts/(?P<pk>\d+)/$', HostDetail.as_view(), name='network.host'), url('^hosts/(?P<pk>\d+)/$', HostDetail.as_view(), name='network.host'),
url('^vlans/$', VlanList.as_view(), name='network.vlan_list'), url('^vlans/$', VlanList.as_view(), name='network.vlan_list'),
......
...@@ -4,15 +4,31 @@ from django.core.urlresolvers import reverse_lazy ...@@ -4,15 +4,31 @@ from django.core.urlresolvers import reverse_lazy
from django_tables2 import SingleTableView from django_tables2 import SingleTableView
from firewall.models import Host, Vlan from firewall.models import Host, Vlan, Domain
from .tables import HostTable, VlanTable, SmallHostTable from .tables import HostTable, VlanTable, SmallHostTable, DomainTable
from .forms import HostForm, VlanForm from .forms import HostForm, VlanForm, DomainForm
class IndexView(TemplateView): class IndexView(TemplateView):
template_name = "network/index.html" template_name = "network/index.html"
class DomainList(SingleTableView):
model = Domain
table_class = DomainTable
template_name = "network/domain-list.html"
class DomainDetail(UpdateView):
model = Domain
template_name = "network/domain-edit.html"
form_class = DomainForm
def get_success_url(self):
if 'pk' in self.kwargs:
return reverse_lazy('network.domain', kwargs=self.kwargs)
class HostList(SingleTableView): class HostList(SingleTableView):
model = Host model = Host
table_class = HostTable table_class = HostTable
......
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