@receiver(SignalHandler.item_deleted)
def handle_item_deleted(**kwargs):
 usage_key = kwargs.get('usage_key')
 if usage_key:
  usage_key = usage_key.for_branch(None)
  course_key = usage_key.course_key
  deleted_module = modulestore().get_item(usage_key)
  for module in yield_dynamic_descriptor_descendants(deleted_module, kwargs.get('user_id')):
   gating_api.remove_prerequisite(module.location)
   gating_api.set_required_content(course_key, module.location, None, None)

@ receiver ( SignalHandler . item_deleted ) def handle_item_deleted ( ** kwargs ) : usage_key = kwargs . get ( 'usage_key' ) if usage_key : usage_key = usage_key . for_branch ( None ) course_key = usage_key . course_key deleted_module = modulestore ( ) . get_item ( usage_key ) for module in yield_dynamic_descriptor_descendants ( deleted_module , kwargs . get ( 'user_id' ) ) : gating_api . remove_prerequisite ( module . location ) gating_api . set_required_content ( course_key , module . location , None , None )
receives the item_deleted signal sent by studio when an xblock is removed from the course structure and removes any gating milestone data associated with it or its descendants .