Commit dce55ba2 by Bach Dániel

firewall: add description field to Setting

parent 2d56bdcd
...@@ -12,6 +12,7 @@ from modeldict import ModelDict ...@@ -12,6 +12,7 @@ from modeldict import ModelDict
class Setting(models.Model): class Setting(models.Model):
key = models.CharField(max_length=32) key = models.CharField(max_length=32)
value = models.CharField(max_length=200) value = models.CharField(max_length=200)
description = models.TextField(blank=True)
settings = ModelDict(Setting, key='key', value='value', instances=False) settings = ModelDict(Setting, key='key', value='value', instances=False)
...@@ -19,6 +20,7 @@ class Rule(models.Model): ...@@ -19,6 +20,7 @@ class Rule(models.Model):
CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), ('vlan', 'vlan')) CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), ('vlan', 'vlan'))
CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp')) CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp'))
CHOICES_dir = (('0', 'out'), ('1', 'in')) CHOICES_dir = (('0', 'out'), ('1', 'in'))
direction = models.CharField(max_length=1, choices=CHOICES_dir, blank=False) direction = models.CharField(max_length=1, choices=CHOICES_dir, blank=False)
description = models.TextField(blank=True) description = models.TextField(blank=True)
vlan = models.ManyToManyField('Vlan', symmetrical=False, blank=True, null=True) vlan = models.ManyToManyField('Vlan', symmetrical=False, blank=True, null=True)
...@@ -82,12 +84,15 @@ class Vlan(models.Model): ...@@ -82,12 +84,15 @@ class Vlan(models.Model):
domain = models.TextField(blank=True, validators=[val_domain]) domain = models.TextField(blank=True, validators=[val_domain])
dhcp_pool = models.TextField(blank=True) dhcp_pool = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
owner = models.ForeignKey(User, blank=True, null=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
def net_ipv6(self): def net_ipv6(self):
return self.net6 + "/" + unicode(self.prefix6) return self.net6 + "/" + unicode(self.prefix6)
def net_ipv4(self): def net_ipv4(self):
return self.net4 + "/" + unicode(self.prefix4) return self.net4 + "/" + unicode(self.prefix4)
def rules_l(self): def rules_l(self):
...@@ -116,6 +121,7 @@ class Alias(models.Model): ...@@ -116,6 +121,7 @@ class Alias(models.Model):
owner = models.ForeignKey(User, null=True, blank=True) owner = models.ForeignKey(User, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
class Meta: class Meta:
verbose_name_plural = 'aliases' verbose_name_plural = 'aliases'
...@@ -139,6 +145,7 @@ class Host(models.Model): ...@@ -139,6 +145,7 @@ class Host(models.Model):
def __unicode__(self): def __unicode__(self):
return self.hostname return self.hostname
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.id and self.ipv6 == "auto": if not self.id and self.ipv6 == "auto":
self.ipv6 = ipv4_2_ipv6(self.ipv4) self.ipv6 = ipv4_2_ipv6(self.ipv4)
......
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