@classmethod
def delete_cases_by_flow_definition(cls, flow_definition):
    """ 
        Deletes all cases by flow definition
        """
    for flow_case in flow_definition.flow_case_set.select_related().all():
        for user_notification_option in flow_case.user_notification_option_set.select_related(
            ).all():
            user_notification_option.delete()
        for flow_property in flow_case.property_set.select_related().all():
            flow_property.delete()
        for doc in flow_case.document_set.select_related().all():
            doc.delete()
        for note in flow_case.note_set.select_related().all():
            note.delete()
        for status in flow_case.source.status_set.select_related().all():
            status.delete()
        for activity in flow_case.activity_set.select_related().all():
            for log in activity.activity_log_set.select_related().all():
                log.delete()
            activity.delete()
        flow_case.delete()
