blob: 32d8f8ec8100faa50dea046f850bb98c3c6467ad [file] [log] [blame]
Sapan Bhatia0235e982014-09-03 13:14:40 -04001from django.db.models.signals import post_save
2from django.dispatch import receiver
3import pdb
Sapan Bhatia3a5980e2014-09-15 03:48:11 -04004from core.models import *
5import model_policies
Sapan Bhatia0235e982014-09-03 13:14:40 -04006
7@receiver(post_save)
Scott Bakerd56ccd72014-09-30 14:53:45 -07008def post_save_handler(sender, instance, **kwargs):
Sapan Bhatia0235e982014-09-03 13:14:40 -04009 sender_name = sender.__name__
10 policy_name = 'model_policy_%s'%sender_name
Sapan Bhatia640f2b72014-09-15 04:04:32 -040011
12 if (not kwargs['update_fields']):
13 try:
14 policy_handler = getattr(model_policies, policy_name)
Scott Bakerd56ccd72014-09-30 14:53:45 -070015 policy_handler.handle(instance)
Sapan Bhatia640f2b72014-09-15 04:04:32 -040016 except:
17 pass