Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.get_observer_state(instance).current_groups = new_group_names
# if post delete, new_group_names should be []
# Django DDP had used the ordering of DELETE, UPDATE then CREATE for good reasons.
self.send_messages(
instance, old_group_names - new_group_names, Action.DELETE, **kwargs
)
# the object has been updated so that its groups are not the same.
self.send_messages(
instance, old_group_names & new_group_names, Action.UPDATE, **kwargs
)
#
self.send_messages(
instance, new_group_names - old_group_names, Action.CREATE, **kwargs
)
def post_save_receiver(self, instance: Model, created: bool, **kwargs):
"""
Handle the post save.
"""
if created:
self.database_event(instance, Action.CREATE)
else:
self.database_event(instance, Action.UPDATE)