Commit 2d70750e by Kálmán Viktor

firewall: add get_absolute_url functions to models

parent 059334a1
...@@ -128,6 +128,10 @@ class Rule(models.Model): ...@@ -128,6 +128,10 @@ class Rule(models.Model):
(("dport=%s " % self.dport) if self.dport else '')), (("dport=%s " % self.dport) if self.dport else '')),
'desc': self.description} 'desc': self.description}
@models.permalink
def get_absolute_url(self):
return ('network.rule', None, {'pk': self.pk})
class Meta: class Meta:
verbose_name = _("rule") verbose_name = _("rule")
verbose_name_plural = _("rules") verbose_name_plural = _("rules")
...@@ -261,6 +265,10 @@ class Vlan(models.Model): ...@@ -261,6 +265,10 @@ class Vlan(models.Model):
"""String representation of selected IPv4 network.""" """String representation of selected IPv4 network."""
return self.net4 + "/" + unicode(self.prefix4) return self.net4 + "/" + unicode(self.prefix4)
@models.permalink
def get_absolute_url(self):
return ('network.vlan', None, {'vid': self.vid})
class VlanGroup(models.Model): class VlanGroup(models.Model):
""" """
...@@ -285,6 +293,10 @@ class VlanGroup(models.Model): ...@@ -285,6 +293,10 @@ class VlanGroup(models.Model):
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@models.permalink
def get_absolute_url(self):
return ('network.vlangroup', None, {'pk': self.pk})
class Group(models.Model): class Group(models.Model):
""" """
...@@ -304,6 +316,10 @@ class Group(models.Model): ...@@ -304,6 +316,10 @@ class Group(models.Model):
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@models.permalink
def get_absolute_url(self):
return ('network.group', None, {'pk': self.pk})
class Host(models.Model): class Host(models.Model):
""" """
...@@ -549,6 +565,10 @@ class Host(models.Model): ...@@ -549,6 +565,10 @@ class Host(models.Model):
""" """
return self.hostname + u'.' + unicode(self.vlan.domain) return self.hostname + u'.' + unicode(self.vlan.domain)
@models.permalink
def get_absolute_url(self):
return ('network.host', None, {'pk': self.pk})
class Firewall(models.Model): class Firewall(models.Model):
name = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=20, unique=True)
...@@ -568,6 +588,10 @@ class Domain(models.Model): ...@@ -568,6 +588,10 @@ class Domain(models.Model):
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@models.permalink
def get_absolute_url(self):
return ('network.domain', None, {'pk': self.pk})
class Record(models.Model): class Record(models.Model):
CHOICES_type = (('A', 'A'), ('CNAME', 'CNAME'), ('AAAA', 'AAAA'), CHOICES_type = (('A', 'A'), ('CNAME', 'CNAME'), ('AAAA', 'AAAA'),
...@@ -683,6 +707,10 @@ class Record(models.Model): ...@@ -683,6 +707,10 @@ class Record(models.Model):
'ttl': self.ttl, 'ttl': self.ttl,
'address': address} 'address': address}
@models.permalink
def get_absolute_url(self):
return ('network.record', None, {'pk': self.pk})
class Blacklist(models.Model): class Blacklist(models.Model):
CHOICES_type = (('permban', 'permanent ban'), ('tempban', 'temporary ban'), CHOICES_type = (('permban', 'permanent ban'), ('tempban', 'temporary ban'),
...@@ -705,6 +733,10 @@ class Blacklist(models.Model): ...@@ -705,6 +733,10 @@ class Blacklist(models.Model):
def __unicode__(self): def __unicode__(self):
return self.ipv4 return self.ipv4
@models.permalink
def get_absolute_url(self):
return ('network.blacklist', None, {'pk': self.pk})
def send_task(sender, instance, created, **kwargs): def send_task(sender, instance, created, **kwargs):
from firewall.tasks import ReloadTask from firewall.tasks import ReloadTask
......
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