Commit 65fd2ea6 by Kálmán Viktor

Merge branch 'issue-253' into 'master'

Make it easy to add a cname to changed hostname

Closes #253
parents 0136016f 7bb777ef
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{% if rule_list.data.data.count > 0 %} {% if rule_list.data.data.count > 0 %}
{% render_table rule_list %} {% render_table rule_list %}
{% else %} {% else %}
{% trans "No rules associated with this host!" %} {% trans "No rules associated with this host." %}
{% endif %} {% endif %}
<div class="page-header"> <div class="page-header">
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<h3>{% trans "Add host group" %}</h3> <h3>{% trans "Add host group" %}</h3>
</div> </div>
{% if not_used_groups|length == 0 %} {% if not_used_groups|length == 0 %}
No more groups to add! {% trans "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 %}
...@@ -65,15 +65,19 @@ ...@@ -65,15 +65,19 @@
</form> </form>
{% endif %} {% endif %}
<div class="page-header"> <div class="page-header">
<a href="{% url "network.record_create" %}?host={{ host_pk }}"
class="btn btn-xs btn-success pull-right">
<i class="fa fa-plus-circle"></i>
{% trans "Add new CNAME record" %}
</a>
<h3>{% trans "Records" %}</h3> <h3>{% trans "Records" %}</h3>
</div> </div>
{% render_table records_table %} {% render_table records_table %}
</div><!-- col-sm-5 --> </div><!-- col-sm-5 -->
</div><!-- row --> </div><!-- row -->
{% endblock %} {% endblock %}
{% block extra_etc %} {% block extra_etc %}
<script src="{% static "js/host.js" %}"></script> <script src="{% static "js/host.js" %}"></script>
{% endblock %} {% endblock %}
...@@ -505,10 +505,23 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin, ...@@ -505,10 +505,23 @@ class RecordCreate(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _(u'Successfully created record!') success_message = _(u'Successfully created record!')
def get_initial(self): def get_initial(self):
return { host_pk = self.request.GET.get("host")
# 'owner': 1, try:
'domain': self.request.GET.get('domain'), host = Host.objects.get(pk=host_pk)
} except (Host.DoesNotExist, ValueError):
host = None
initial = {'owner': self.request.user}
if host:
initial.update({
'type': "CNAME",
'host': host,
'address': host.get_fqdn(),
})
else:
initial['domain'] = self.request.GET.get('domain')
return initial
class RecordDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView): class RecordDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
......
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