Commits

George Notaras committed d464799

Improved BaseRecordModelForm.

Comments (0)

Files changed (1)

src/powerdns_manager/forms.py

     """Base ModelForm for Record instances.
     
     """
+    class Meta:
+        model = cache.get_model('powerdns_manager', 'Record')
+    
 
 
 class SoaRecordModelForm(BaseRecordModelForm):
     expire = forms.IntegerField(min_value=300, initial=604800, required=True, label=_('expire'), help_text="""If for expire seconds the primary server cannot be reached, all information about the zone is invalidated on the secondary servers (i.e., they are no longer authoritative for that zone). Example: 604800""")
     default_ttl = forms.IntegerField(min_value=300, initial=86400, required=True, label=_('minimum TTL'), help_text="""The minimum TTL field that should be exported with any RR from this zone. If any RR in the database has a lower TTL, this TTL is sent instead. Example: 86400""")
 
-    class Meta:
-        model = cache.get_model('powerdns_manager', 'Record')
-
     def __init__(self, *args, **kwargs):
         """ModelForm constructor.
         
 class NsRecordModelForm(BaseRecordModelForm):
     """ModelForm for NS resource records."""
 
-    class Meta:
-        model = cache.get_model('powerdns_manager', 'Record')
-
     def save(self, *args, **kwargs):
         self.instance.type = 'NS'
         return super(NsRecordModelForm, self).save(*args, **kwargs)
 class MxRecordModelForm(BaseRecordModelForm):
     """ModelForm for MX resource records."""
 
-    class Meta:
-        model = cache.get_model('powerdns_manager', 'Record')
-
     def save(self, *args, **kwargs):
         self.instance.type = 'MX'
         return super(MxRecordModelForm, self).save(*args, **kwargs)
 class SrvRecordModelForm(BaseRecordModelForm):
     """ModelForm for SRV resource records."""
 
-    class Meta:
-        model = cache.get_model('powerdns_manager', 'Record')
-
     def save(self, *args, **kwargs):
         self.instance.type = 'SRV'
         return super(SrvRecordModelForm, self).save(*args, **kwargs)
     )
     type_avail = forms.ChoiceField(initial='', required=True, choices=AVAILABLE_RECORD_TYPE_CHOICES, label=_('type'), help_text="""Select the resource record type.""")
 
-    class Meta:
-        model = cache.get_model('powerdns_manager', 'Record')
-
     def __init__(self, *args, **kwargs):
         if kwargs.has_key('instance'):
             instance = kwargs['instance']