Commit daf265d4 by Kálmán Viktor

network: bootstrap3 migration and bugfixes

parent 6f49fcd2
...@@ -285,4 +285,6 @@ finally: ...@@ -285,4 +285,6 @@ finally:
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# vim: et sw=4 ai fenc=utf8 smarttab : # vim: et sw=4 ai fenc=utf8 smarttab :
...@@ -2,8 +2,8 @@ from django.forms import ModelForm ...@@ -2,8 +2,8 @@ from django.forms import ModelForm
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Row, HTML from crispy_forms.layout import Layout, Fieldset, Div, Submit, BaseInput
from crispy_forms.layout import Div, ButtonHolder, Submit, BaseInput from crispy_forms.bootstrap import FormActions
from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist, from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist,
Rule, VlanGroup) Rule, VlanGroup)
...@@ -19,7 +19,7 @@ class LinkButton(BaseInput): ...@@ -19,7 +19,7 @@ class LinkButton(BaseInput):
the submit button. the submit button.
""" """
template = "bootstrap/layout/linkbutton.html" template = "bootstrap/layout/linkbutton.html"
field_classes = 'btn' field_classes = 'btn btn-default'
def __init__(self, name, text, url, *args, **kwargs): def __init__(self, name, text, url, *args, **kwargs):
self.href = url self.href = url
...@@ -30,26 +30,19 @@ class BlacklistForm(ModelForm): ...@@ -30,26 +30,19 @@ class BlacklistForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( '',
Fieldset( 'ipv4',
'Blacklist detail', 'host',
'ipv4', 'reason',
'host', 'type',
'reason', )
'type', ),
), FormActions(
css_class='span8'), Submit('submit', 'Save changes'),
Div( LinkButton('back', 'Back', reverse_lazy('network.blacklist_list'))
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: class Meta:
model = Blacklist model = Blacklist
...@@ -59,25 +52,18 @@ class DomainForm(ModelForm): ...@@ -59,25 +52,18 @@ class DomainForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( '',
Fieldset( 'name',
'Identity', 'owner',
'name', 'ttl',
'owner',
'ttl',
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
), ),
ButtonHolder( ),
Submit('submit', 'Save'), FormActions(
LinkButton('back', 'Back', reverse_lazy( Submit('submit', 'Save'),
'network.domain_list')) LinkButton('back', 'Back', reverse_lazy('network.domain_list'))
), )
css_class="form-horizontal")) )
class Meta: class Meta:
model = Domain model = Domain
...@@ -87,25 +73,18 @@ class GroupForm(ModelForm): ...@@ -87,25 +73,18 @@ class GroupForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( 'Identity',
Fieldset( 'name',
'Identity', 'description',
'name', 'owner',
'description',
'owner',
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
),
ButtonHolder(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy(
'network.group_list'))
), ),
css_class="form-horizontal")) ),
FormActions(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy('network.group_list'))
)
)
class Meta: class Meta:
model = Group model = Group
...@@ -115,40 +94,32 @@ class HostForm(ModelForm): ...@@ -115,40 +94,32 @@ class HostForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( 'Identity',
Fieldset( 'hostname',
'Identity', 'reverse',
'hostname', 'mac',
'reverse',
'mac',
),
Fieldset(
'Network',
'vlan',
'ipv4',
'ipv6',
'shared_ip',
'pub_ipv4',
),
Fieldset(
'Info',
'description',
'location',
'comment',
'owner',
# 'created_at',
# 'modified_at',
# 'id'
),
css_class='span12'),
), ),
ButtonHolder( Fieldset(
Submit('submit', 'Save'), 'Network',
LinkButton('back', 'Back', reverse_lazy( 'vlan',
'network.host_list')) 'ipv4',
'ipv6',
'shared_ip',
'pub_ipv4',
), ),
css_class="form-horizontal")) Fieldset(
'Information',
'description',
'location',
'comment',
'owner',
),
),
FormActions(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy('network.host_list')))
)
class Meta: class Meta:
model = Host model = Host
...@@ -158,27 +129,23 @@ class RecordForm(ModelForm): ...@@ -158,27 +129,23 @@ class RecordForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( '',
Fieldset( 'type',
'Record properties', 'host',
'type', 'name',
'host', 'domain',
'name', 'address',
'domain', 'ttl',
'address', 'description',
'ttl', 'owner',
'description', )
'owner', ),
), FormActions(
css_class='span12'), Submit('submit', 'Save'),
), LinkButton('back', 'Back', reverse_lazy('network.record_list'))
ButtonHolder( )
Submit('submit', 'Save'), )
LinkButton('back', 'Back', reverse_lazy(
'network.record_list'))
),
css_class="form-horizontal"))
class Meta: class Meta:
model = Record model = Record
...@@ -188,42 +155,35 @@ class RuleForm(ModelForm): ...@@ -188,42 +155,35 @@ class RuleForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Div( 'Identity',
Fieldset( 'direction',
'Identity', 'description',
'direction', 'foreign_network',
'description', 'dport',
'foreign_network', 'sport',
'dport', 'proto',
'sport', 'extra',
'proto', 'accept',
'extra', 'owner',
'accept', 'r_type',
'owner', 'nat',
'r_type', 'nat_dport',
'nat',
'nat_dport',
),
Fieldset(
'External',
'vlan',
'vlangroup',
'host',
'hostgroup',
'firewall'
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
), ),
ButtonHolder( Fieldset(
Submit('submit', 'Save'), 'External',
LinkButton('back', 'Back', reverse_lazy( 'vlan',
'network.rule_list')) 'vlangroup',
), 'host',
css_class="form-horizontal")) 'hostgroup',
'firewall'
)
),
FormActions(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy('network.rule_list'))
)
)
class Meta: class Meta:
model = Rule model = Rule
...@@ -233,47 +193,45 @@ class VlanForm(ModelForm): ...@@ -233,47 +193,45 @@ class VlanForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Fieldset( 'Identity',
'Identity', 'name',
'name', 'vid',
'vid', 'interface',
'interface', ),
), Fieldset(
Fieldset( 'IPv4',
'IPv4', 'net4',
'net4', 'prefix4',
'prefix4', 'ipv4',
'ipv4', 'snat_to',
'snat_to', 'snat_ip',
'snat_ip', 'dhcp_pool',
'dhcp_pool', ),
), Fieldset(
Fieldset( 'IPv6',
'IPv6', 'net6',
'net6', 'prefix6',
'prefix6', 'ipv6',
'ipv6',
),
Fieldset(
'Domain name service',
'domain',
'reverse_domain',
),
Fieldset(
'Info',
'description',
'comment',
# 'created_at',
# 'modified_at',
),
), ),
ButtonHolder( Fieldset(
Submit('submit', 'Save'), 'Domain name service',
LinkButton('back', 'Back', reverse_lazy( 'domain',
'network.host_list')) 'reverse_domain',
), ),
css_class="form-horizontal")) Fieldset(
'Info',
'description',
'comment',
# 'created_at',
# 'modified_at',
),
),
FormActions(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy('network.vlan_list'))
)
)
class Meta: class Meta:
model = Vlan model = Vlan
...@@ -283,21 +241,20 @@ class VlanGroupForm(ModelForm): ...@@ -283,21 +241,20 @@ class VlanGroupForm(ModelForm):
helper = FormHelper() helper = FormHelper()
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Fieldset(
Fieldset( '',
'Identity', 'name',
'name', 'vlans',
'vlans', 'description',
'description', 'owner',
'owner', )
), ),
), FormActions(
ButtonHolder( Submit('submit', 'Save'),
Submit('submit', 'Save'), LinkButton('back', 'Back', reverse_lazy(
LinkButton('back', 'Back', reverse_lazy( 'network.vlan_group_list'))
'network.vlan_group_list')) )
), )
css_class="form-horizontal"))
class Meta: class Meta:
model = VlanGroup model = VlanGroup
...@@ -174,7 +174,14 @@ function validateForm() { ...@@ -174,7 +174,14 @@ function validateForm() {
// name // name
record_name = $('#id_name').val() record_name = $('#id_name').val()
if(!domain_re.test(record_name)) {
if(!record_name) {
messages.push({
'message': gettext("You must specify a name!"),
'id': 'name'
});
}
else if(!domain_re.test(record_name)) {
text = gettext('%s - invalid domain name'), text = gettext('%s - invalid domain name'),
messages.push({ messages.push({
'message': interpolate(text, [record_name]), 'message': interpolate(text, [record_name]),
...@@ -230,8 +237,8 @@ function resetForm() { ...@@ -230,8 +237,8 @@ function resetForm() {
// removes all error messages / classes // removes all error messages / classes
function resetErrors() { function resetErrors() {
// reset invalid inputs too // reset invalid inputs too
$('div[id^="div_id_"][class*="error"]').each(function() { $('div[id^="div_id_"][class*="has-error"]').each(function() {
$(this).removeClass('error'); $(this).removeClass('has-error');
}); });
// remove the error messages // remove the error messages
...@@ -267,7 +274,7 @@ $(function() { ...@@ -267,7 +274,7 @@ $(function() {
$('#submit-id-submit').hide(); $('#submit-id-submit').hide();
$('#div_id_type .controls').append( $('#div_id_type .controls').append(
//' <a id="type_next" onclick="type_next()" class="btn btn-info">Next</a>' //' <a id="type_next" onclick="type_next()" class="btn btn-info">Next</a>'
'<span id="type_next" class="help-inline"><strong>' + '<span id="type_next" class="help-block"><strong>' +
gettext('Specify a type!') + gettext('Specify a type!') +
'</strong></span>' '</strong></span>'
); );
...@@ -301,16 +308,16 @@ function type_next() { ...@@ -301,16 +308,16 @@ function type_next() {
function appendMessage(type, messages, id) { function appendMessage(type, messages, id) {
$('#js_error').remove(); $('#js_error').remove();
resetErrors(); resetErrors();
message = '<div id="js_error" style="display: none;" class="alert alert-' + type + ' alert-block"><ul>' message = '<div id="js_error" style="display: none;" class="alert alert-danger"><ul>'
for(var i = 0;i < messages.length; i++) { for(var i = 0;i < messages.length; i++) {
message += "<li>" +messages[i].message+ "</li>"; message += "<li>" +messages[i].message+ "</li>";
if(messages[i].id) { if(messages[i].id) {
$('#id_' + messages[i].id).closest('div[class="control-group"]').addClass("error"); $('#id_' + messages[i].id).closest('div[class="form-group"]').addClass("has-error");
} }
} }
message +='</ul></div>'; message +='</ul></div>';
$('.form-horizontal').before(message); $('form').before(message);
$('html, body').animate({ scrollTop: 0}, 'slow', function() { $('html, body').animate({ scrollTop: 0}, 'slow', function() {
$('#js_error').fadeIn(); $('#js_error').fadeIn();
}); });
...@@ -321,8 +328,8 @@ function appendMessage(type, messages, id) { ...@@ -321,8 +328,8 @@ function appendMessage(type, messages, id) {
// it also removes the help-inline span that shouldn't really appear // it also removes the help-inline span that shouldn't really appear
$('* [id^="id_"]').focus(function() { $('* [id^="id_"]').focus(function() {
id = "#div_" + $(this).prop('id'); id = "#div_" + $(this).prop('id');
if($(id).hasClass('error')) { if($(id).hasClass('has-error')) {
$(id).removeClass('error'); $(id).removeClass('has-error');
$('span[id="error_1_' + $(this).attr('id') + '"]').remove(); $('span[id="error_1_' + $(this).attr('id') + '"]').remove();
} }
}); });
...@@ -9,13 +9,23 @@ ...@@ -9,13 +9,23 @@
<title>{% block title %}Firewall GUI{% endblock %}</title> <title>{% block title %}Firewall GUI{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" />
<style type="text/css"> <style type="text/css">
body { body {
padding-top:40px; padding-top:40px;
} }
/* note: this doesn't really work */
a i:hover {
text-decoration: none;
}
footer {
margin-top: 40px;
}
</style> </style>
<link href="{% static "css/bootstrap-responsive.min.css" %}" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
...@@ -26,21 +36,19 @@ ...@@ -26,21 +36,19 @@
</head> </head>
<body> <body>
<div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner"> <div class="navbar-header">
<div class="container"> <a class="navbar-brand" href="{% url network.index %}">CIRCLE Network</a>
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="brand" href="{% url network.index %}">CIRCLE Network</a> </div>
<div class="nav-collapse collapse"> <div class="collapse navbar-collapse">
<ul class="nav"> <ul class="nav navbar-nav">
{% include "network/menu.html" %} {% include "network/menu.html" %}
</ul> </ul>
</div>
</div> </div>
</div>
</div> </div>
{% block messages %} {% block messages %}
{% if messages %} {% if messages %}
...@@ -52,14 +60,18 @@ ...@@ -52,14 +60,18 @@
{% endif %} {% endif %}
{% endblock messages %} {% endblock messages %}
<div class="container"> <div class="container">
{% block content %} {% block content %}
<div class="alert-block">This is an abstract base template.</div> <div class="alert-block">This is an abstract base template.</div>
{% endblock %} {% endblock %}
</div> <footer>
<p class="pull-right"><a href="#">Vissza az oldal tetejére</a></p>
<p>&copy; 2013 BME Közigazgatási Informatikai Központ
</footer>
</div><!-- .container -->
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{% url network.js_catalog %}"></script> <script src="{% url network.js_catalog %}"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="{% static "js/bootbox.min.js" %}"></script>
<!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>--> <!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>-->
<script src="{% static "js/network.js" %}"></script> <script src="{% static "js/network.js" %}"></script>
<script> <script>
......
...@@ -6,9 +6,12 @@ ...@@ -6,9 +6,12 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.ipv4.value }} <small>details of restriction</small></h1> <h1>{{ form.ipv4.value }} <small>{{ form.type.value }}</small></h1>
</div>
<div class="row">
<div class="col-sm-4">
{% crispy form %}
</div>
</div> </div>
{% crispy form %}
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Blacklist <small></small></h1> <h1>Blacklist <small></small></h1>
</div> </div>
......
{% load i18n %} {% load i18n %}
{% load l10n %} {% load l10n %}
<span style="color: #FF0000;">[{{ record.r_type }}]</span> {# <span style="color: #FF0000;">[{{ record.r_type }}]</span> #}
{% if record.direction == "1" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %} {% if record.direction == "1" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %}
{#<span style="color: #0000FF;"> ▸ </span>#} {#<span style="color: #0000FF;"> ▸ </span>#}
<i class="icon-arrow-right"></i> <i class="icon-arrow-right"></i>
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
{% endif %} {% endif %}
{% if record.extra %} {% if record.extra %}
<span class="label label-inverse">{{ record.extra }}</span> <span class="label label-default">{{ record.extra }}</span>
{% endif %} {% endif %}
{% if record.nat %} {% if record.nat %}
<span class="label">NAT <span class="label label-success">NAT
[ {{ record.dport }} <i class="icon-arrow-right"></i> {{record.nat_dport}} ]</span> [ {{ record.dport }} <i class="icon-arrow-right"></i> {{record.nat_dport}} ]</span>
{% endif %} {% endif %}
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.name.value }} <small>details of domain</small></h1> <h1>{{ form.name.value }} <small></small></h1>
</div> </div>
{% crispy form %} <div class="row">
<div class="col-sm-4">
{% crispy form %}
</div>
</div>
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Domains <small>list of all domains</small></h1> <h1>Domains <small>list of all domains</small></h1>
</div> </div>
......
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.name.value }} <small>details of group</small></h1> <h1>{{ form.name.value }} <small>details of group</small></h1>
</div> </div>
{% crispy form %} <div class="row">
<div class="col-sm-6">
{% crispy form %}
</div>
</div>
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Host groups <small>list of all host groups</small></h1> <h1>Host groups <small>list of all host groups</small></h1>
</div> </div>
......
...@@ -6,16 +6,17 @@ ...@@ -6,16 +6,17 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h2>Create a new host</h2> <h2>Create a new host</h2>
</div> </div>
<div class="row"> <div class="row">
<div class="span8"> <div class="col-sm-8">
{% crispy form %} {% crispy form %}
</div> </div>
<div class="span4"> <div class="col-sm-4">
</div><!-- span4 --> Maybe some help text here?
</div><!-- col-sm-4 -->
</div><!-- row --> </div><!-- row -->
{% endblock %} {% endblock %}
...@@ -6,48 +6,61 @@ ...@@ -6,48 +6,61 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.hostname.value }} <small>details of host</small></h1> <h1>{{ form.hostname.value }} <small>details of host</small></h1>
</div> </div>
<div class="row"> <div class="row">
<div class="span8"> <div class="col-sm-8">
{% crispy form %} {% crispy form %}
</div> </div>
<div class="span4"> <div class="col-sm-4">
<h3>Rules</h3> <div class="page-header">
{% render_table rule_list %} <h3>Rules</h3>
<h3>Groups</h3>
{% 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 }}">
<i class="icon-remove" style="vertical-align: middle;"></i></a>
<a href="{% url network.group group.pk %}">
<i class="icon-pencil" style="vertical-align: middle;"></i></a>
</h4>
{% render_table group.table %}
</div> </div>
{% endfor %} {% if rule_list.data.data.count > 0 %}
{% render_table rule_list %}
<h3>Add host group</h3> {% else %}
No rules associated with this host!
{% endif %}
<div class="page-header">
<h3>Groups</h3>
</div>
{% 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 }}">
<i class="icon-remove" style="vertical-align: middle;"></i></a>
<a href="{% url network.group group.pk %}">
<i class="icon-pencil" style="vertical-align: middle;"></i></a>
</h4>
{% render_table group.table %}
</div>
{% endfor %}
<div class="page-header">
<h3>Add host group</h3>
</div>
{% if not_used_groups|length == 0 %} {% if not_used_groups|length == 0 %}
No more groups to add! No more groups to add!
{% else %} {% else %}
<form action="{% url network.add_host_group pk=host_pk %}" method="POST"> <form action="{% url network.add_host_group pk=host_pk %}" method="POST">
{% csrf_token %} {% csrf_token %}
<div class="input-append"> <div class="input-group">
<select name="group" id="add_group"> <select name="group" id="add_group" class="form-control">
{% for rest in not_used_groups %} {% for rest in not_used_groups %}
<option value="{{ rest.pk }}">{{ rest }}</option> <option value="{{ rest.pk }}">{{ rest }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="submit" value="Add group" class="btn"></input> <div class="input-group-btn">
</div><!-- input append --> <input type="submit" value="Add group" class="btn btn-default"></input>
</form> </div>
</div><!-- input-group -->
</form>
{% endif %} {% endif %}
</div><!-- span4 --> </div><!-- col-sm-4 -->
</div><!-- row --> </div><!-- row -->
{% endblock %} {% endblock %}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<style> <style>
</style> </style>
<div class="page-heading"> <div class="page-header">
<h1> <h1>
Hosts Hosts
<small> <small>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</h1> </h1>
</div> </div>
<ul class="nav nav-pills"> <ul class="nav nav-pills" style="margin: 5px 0 20px 0;">
<li class="disabled"><a href="#">Filter by vlans</a></li> <li class="disabled"><a href="#">Filter by vlans</a></li>
<li {% if not request.GET.vlan %} class="active"{% endif %}><a href="{{ request.path }}">ALL</a></li> <li {% if not request.GET.vlan %} class="active"{% endif %}><a href="{{ request.path }}">ALL</a></li>
{% for vlan in vlans %} {% for vlan in vlans %}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Latest modifications</h1> <h1>Latest modifications</h1>
</div> </div>
...@@ -23,15 +23,15 @@ ...@@ -23,15 +23,15 @@
<td><a href="{{ l.link }}">{{ l.name }}</a></td> <td><a href="{{ l.link }}">{{ l.name }}</a></td>
<td>{{ l.modified_at|timesince }}</td> <td>{{ l.modified_at|timesince }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<div class="page-heading"> <div class="page-header">
<h1>Dashboard <small>foo bar baz</small></h1> <h1>Dashboard <small>foo bar baz</small></h1>
</div> </div>
<ul class="thumbnails"> <ul class="thumbnails">
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead"><a href="{% url network.host_list %}">Hosts</a> are machines on the network.</p> <p class="lead"><a href="{% url network.host_list %}">Hosts</a> are machines on the network.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</ul> </ul>
<ul class="thumbnails"> <ul class="thumbnails">
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
</p> </p>
</div> </div>
</li> </li>
<li class="span3"> <li class="col-sm-3">
<div class="thumbnail"> <div class="thumbnail">
<p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p> <p class="lead">Lorem ipsum <a href="#">dolor</a> sit amet, consectetur adipiscing elit.</p>
<p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p> <p>Proin mattis enim risus. Ut condimentum eu enim quis auctor. Duis lobortis sollicitudin lacus, scelerisque dictum arcu aliquam nec.</p>
......
...@@ -6,20 +6,19 @@ ...@@ -6,20 +6,19 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h2>Create a new record</h2> <h2>Create a new record</h2>
</div> </div>
<div class="row"> <div class="row">
<div class="span8"> <div class="col-sm-6">
{% crispy form %} {% crispy form %}
</div> </div>
<div class="span4"> <div class="col-sm-4">
</div><!-- span4 --> </div><!-- col-sm-4 -->
</div><!-- row --> </div><!-- row -->
{% endblock %} {% endblock %}
{% block extra_etc %} {% block extra_etc %}
<script src="{% static "js/record-create.js" %}"></script> <script src="{% static "js/record.js" %}"></script>
{% endblock %} {% endblock %}
~ ~
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ fqdn }} <small>details of record</small></h1> <h1>{{ fqdn }} <small>details of record</small></h1>
</div> </div>
{% crispy form %} <div class="row">
<div class="col-sm-6">
{% crispy form %}
</div>
</div>
{% endblock %} {% endblock %}
{% block extra_etc %} {% block extra_etc %}
<script src="{% static "js/record-create.js" %}"></script> <script src="{% static "js/record.js" %}"></script>
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1> <h1>
Records Records
<small> <small>
......
...@@ -6,9 +6,17 @@ ...@@ -6,9 +6,17 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.hostname.value }} <small>details of rule</small></h1> <h3>
{% with rule as record %}
{% include "network/columns/host-rule.html" %}
{% endwith %}
</h3>
</div> </div>
{% crispy form %} <div class="row">
<div class="col-sm-7">
{% crispy form %}
</div>
</div>
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Rules <small>list of all rules</small></h1> <h1>Rules <small>list of all rules</small></h1>
</div> </div>
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.name.value }} <small>details of vlan</small></h1> <h1>{{ form.name.value }} <small>details of vlan</small></h1>
</div> </div>
<div class="row"> <div class="row">
<div class="span8"> <div class="col-sm-8">
{% crispy form %} {% crispy form %}
</div> </div>
<div class="span4"> <div class="col-sm-4">
{% render_table host_list %} {% render_table host_list %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>{{ form.name.value }} <small>details of vlan group</small></h1> <h1>{{ form.name.value }} <small>details of vlan group</small></h1>
</div> </div>
{% crispy form %} <div class="row">
<div class="col-sm-6">
{% crispy form %}
</div>
</div>
{% endblock %} {% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Vlan groups <small>list of all vlan groups</small></h1> <h1>Vlan groups <small>list of all vlan groups</small></h1>
</div> </div>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block content %} {% block content %}
<div class="page-heading"> <div class="page-header">
<h1>Vlans <small>list of all vlans</small></h1> <h1>Vlans <small>list of all vlans</small></h1>
</div> </div>
......
...@@ -143,6 +143,18 @@ class HostDetail(UpdateView): ...@@ -143,6 +143,18 @@ class HostDetail(UpdateView):
self.object = self.get_object() self.object = self.get_object()
return super(HostDetail, self).get(request, *args, **kwargs) return super(HostDetail, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
pk = self.kwargs.get('pk')
# this is usually not None (well, with curl and whatnot it can be)
if pk:
groups = Host.objects.get(pk=pk).groups.all()
groups = [i.pk for i in groups]
# request.POST is immutable
post_copy = request.POST.copy()
post_copy.setlist('groups', groups)
request.POST = post_copy
return super(HostDetail, self).post(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(HostDetail, self).get_context_data(**kwargs) context = super(HostDetail, self).get_context_data(**kwargs)
# own rules # own rules
...@@ -225,6 +237,15 @@ class RuleDetail(UpdateView): ...@@ -225,6 +237,15 @@ class RuleDetail(UpdateView):
if 'pk' in self.kwargs: if 'pk' in self.kwargs:
return reverse_lazy('network.rule', kwargs=self.kwargs) return reverse_lazy('network.rule', kwargs=self.kwargs)
def get_context_data(self, **kwargs):
context = super(RuleDetail, self).get_context_data(**kwargs)
pk = self.kwargs.get('pk')
rule = Rule.objects.get(pk=pk)
context['rule'] = rule
return context
class RuleDelete(DeleteView): class RuleDelete(DeleteView):
model = Rule model = Rule
......
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