'Create a snapshot of course access rules when rules are deleted.'

@staticmethod
def snapshot_post_delete_receiver(sender, instance, **kwargs):

    if isinstance(instance, RestrictedCourse):
        CourseAccessRuleHistory.save_snapshot(instance, deleted=True)
    elif isinstance(instance, CountryAccessRule):
        try:
            restricted_course = instance.restricted_course
        except RestrictedCourse.DoesNotExist:
            pass
        else:
            CourseAccessRuleHistory.save_snapshot(restricted_course)
