Parcourir la source

Allow a configuration model to skip save_subnet and delete_subnet

Baptiste Jonglez il y a 10 ans
Parent
commit
7200a26d11
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 4 2
      coin/configuration/models.py

+ 4 - 2
coin/configuration/models.py

@@ -90,7 +90,8 @@ def subnet_save_event(sender, **kwargs):
     subnet = kwargs['instance']
     try:
         config = subnet.configuration
-        config.save_subnet(subnet, kwargs['created'])
+        if hasattr(config, 'save_subnet'):
+            config.save_subnet(subnet, kwargs['created'])
     except ObjectDoesNotExist:
         pass
 
@@ -103,6 +104,7 @@ def subnet_delete_event(sender, **kwargs):
     subnet = kwargs['instance']
     try:
         config = subnet.configuration
-        config.delete_subnet(subnet)
+        if hasattr(config, 'delete_subnet'):
+            config.delete_subnet(subnet)
     except ObjectDoesNotExist:
         pass