def create_feature_segment_audit_log(instance, history_user, history_instance, **kwargs): # due to referential integrity issues that come from cascade deletes, we skip creating # audit logs for deleted feature segments for now # TODO: handle audit log in middleware instead project = None if history_instance.history_type == "-" else instance.feature.project message = FEATURE_SEGMENT_UPDATED_MESSAGE % (instance.feature.name, instance.environment.name) AuditLog.create_record(obj=instance.feature, obj_type=RelatedObjectType.FEATURE, log_message=message, author=history_user, project=project)
def create_feature_segment_audit_log(instance, history_user, history_instance, **kwargs): deleted = history_instance.history_type == "-" # if the feature segment has been deleted, this could have been a cascade delete from the project being deleted # if it is, then we can skip creating the audit log. project = instance.feature.project with transaction.atomic(): if deleted and not Project.objects.filter(id=project.id).exists(): return message = FEATURE_SEGMENT_UPDATED_MESSAGE % (instance.feature.name, instance.environment.name) AuditLog.create_record( obj=instance.feature, obj_type=RelatedObjectType.FEATURE, log_message=message, author=history_user, project=instance.feature.project )