Permalink
Browse files

send updateurl when getting record for update, refactor get_klasses

  • Loading branch information...
1 parent 789e26b commit 680e089bcf03a06ebad8b59260c733776433bf65 Kevin Ngo committed Nov 7, 2012
Showing with 88 additions and 108 deletions.
  1. +2 −2 cyder/base/mixins.py
  2. +2 −2 cyder/base/templates/base/detail.html
  3. +1 −1 cyder/core/search/templates/search/search.html
  4. +1 −1 cyder/cydhcp/interface/static_intr/models.py
  5. +1 −1 cyder/cydhcp/interface/static_intr/tests/basic.py
  6. +1 −1 cyder/cydhcp/interface/static_intr/views.py
  7. +2 −2 cyder/cydhcp/network/templates/network/network_detail.html
  8. +2 −2 cyder/cydhcp/network/templates/network/network_wizard.html
  9. +2 −2 cyder/cydhcp/network/templates/network/network_wizard_ranges.html
  10. +1 −1 cyder/cydhcp/network/views.py
  11. +2 −2 cyder/cydhcp/range/templates/range/range_detail.html
  12. +1 −1 cyder/cydhcp/range/views.py
  13. +2 −2 cyder/cydhcp/site/templates/site/site_detail.html
  14. +2 −2 cyder/cydhcp/site/templates/site/site_form.html
  15. +2 −2 cyder/cydhcp/templates/cydhcp/cydhcp_detail.html
  16. +2 −2 cyder/cydhcp/vlan/templates/vlan/vlan_detail.html
  17. +2 −2 cyder/cydhcp/vlan/templates/vlan/vlan_form.html
  18. +1 −1 cyder/cydns/address_record/templates/address_record/addressrecord_detail.html
  19. +2 −2 cyder/cydns/address_record/tests/test_models.py
  20. +1 −1 cyder/cydns/cname/templates/cname/cname_detail.html
  21. +1 −1 cyder/cydns/cname/tests/test_models.py
  22. +1 −1 cyder/cydns/domain/templates/domain/domain_detail.html
  23. +1 −1 cyder/cydns/domain/tests/basic.py
  24. +1 −1 cyder/cydns/domain/tests/test_reverse.py
  25. +1 −1 cyder/cydns/models.py
  26. +1 −1 cyder/cydns/mx/tests/test_models.py
  27. +1 −1 cyder/cydns/nameserver/tests/test_models.py
  28. +1 −1 cyder/cydns/ptr/templates/ptr/ptr_detail.html
  29. +1 −1 cyder/cydns/ptr/tests/test_models.py
  30. +3 −3 cyder/cydns/soa/tests/test_models.py
  31. +1 −1 cyder/cydns/soa/views.py
  32. +1 −1 cyder/cydns/srv/tests/test_models.py
  33. +1 −1 cyder/cydns/sshfp/tests/test_models.py
  34. +2 −2 cyder/cydns/templates/cydns/cydns_detail.html
  35. +6 −6 cyder/cydns/templates/cydns/cydns_list_record.html
  36. +1 −1 cyder/cydns/txt/tests/test_models.py
  37. +3 −2 cyder/cydns/urls.py
  38. +18 −44 cyder/cydns/views.py
  39. +11 −6 media/js/cydns/cydns_record_form.js
View
@@ -19,9 +19,9 @@ def get_absolute_url(self):
def absolute_url(self):
return self.get_absolute_url()
- def get_edit_url(self):
+ def get_update_url(self):
"""
- Return the edit url of an object.
+ Return the update url of an object.
"""
return reverse(self._meta.db_table.replace('-', '_') + '-update',
args=[self.pk])
@@ -4,8 +4,8 @@
<div>{{ object }}</div>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block action_bar_extra %}
@@ -239,7 +239,7 @@ <h3><a name="Address">Address</a> Records</h3>
<tbody>
{% for addr in addrs %}
<tr>
- <td><a href="{{ addr.get_edit_url() }}">{{ addr.fqdn }}</a></td>
+ <td><a href="{{ addr.get_update_url() }}">{{ addr.fqdn }}</a></td>
<td><b>{{ addr.record_type() }}</b></td>
<td>{{ addr.ip_str }}</td>
</tr>
@@ -116,7 +116,7 @@ def get_api_fields(cls):
return super(StaticInterface, cls).get_api_fields() + ['mac',
'dhcp_enabled', 'dns_enabled']
- def get_edit_url(self):
+ def get_update_url(self):
return "/cydhcp/interface/{0}/update/".format(self.pk)
def get_delete_url(self):
@@ -49,7 +49,7 @@ def do_add(self, mac, label, domain, ip_str, ip_type='4'):
r.clean()
r.save()
r.details()
- r.get_edit_url()
+ r.get_update_url()
r.get_delete_url()
r.get_absolute_url()
repr(r)
@@ -257,7 +257,7 @@ def edit_static_interface(request, intr_pk):
})
messages.success(request, "Success! Interface Updated.")
- return redirect(intr.get_edit_url())
+ return redirect(intr.get_update_url())
else:
interface_form = StaticInterfaceForm(instance=intr)
@@ -5,8 +5,8 @@
<div class='dns-title'>{{ network }}</div>
{% block action_bar %}
- {% if network.get_edit_url %}
- <a class="btn btn-primary" href="{{ network.get_edit_url() }}">Edit</a>
+ {% if network.get_update_url %}
+ <a class="btn btn-primary" href="{{ network.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -23,8 +23,8 @@
</script>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -23,8 +23,8 @@
</script>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -99,7 +99,7 @@ def update_network(request, network_pk):
kv = get_attrs(request.POST)
update_attrs(kv, attrs, NetworkKeyValue, network, 'network')
network = form.save()
- return redirect(network.get_edit_url())
+ return redirect(network.get_update_url())
except ValidationError, e:
if form._errors is None:
form._errors = ErrorDict()
@@ -6,8 +6,8 @@
<!-- TODO fix all the urls in this view -->
{% block action_bar %}
- {% if range.get_edit_url %}
- <a class="btn btn-primary" href="{{ range.get_edit_url() }}">Edit</a>
+ {% if range.get_update_url %}
+ <a class="btn btn-primary" href="{{ range.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -149,7 +149,7 @@ def update_range(request, range_pk):
kv = get_attrs(request.POST)
update_attrs(kv, attrs, RangeKeyValue, mrange, 'range')
mrange = form.save()
- return redirect(mrange.get_edit_url())
+ return redirect(mrange.get_update_url())
except ValidationError, e:
if form._errors is None:
form._errors = ErrorDict()
@@ -12,8 +12,8 @@
{% block action_bar %}
- {% if site.get_edit_url %}
- <a class="btn btn-primary" href="{{ site.get_edit_url() }}">Edit</a>
+ {% if site.get_update_url %}
+ <a class="btn btn-primary" href="{{ site.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -5,8 +5,8 @@
<div class='dns-title'>{{ object }}</div>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -5,8 +5,8 @@
<div class='dns-title'>{{ object }}</div>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -5,8 +5,8 @@
<div class='dns-title'>{{ vlan }}</div>
{% block action_bar %}
- {% if vlan.get_edit_url %}
- <a class="btn btn-primary" href="{{ vlan.get_edit_url() }}">Edit</a>
+ {% if vlan.get_update_url %}
+ <a class="btn btn-primary" href="{{ vlan.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -5,8 +5,8 @@
<div class='dns-title'>{{ object }}</div>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -7,7 +7,7 @@
<a class="btn" href="{{ object.domain.get_absolute_url() }}">View Domain</a>
{% endif %}
- <a class="btn" href="{{ object.get_edit_url() }}">Edit</a>
+ <a class="btn" href="{{ object.get_update_url() }}">Edit</a>
<a class="btn" href="{{ object.get_delete_url() }}">Delete</a>
{% from "base/tables.html" import render_table %}
@@ -349,7 +349,7 @@ def do_add_record(self, data):
rec.save()
self.assertTrue(rec.__repr__())
self.assertTrue(rec.get_absolute_url())
- self.assertTrue(rec.get_edit_url())
+ self.assertTrue(rec.get_update_url())
self.assertTrue(rec.get_delete_url())
self.assertTrue(rec.details())
@@ -367,7 +367,7 @@ def do_add_record6(self, data):
rec.save()
self.assertTrue(rec.__repr__())
self.assertTrue(rec.get_absolute_url())
- self.assertTrue(rec.get_edit_url())
+ self.assertTrue(rec.get_update_url())
self.assertTrue(rec.get_delete_url())
self.assertTrue(rec.details())
@@ -8,7 +8,7 @@
<a class="btn" href="{{ object.domain.get_absolute_url() }}">View Domain</a>
{% endif %}
- <a class="btn" href="{{ object.get_edit_url() }}">Edit</a>
+ <a class="btn" href="{{ object.get_update_url() }}">Edit</a>
<a class="btn" href="{{ object.get_delete_url() }}">Delete</a>
{% from "base/tables.html" import render_table %}
@@ -63,7 +63,7 @@ def do_add(self, label, domain, data):
cn.save()
cn.save()
self.assertTrue(cn.get_absolute_url())
- self.assertTrue(cn.get_edit_url())
+ self.assertTrue(cn.get_update_url())
self.assertTrue(cn.get_delete_url())
self.assertTrue(cn.details())
@@ -10,7 +10,7 @@
<a class="btn" href="{{ object.soa.get_absolute_url() }}">View SOA</a>
<br>
{% endif %}
- <a class="btn" href="{{ object.get_edit_url() }}">Edit</a>
+ <a class="btn" href="{{ object.get_update_url() }}">Edit</a>
<a class="btn" href="{{ object.get_delete_url() }}">Delete</a>
@@ -45,7 +45,7 @@ def test1_add_domain(self):
f_c.save()
f_c.details()
self.assertTrue(f_c.get_absolute_url())
- self.assertTrue(f_c.get_edit_url())
+ self.assertTrue(f_c.get_update_url())
self.assertTrue(f_c.get_delete_url())
self.assertTrue(f_c.master_domain == c)
@@ -542,7 +542,7 @@ def test_master_reverse_ipv6_domains(self):
else:
self.assertEqual(rd[1].master_domain, rds[rd[0] - 1])
self.assertTrue(rd[1].get_absolute_url())
- self.assertTrue(rd[1].get_edit_url())
+ self.assertTrue(rd[1].get_update_url())
self.assertTrue(rd[1].get_delete_url())
try:
View
@@ -46,7 +46,7 @@ class CydnsRecord(models.Model, ObjectUrlMixin):
classes share. This includes a foreign key to the ``domain`` table
and a ``label`` CharField. This class also inherits from the
``ObjectUrlMixin`` class to provide the ``get_absolute_url``,
- ``get_edit_url``, and ``get_delete_url`` functions.
+ ``get_update_url``, and ``get_delete_url`` functions.
This class does validation on the ``label`` field. Call
``clean_all`` to trigger the validation functions. Failure to
@@ -22,7 +22,7 @@ def do_generic_add(self, data):
mx.save()
self.assertTrue(mx.details())
self.assertTrue(mx.get_absolute_url())
- self.assertTrue(mx.get_edit_url())
+ self.assertTrue(mx.get_update_url())
self.assertTrue(mx.get_delete_url())
rmx = MX.objects.filter(**data)
self.assertTrue(len(rmx) == 1)
@@ -57,7 +57,7 @@ def do_add(self, domain, server):
self.assertTrue(ns.__repr__())
self.assertTrue(ns.details())
self.assertTrue(ns.get_absolute_url())
- self.assertTrue(ns.get_edit_url())
+ self.assertTrue(ns.get_update_url())
self.assertTrue(ns.get_delete_url())
ret = Nameserver.objects.filter(domain=domain, server=server)
self.assertEqual(len(ret), 1)
@@ -7,7 +7,7 @@
<a class="btn" href="{{ object.reverse_domain.get_absolute_url() }}">View Reverse Domain</a>
{% endif %}
- <a class="btn" href="{{ object.get_edit_url() }}">Edit</a>
+ <a class="btn" href="{{ object.get_update_url() }}">Edit</a>
<a class="btn" href="{{ object.get_delete_url() }}">Delete</a>
{% from "base/tables.html" import render_table %}
@@ -51,7 +51,7 @@ def do_generic_add(self, ip_str, fqdn, ip_type, domain=None):
self.assertTrue(ret.details())
self.assertTrue(ret.get_absolute_url())
- self.assertTrue(ret.get_edit_url())
+ self.assertTrue(ret.get_update_url())
self.assertTrue(ret.get_delete_url())
ip = Ip(ip_str=ip_str, ip_type=ip_type)
@@ -41,7 +41,7 @@ def test_add_soa(self):
soa = soa[0]
self.assertTrue(soa.details())
self.assertTrue(soa.get_absolute_url())
- self.assertTrue(soa.get_edit_url())
+ self.assertTrue(soa.get_update_url())
self.assertTrue(soa.get_delete_url())
primary = "do.com"
@@ -56,7 +56,7 @@ def test_add_soa(self):
soa = soa[0]
self.assertTrue(soa.details())
self.assertTrue(soa.get_absolute_url())
- self.assertTrue(soa.get_edit_url())
+ self.assertTrue(soa.get_update_url())
self.assertTrue(soa.get_delete_url())
primary = "ns1.derp.com"
@@ -67,7 +67,7 @@ def test_add_soa(self):
soa.serial and soa.expire and soa.retry and soa.refresh)
self.assertTrue(soa.details())
self.assertTrue(soa.get_absolute_url())
- self.assertTrue(soa.get_edit_url())
+ self.assertTrue(soa.get_update_url())
self.assertTrue(soa.get_delete_url())
def test_add_remove(self):
View
@@ -90,7 +90,7 @@ def update_soa(request, soa_pk):
kv = get_attrs(request.POST)
update_attrs(kv, attrs, SOAKeyValue, soa, 'soa')
soa = form.save()
- return redirect(soa.get_edit_url())
+ return redirect(soa.get_update_url())
except ValidationError, e:
if form._errors is None:
form._errors = ErrorDict()
@@ -20,7 +20,7 @@ def do_generic_add(self, data):
srv.save()
self.assertTrue(srv.details())
self.assertTrue(srv.get_absolute_url())
- self.assertTrue(srv.get_edit_url())
+ self.assertTrue(srv.get_update_url())
self.assertTrue(srv.get_delete_url())
rsrv = SRV.objects.filter(**data)
self.assertTrue(len(rsrv) == 1)
@@ -18,7 +18,7 @@ def do_generic_add(self, data):
sshfp.save()
self.assertTrue(sshfp.details())
self.assertTrue(sshfp.get_absolute_url())
- self.assertTrue(sshfp.get_edit_url())
+ self.assertTrue(sshfp.get_update_url())
self.assertTrue(sshfp.get_delete_url())
rsshfp = SSHFP.objects.filter(**data)
self.assertTrue(len(rsshfp) == 1)
@@ -16,8 +16,8 @@
<div class='dns-title'>{{ object }}</div>
{% block action_bar %}
- {% if object.get_edit_url %}
- <a class="btn btn-primary" href="{{ object.get_edit_url() }}">Edit</a>
+ {% if object.get_update_url %}
+ <a class="btn btn-primary" href="{{ object.get_update_url() }}">Edit</a>
{% endif %}
{% block mid_action_bar %}
@@ -22,7 +22,7 @@
<span id="cydns-record"
data-recordType="{{ record_type }}"
data-searchUrl="{{ url('cydns-search-record') }}"
- data-updateUrl="{{ url('cydns-update-record') }}"
+ data-getUrl="{{ url('cydns-get-record') }}"
data-domainsUrl="{{ url('get-all-domains') }}">
</span>
@@ -43,11 +43,11 @@
<div {% if not form.errors %}class="hidden"{% endif %} id="cydns-record-form">
<form method="POST">
- <h2 id="record-form-title"></h2>
- <div class="inner-form">
- {{ form.as_p() }}
- </div>
- <input type="submit" value="Submit"></input>
+ <h2 id="record-form-title"></h2>
+ <div class="inner-form">
+ {{ form.as_p() }}
+ </div>
+ <input type="submit" value="Submit"></input>
</form>
</div>
@@ -25,7 +25,7 @@ def do_generic_add(self, data):
txt.save()
self.assertTrue(txt.details())
self.assertTrue(txt.get_absolute_url())
- self.assertTrue(txt.get_edit_url())
+ self.assertTrue(txt.get_update_url())
self.assertTrue(txt.get_delete_url())
rtxt = TXT.objects.filter(**data)
self.assertTrue(len(rtxt) == 1)
Oops, something went wrong.

0 comments on commit 680e089

Please sign in to comment.