# -*- coding: utf-8 -*-
from django.db import models
import time

class Domain(models.Model):
    name = models.CharField(unique=True, max_length=255)
    master = models.CharField(max_length=128, blank=True, null=True)
    last_check = models.IntegerField(blank=True, null=True)
    type = models.CharField(max_length=6, blank=True, null=True)
    notified_serial = models.IntegerField(blank=True, null=True)
    account = models.CharField(max_length=40, blank=True, null=True)
    def __unicode__(self):
        return self.name
    class Meta:
        db_table = u'domains'
    def save(self):
        self.name = self.name.lower() # Get rid of CAPs before saving
        super(Domain, self).save() # Call the "real" save() method.

class Record(models.Model):
    domain = models.ForeignKey(Domain)
    name = models.CharField(max_length=255, blank=True, null=True)
    type = models.CharField(max_length=6, blank=True, null=True)
    content = models.CharField(max_length=255, blank=True, null=True)
    ttl = models.IntegerField(blank=True, null=True)
    prio = models.IntegerField(blank=True, null=True)
    change_date = models.IntegerField(blank=True, null=True)
    def __unicode__(self):
        return self.name
    class Meta:
        db_table = u'records'
    def save(self):
        self.name = self.name.lower() # Get rid of CAPs before saving
        if not self.change_date:
	    # Set change_date to current unix time to allow auto SOA update and slave notification
            self.change_date = int(time.time())
        super(Record, self).save() # Call the "real" save() method.


class Supermaster(models.Model):
    ip = models.CharField(max_length=25)
    nameserver = models.CharField(max_length=255)
    account = models.CharField(max_length=40, blank=True, null=True)
    class Meta:
        db_table = u'supermasters'

@@ -83,24 +83,138 @@
 els.Model):%0A
+    DOMAIN_TYPE = (%0A        ('MASTER', 'MASTER'),%0A        ('NATIVE', 'NATIVE'),%0A        ('SLAVE', 'SLAVE'),%0A    )%0A
     name = m
@@ -254,24 +254,24 @@
 length=255)%0A
-
     master =
@@ -446,24 +446,45 @@
 e, null=True
+, choices=DOMAIN_TYPE
 )%0A    notifi
@@ -888,24 +888,288 @@
 els.Model):%0A
+    RECORD_TYPE = (%0A        ('A', 'A'),%0A        ('AAAA', 'AAAA'),%0A        ('CNAME', 'CNAME'),%0A        ('MX', 'MX'),%0A        ('NS', 'NS'),%0A        ('PTR', 'PTR'),%0A        ('SOA', 'SOA'),%0A        ('SPF', 'SPF'),%0A        ('SRV', 'SRV'),%0A        ('TXT', 'TXT'),%0A    )%0A
     domain =
@@ -1321,24 +1321,45 @@
 e, null=True
+, choices=RECORD_TYPE
 )%0A    conten
@@ -1696,32 +1696,32 @@
 def save(self):%0A
-
         self.nam
@@ -1766,32 +1766,97 @@
 s before saving%0A
+        self.type = self.type.upper() # CAPITALISE before saving%0A
         if not s

Add domain and record types as a pick list