No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

models.py 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from django.db import models
  2. from django.urls import reverse
  3. from whoisdb.models import MntdObject, Contact, InetNum
  4. # generally allow domains for .dn to be created
  5. # allow owners of a subnet to create reverse dns record?
  6. class Nameserver(MntdObject):
  7. handleSuffix = "NS"
  8. # dns name
  9. # ip address, if glue
  10. # ipv4/ipv6 address?
  11. handle = None
  12. name = models.CharField(max_length=256, unique=True)
  13. glueIPv4 = models.GenericIPAddressField(protocol='IPv4', blank=True, null=True)
  14. glueIPv6 = models.GenericIPAddressField(protocol='IPv6', blank=True, null=True)
  15. admin_c = models.ManyToManyField(Contact)
  16. def get_absolute_url(self):
  17. return reverse("domains:nameserver-show", args=(self.name,))
  18. def __str__(self):
  19. return self.name
  20. class Domain(MntdObject):
  21. handle = None
  22. handleSuffix = "DOM"
  23. name = models.CharField(max_length=67, unique=True, db_index=True)
  24. nameservers = models.ManyToManyField(Nameserver, blank=True)
  25. admin_c = models.ManyToManyField(Contact)
  26. def get_absolute_url(self):
  27. return reverse("domains:domain-show", args=(self.name,))
  28. def __str__(self):
  29. return self.name
  30. def getNoDeleteReasons(self):
  31. reasons = []
  32. nameservers = Nameserver.objects.filter(name__endswith="." + self.name)
  33. for ns in nameservers:
  34. reasons.append("Nameserver %s depends on this domain" % ns.name)
  35. return reasons
  36. #class NameserverDomainAssignment(models.Model):
  37. # domain = models.ForeignKey(Domain)
  38. # nameserver = models.ForeignKey(Nameserver)
  39. #
  40. # order = models.PositiveSmallIntegerField(default=0)
  41. class ReverseZone(models.Model):
  42. parentNet = models.ForeignKey(InetNum)
  43. address = models.GenericIPAddressField(db_index=True)
  44. netmask = models.PositiveIntegerField()
  45. nameservers = models.ManyToManyField(Nameserver)
  46. #class NameserverReverseZoneAssignment(models.Model):
  47. # reversezone = models.ForeignKey(ReverseZone)
  48. # nameserver = models.ForeignKey(Nameserver)
  49. #
  50. # order = models.PositiveSmallIntegerField()