Commit aa53d585 by Bach Dániel Committed by Bach Dániel

firewall: remove get_data()

parent a9b24356
......@@ -105,17 +105,7 @@ class DomainAdmin(admin.ModelAdmin):
class RecordAdmin(admin.ModelAdmin):
list_display = ('name_', 'type', 'address_', 'ttl', 'host', 'owner')
@staticmethod
def address_(instance):
a = instance.get_data()
return a['address'] if a else None
@staticmethod
def name_(instance):
a = instance.get_data()
return a['name'] if a else None
list_display = ('name', 'type', 'address', 'ttl', 'host', 'owner')
class BlacklistAdmin(admin.ModelAdmin):
......
......@@ -355,23 +355,22 @@ def dns():
models.settings['dns_ttl']))
for r in models.Record.objects.all():
d = r.get_data()
if d['type'] == 'A':
DNS.append("+%s:%s:%s" % (d['name'], d['address'], d['ttl']))
elif d['type'] == 'AAAA':
if r.type == 'A':
DNS.append("+%s:%s:%s" % (r.fqdn, r.address, r.ttl))
elif r.type == 'AAAA':
DNS.append(":%s:28:%s:%s" %
(d['name'], ipv6_to_octal(d['address']), d['ttl']))
elif d['type'] == 'NS':
DNS.append("&%s::%s:%s" % (d['name'], d['address'], d['ttl']))
elif d['type'] == 'CNAME':
DNS.append("C%s:%s:%s" % (d['name'], d['address'], d['ttl']))
elif d['type'] == 'MX':
mx = d['address'].split(':', 2)
(r.fqdn, ipv6_to_octal(r.address), r.ttl))
elif r.type == 'NS':
DNS.append("&%s::%s:%s" % (r.fqdn, r.address, r.ttl))
elif r.type == 'CNAME':
DNS.append("C%s:%s:%s" % (r.fqdn, r.address, r.ttl))
elif r.type == 'MX':
mx = r.address.split(':', 2)
DNS.append("@%(fqdn)s::%(mx)s:%(dist)s:%(ttl)s" %
{'fqdn': d['name'], 'mx': mx[1], 'dist': mx[0],
'ttl': d['ttl']})
elif d['type'] == 'PTR':
DNS.append("^%s:%s:%s" % (d['name'], d['address'], d['ttl']))
{'fqdn': r.fqdn, 'mx': mx[1], 'dist': mx[0],
'ttl': r.ttl})
elif r.type == 'PTR':
DNS.append("^%s:%s:%s" % (r.fqdn, r.address, r.ttl))
return DNS
......
......@@ -687,9 +687,7 @@ class Record(models.Model):
return self.desc()
def desc(self):
a = self.get_data()
return (u' '.join([a['name'], a['type'], a['address']])
if a else unicode(_('(empty)')))
return u' '.join([self.fqdn, self.type, self.address])
def save(self, *args, **kwargs):
self.full_clean()
......@@ -725,17 +723,6 @@ class Record(models.Model):
else:
return self.domain.name
def get_data(self):
name = self.fqdn
address = self.address
if not address or not name:
return None
else:
return {'name': name,
'type': self.type,
'ttl': self.ttl,
'address': address}
@models.permalink
def get_absolute_url(self):
return ('network.record', None, {'pk': self.pk})
......
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