Commits

George Notaras  committed 3cd88f9

Refactoring: moved code from signal callbacks to Record model's save() method.

  • Participants
  • Parent commits c784dff

Comments (0)

Files changed (1)

File src/powerdns_manager/signal_cb.py

 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 #
-
-import time
-
-from django.db.models.loading import cache
-
-from powerdns_manager import settings
-
-
-
-def set_soa_rr_name(sender, **kwargs):
-    """Sets the ``name`` field of the SOA record.
-    
-    PowerDNS Manager allows only one SOA RR per zone.
-    
-    This callback updates the ``name`` field of the SOA record and
-    sats it eual to the name of the associated domain.
-    
-    """
-    instance = kwargs['instance']   # powerdns_manager.Record instance
-    if instance.type == 'SOA':
-        instance.name = instance.domain.name
-
-
-def update_rr_change_date(sender, **kwargs):
-    """Sets the current timestamp to the ``change_date`` field.
-    
-    This is used by PowerDNS.
-    
-    """
-    instance = kwargs['instance']   # powerdns_manager.Record instance
-    instance.change_date = int(time.time())
-
-
-def set_rr_ttl(sender, **kwargs):
-    """Sets the TTL of the resource record(s).
-    
-    This is done according to the following rules:
-    
-    1) TTL of SOA RRs is not modified here. Missing TTL information is handled
-    in forms.SoaRecordModelForm.save() method. The minimum TTL is retrieved
-    from the SOA content field, so it would make no sense to set it in this
-    callback.
-    
-    2) If the RR is not a SOA and if TTL is missing, the minimum TTL of
-    the zone (as defined in the SOA record) will be used. If a SOA record
-    is missing, PDNS_DEFAULT_RR_TTL is returned by Domain.get.minimum_ttl().
-    
-    """
-    instance = kwargs['instance']   # powerdns_manager.Record instance
-    if not instance.ttl and instance.type != 'SOA':
-        instance.ttl = instance.domain.get_minimum_ttl()
-
-
-def set_rr_authoritative(sender, **kwargs):
-    """This callback fills the ``auth`` field of the Record model.
-    
-    TODO: list the rules to fill the field.
-    
-    """ 
-    instance = kwargs['instance']   # powerdns_manager.Record instance
-
-
-def set_rr_ordername(sender, **kwargs):
-    """This callback fills the ``ordername`` field of the Record model.
-    
-    TODO: list the rules to fill the field.
-    
-    """ 
-    instance = kwargs['instance']   # powerdns_manager.Record instance
-
-