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