示例#1
0
def _get_project_child_entities(project, user, is_analyst):
    has_case_review_perm = has_case_review_permissions(project, user)

    families_by_guid = _retrieve_families(project.guid, is_analyst, has_case_review_perm)
    individuals_by_guid, individual_models = _retrieve_individuals(project.guid, is_analyst, has_case_review_perm)
    for individual_guid, individual in individuals_by_guid.items():
        families_by_guid[individual['familyGuid']]['individualGuids'].add(individual_guid)
    samples_by_guid = _retrieve_samples(
        project.guid, individuals_by_guid, Sample.objects.filter(individual__in=individual_models))
    igv_samples_by_guid = _retrieve_samples(
        project.guid, individuals_by_guid, IgvSample.objects.filter(individual__in=individual_models),
        sample_guid_key='igvSampleGuids')
    mme_submissions_by_guid = _retrieve_mme_submissions(individuals_by_guid, individual_models)
    analysis_groups_by_guid = _retrieve_analysis_groups(project)
    locus_lists = get_json_for_locus_lists(LocusList.objects.filter(projects__id=project.id), user, is_analyst=is_analyst)
    locus_lists_by_guid = {locus_list['locusListGuid']: locus_list for locus_list in locus_lists}
    return {
        'familiesByGuid': families_by_guid,
        'individualsByGuid': individuals_by_guid,
        'samplesByGuid': samples_by_guid,
        'igvSamplesByGuid': igv_samples_by_guid,
        'locusListsByGuid': locus_lists_by_guid,
        'analysisGroupsByGuid': analysis_groups_by_guid,
        'mmeSubmissionsByGuid': mme_submissions_by_guid,
    }
示例#2
0
def _get_case_review_fields(model, project, user):
    if not (user and has_case_review_permissions(project, user)):
        return []
    return [
        field.name for field in type(model)._meta.fields
        if field.name.startswith('case_review')
    ]
示例#3
0
def _get_case_review_fields(model, has_case_review_perm, user, get_project):
    if has_case_review_perm is None:
        has_case_review_perm = user and has_case_review_permissions(
            get_project(model), user)
    if not has_case_review_perm:
        return []
    return [
        field.name for field in type(model)._meta.fields
        if field.name.startswith('case_review')
    ]
示例#4
0
def _update_case_review(model,
                        project,
                        request,
                        field,
                        get_response_json,
                        additional_updates=None):
    if not has_case_review_permissions(project, request.user):
        raise PermissionDenied('User cannot edit case review for this project')

    update_json = {field: json.loads(request.body).get(field)}
    if additional_updates:
        update_json.update(additional_updates)

    update_model_from_json(model, update_json, user=request.user)

    return create_json_response(
        {model.guid: get_response_json(model, request.user)})