def update_locus_list_handler(request, locus_list_guid): locus_list = LocusList.objects.get(guid=locus_list_guid) check_user_created_object_permissions(locus_list, request.user, permission_level=CAN_EDIT) request_json = json.loads(request.body) genes_by_id, intervals, invalid_items = parse_locus_list_items( request_json) if invalid_items and not request_json.get('ignoreInvalidItems'): return create_json_response({'invalidLocusListItems': invalid_items}, status=400, reason=INVALID_ITEMS_ERROR) update_model_from_json(locus_list, request_json, allow_unknown_keys=True) if genes_by_id is not None: _update_locus_list_items(locus_list, genes_by_id, intervals, request_json) return create_json_response({ 'locusListsByGuid': { locus_list.guid: get_json_for_locus_list(locus_list, request.user) }, 'genesById': genes_by_id or {}, })
def delete_locus_list_handler(request, locus_list_guid): locus_list = LocusList.objects.get(guid=locus_list_guid) check_user_created_object_permissions(locus_list, request.user, permission_level=CAN_EDIT) locus_list.delete() return create_json_response({'locusListsByGuid': {locus_list_guid: None}})
def update_gene_note_handler(request, gene_id, note_guid): note = GeneNote.objects.get(guid=note_guid) check_user_created_object_permissions(note, request.user) request_json = json.loads(request.body) update_model_from_json(note, request_json, user=request.user, allow_unknown_keys=True) return create_json_response({'genesById': {gene_id: { 'notes': _get_gene_notes(gene_id, request.user) }}})
def _delete_project(project_guid, user): """Delete project. Args: project_guid (string): GUID of the project to delete user (object): Django ORM model for the user """ project = Project.objects.get(guid=project_guid) check_user_created_object_permissions(project, user) IgvSample.bulk_delete(user, individual__family__project=project) Sample.bulk_delete(user, individual__family__project=project) Individual.bulk_delete(user, family__project=project) Family.bulk_delete(user, project=project) project.delete_model(user, user_can_delete=True)