2017-02-10 02:45:45 +01:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from dncore.models import User
|
2017-02-15 02:35:46 +01:00
|
|
|
from .validators import HandleValidator
|
2017-02-10 02:45:45 +01:00
|
|
|
|
2017-02-15 02:35:46 +01:00
|
|
|
|
|
|
|
class WhoisObject(models.Model):
|
|
|
|
handle_suffix = None
|
|
|
|
|
|
|
|
handle = models.SlugField(max_length='32', unique=True, validators=[HandleValidator()])
|
|
|
|
created = models.DateTimeField(auto_add_now=True)
|
|
|
|
last_modified = models.DateTimeField(auto_add_now=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
|
|
class Maintainer(WhoisObject):
|
2017-02-10 02:45:45 +01:00
|
|
|
auth = models.ManyToManyField(User)
|
2017-02-15 02:35:46 +01:00
|
|
|
|
|
|
|
admin_c = models.ManyToManyField("Contact")
|
|
|
|
|
|
|
|
class MntdObject(WhoisObject):
|
|
|
|
mnt_by = models.ManyToManyField(Maintainer)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
|
|
class Contact(MntdObject):
|
|
|
|
TYPE = (('person', 'person'), ('role', 'role'))
|
|
|
|
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
|
2017-02-21 20:45:44 +01:00
|
|
|
class ASBlock(MntdObject):
|
|
|
|
parent_block = models.ForeignKey("ASBlock", models.CASCADE, null=True, blank=True, default=None)
|
|
|
|
description = models.CharField(max_length=64, blank=True)
|
2017-02-15 02:35:46 +01:00
|
|
|
|
2017-02-21 20:45:44 +01:00
|
|
|
class ASNumber(MntdObject):
|
2017-02-15 02:35:46 +01:00
|
|
|
number = models.PositiveIntegerField(unique=True, db_index=True)
|
2017-02-21 20:45:44 +01:00
|
|
|
volatile = models.BooleanField(default=False)
|
|
|
|
asblock = models.ForeignKey(ASBlock, models.CASCADE)
|
|
|
|
description = models.CharField(max_length=64, blank=True)
|
|
|
|
|
|
|
|
mnt_lower = models.ManyToManyField(Maintainer)
|
2017-02-15 02:35:46 +01:00
|
|
|
|
2017-02-21 20:45:44 +01:00
|
|
|
#class Route(MntObject):
|
|
|
|
#
|
2017-02-15 02:35:46 +01:00
|
|
|
|
|
|
|
class InetNum(WhoisObject):
|
|
|
|
PROTO = (('ipv4', 'ipv4'), ('ipv6', 'ipv6'))
|
|
|
|
protocol = models.CharField(max_length=4, choices=PROTO)
|
|
|
|
netmask = models.PositiveIntegerField()
|
2017-02-21 20:45:44 +01:00
|
|
|
parent_range = models.ForeignKey("InetNum", models.CASCADE, null=True, blank=True, default=None)
|
|
|
|
description = models.CharField(max_length=64, blank=True)
|
2017-02-15 02:35:46 +01:00
|
|
|
|
2017-02-21 20:45:44 +01:00
|
|
|
mnt_lower = models.ManyToManyField(Maintainer)
|