Move edit/add/cname key_name and ttl form items to just use choice item instead of trying to define each element

This commit is contained in:
Jeffrey Forman 2017-04-17 20:26:01 -04:00
parent 235f0fe174
commit ddae5be662
3 changed files with 22 additions and 18 deletions

View File

@ -59,7 +59,7 @@
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<select id="ttl" name="ttl" class="form-control"> <select id="ttl" name="ttl" class="form-control">
{% for choice in form.ttl %} {% for choice in form.ttl %}
<option value="{{ choice.choice_value }}">{{ choice.choice_value }} ({{ choice.choice_label }})</option> {{choice}}
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -77,11 +77,9 @@
<label for="key_name" class="col-sm-3 control-label">TSIG Key:</label> <label for="key_name" class="col-sm-3 control-label">TSIG Key:</label>
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<select id="key_name" name="key_name" class="form-control"> <select id="key_name" name="key_name" class="form-control">
{% for key in form.key_name %} {% for choice in form.key_name %}
<option value="{{ key.choice_value }}"{% if key.choice_value|add:0 == dns_server.default_transfer_key.id %} selected="selected"{% endif %}>{{ key.choice_label }}</option> {{ choice }}
{% empty %} {% endfor %}}
<option selected="selected" value="" />
{% endfor %}
</select> </select>
</div> </div>
{% if form.key_name.errors %} {% if form.key_name.errors %}

View File

@ -1,8 +1,18 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block pageheader %}Add record in {{ form.zone_name.value }}{% endblock pageheader %} {% block pageheader %}
{% if 'add_record' in request.path %}
Add
{% elif 'edit_record' in request.path %}
Edit
{% else %}
Unknown Action!
{% endif %}
record in {{ form.zone_name.value }}
{% endblock pageheader %}
{% block body %} {% block body %}
<form class="form-horizontal" action="{% url "add_record" dns_server=dns_server zone_name=form.zone_name.value %}" method="POST">{% csrf_token %} <form class="form-horizontal" action="{% url "add_record" dns_server=dns_server zone_name=form.zone_name.value %}" method="POST">{% csrf_token %}
<legend>Create Record</legend> <legend>Create Record</legend>
@ -25,7 +35,7 @@
<label for="record_name" class="col-sm-3 control-label">Record Name:</label> <label for="record_name" class="col-sm-3 control-label">Record Name:</label>
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<div class="input-group"> <div class="input-group">
<input id="record_name" name="record_name" type="text" class="form-control"{% if form.record_name.value %} value="{{ form.record_name.value }}"{% endif %} /> <input id="record_name" name="record_name" type="text" class="form-control"{% if form.record_name.value %} value="{{ form.record_name.value }}" readonly="readonly"{% endif %}/>
<span class="input-group-addon">.{{ form.zone_name.value }}</span> <span class="input-group-addon">.{{ form.zone_name.value }}</span>
<input type="hidden" name="zone_name" value="{{ form.zone_name.value }}" /> <input type="hidden" name="zone_name" value="{{ form.zone_name.value }}" />
</div> </div>
@ -45,7 +55,7 @@
<select id="record_type" name="record_type" class="form-control"> <select id="record_type" name="record_type" class="form-control">
{% if "in-addr.arpa" not in form.zone_name.value and "ip6.arpa" not in form.zone_name.value %} {% if "in-addr.arpa" not in form.zone_name.value and "ip6.arpa" not in form.zone_name.value %}
{% for choice in form.record_type %} {% for choice in form.record_type %}
<option value="{{ choice.choice_value }}">{{ choice.choice_label }}</option> {{ choice }}
{% endfor %} {% endfor %}
{% else %} {% else %}
<option value="PTR">PTR</option> <option value="PTR">PTR</option>
@ -81,7 +91,7 @@
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<select id="ttl" name="ttl" class="form-control"> <select id="ttl" name="ttl" class="form-control">
{% for choice in form.ttl %} {% for choice in form.ttl %}
<option value="{{ choice.choice_value }}">{{ choice.choice_value }} ({{ choice.choice_label }})</option> {{ choice }}
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -108,10 +118,8 @@
<label for="key_name" class="col-sm-3 control-label">TSIG Key:</label> <label for="key_name" class="col-sm-3 control-label">TSIG Key:</label>
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<select id="key_name" name="key_name" class="form-control"> <select id="key_name" name="key_name" class="form-control">
{% for key in form.key_name %} {% for choice in form.key_name %}
<option value="{{ key.choice_value }}"{% if key.choice_value|add:0 == dns_server.default_transfer_key.id %} selected="selected"{% endif %}>{{ key.choice_label }}</option> {{ choice }}
{% empty %}
<option selected="selected" value="" />
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View File

@ -39,10 +39,8 @@
<label for="key_name" class="col-sm-3 control-label">TSIG Key:</label> <label for="key_name" class="col-sm-3 control-label">TSIG Key:</label>
<div class="col-sm-5 col-md-4"> <div class="col-sm-5 col-md-4">
<select id="key_name" name="key_name" class="form-control"> <select id="key_name" name="key_name" class="form-control">
{% for key in form.key_name %} {% for choice in form.key_name %}
<option value="{{ key.choice_value }}"{% if key.choice_value|add:0 == dns_server.default_transfer_key.id %} selected="selected"{% endif %}>{{ key.choice_label }}</option> {{ choice }}
{% empty %}
<option selected="selected" value="" />
{% endfor %} {% endfor %}
</select> </select>
</div> </div>