Converted IPAM Prefix, IPAddress, VLAN add/edit/delete views to CBVs

This commit is contained in:
Jeremy Stretch
2016-05-09 13:10:37 -04:00
parent 60daaee204
commit 171f2c008f
8 changed files with 86 additions and 246 deletions

View File

@@ -1,8 +1,8 @@
{% extends 'utilities/confirmation_form.html' %}
{% load form_helpers %}
{% block title %}Delete IP address {{ ipaddress }}?{% endblock %}
{% block title %}Delete IP address {{ obj }}?{% endblock %}
{% block message %}
<p>Are you sure you want to delete this IP address?</p>
<p>Are you sure you want to delete {{ obj }}?</p>
{% endblock %}

View File

@@ -1,10 +1,10 @@
{% extends '_base.html' %}
{% load form_helpers %}
{% block title %}{% if ipaddress %}Editing IP Address {{ ipaddress }}{% else %}Add an IP Address{% endif %}{% endblock %}
{% block title %}{% if obj %}Editing IP Address {{ obj }}{% else %}Add an IP Address{% endif %}{% endblock %}
{% block content %}
<h1>{% if ipaddress %}Editing IP Address {{ ipaddress }}{% else %}Add an IP Address{% endif %}</h1>
<h1>{% if obj %}Editing IP Address {{ obj }}{% else %}Add an IP Address{% endif %}</h1>
<form action="." method="post" class="form form-horizontal">
{% csrf_token %}
<div class="row">
@@ -22,13 +22,13 @@
<div class="panel-body">
{% render_field form.address %}
{% render_field form.vrf %}
{% if ipaddress %}
{% if obj %}
<div class="form-group">
<label class="col-md-3 control-label">Device</label>
<div class="col-md-9">
<p class="form-control-static">
{% if ipaddress.interface %}
<a href="{% url 'dcim:device' pk=ipaddress.interface.device.pk %}">{{ ipaddress.interface.device }}</a>
{% if obj.interface %}
<a href="{% url 'dcim:device' pk=obj.interface.device.pk %}">{{ obj.interface.device }}</a>
{% else %}
<span>None</span>
{% endif %}
@@ -38,7 +38,7 @@
<div class="form-group">
<label class="col-md-3 control-label">Interface</label>
<div class="col-md-9">
<p class="form-control-static">{{ ipaddress.interface }}</p>
<p class="form-control-static">{{ obj.interface }}</p>
</div>
</div>
{% endif %}
@@ -70,9 +70,9 @@
</div>
<div class="row">
<div class="col-md-12 text-right">
{% if ipaddress %}
{% if obj %}
<button type="submit" name="_update" class="btn btn-primary">Update</button>
<a href="{% url 'ipam:ipaddress' pk=ipaddress.pk %}" class="btn btn-default">Cancel</a>
<a href="{% url 'ipam:ipaddress' pk=obj.pk %}" class="btn btn-default">Cancel</a>
{% else %}
<button type="submit" name="_create" class="btn btn-primary">Create</button>
<button type="submit" name="_addanother" class="btn btn-primary">Create and Add Another</button>

View File

@@ -1,8 +1,8 @@
{% extends 'utilities/confirmation_form.html' %}
{% load form_helpers %}
{% block title %}Delete prefix {{ prefix }}?{% endblock %}
{% block title %}Delete prefix {{ obj }}?{% endblock %}
{% block message %}
<p>Are you sure you want to delete this prefix?</p>
<p>Are you sure you want to delete {{ obj }}?</p>
{% endblock %}

View File

@@ -1,11 +1,11 @@
{% extends '_base.html' %}
{% load form_helpers %}
{% block title %}{% if prefix %}Editing prefix {{ prefix }}{% else %}Add a prefix{% endif %}{% endblock %}
{% block title %}{% if obj %}Editing prefix {{ obj }}{% else %}Add a prefix{% endif %}{% endblock %}
{% block content %}
{% if prefix %}
<h1>{{ prefix }}</h1>
{% if obj %}
<h1>{{ obj }}</h1>
{% else %}
<h1>Add a Prefix</h1>
{% endif %}
@@ -35,9 +35,9 @@
</div>
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
{% if prefix %}
{% if obj %}
<button type="submit" name="_update" class="btn btn-primary">Update</button>
<a href="{% url 'ipam:prefix' pk=prefix.pk %}" class="btn btn-default">Cancel</a>
<a href="{% url 'ipam:prefix' pk=obj.pk %}" class="btn btn-default">Cancel</a>
{% else %}
<button type="submit" name="_create" class="btn btn-primary">Create</button>
<button type="submit" name="_addanother" class="btn btn-primary">Create and Add Another</button>

View File

@@ -1,20 +1,20 @@
{% extends 'utilities/confirmation_form.html' %}
{% load form_helpers %}
{% block title %}Delete VLAN {{ vlan }}?{% endblock %}
{% block title %}Delete VLAN {{ obj }}?{% endblock %}
{% block message %}
<p>
Are you sure you want to delete this VLAN?
{% if vlan.prefix_set.count %}
{% if obj.prefix_set.count %}
The following prefixes will also be deleted:
{% else %}
(There are no prefixes associated with this VLAN.)
{% endif %}
</p>
{% if vlan.prefix_set.count %}
{% if obj.prefix_set.count %}
<ul>
{% for p in vlan.prefix_set.all %}
{% for p in obj.prefix_set.all %}
<li><a href="{% url 'ipam:prefix' pk=p.pk %}">{{ p }}</a></li>
{% endfor %}
</ul>

View File

@@ -1,16 +1,17 @@
{% extends '_base.html' %}
{% load form_helpers %}
{% block title %}Editing VLAN {{ vlan }}{% endblock %}
{% block title %}{% if obj %}Editing VLAN {{ obj }}{% else %}Add a new VLAN{% endif %}{% endblock %}
{% block content %}
{% if vlan %}
<h1>{{ vlan }}</h1>
{% if obj %}
<h1>{{ obj }}</h1>
{% else %}
<h1>Add a VLAN</h1>
{% endif %}
<form action="." method="post" class="form form-horizontal">
{% csrf_token %}
<div class="row">
<div class="row">
<div class="col-md-6 col-md-offset-3">
{% if form.non_field_errors %}
@@ -33,9 +34,9 @@
</div>
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
{% if vlan %}
{% if obj %}
<button type="submit" name="_update" class="btn btn-primary">Update</button>
<a href="{% url 'ipam:vlan' pk=vlan.pk %}" class="btn btn-default">Cancel</a>
<a href="{% url 'ipam:vlan' pk=obj.pk %}" class="btn btn-default">Cancel</a>
{% else %}
<button type="submit" name="_create" class="btn btn-primary">Create</button>
<button type="submit" name="_addanother" class="btn btn-primary">Create and Add Another</button>