Ejemplo n.º 1
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        return HttpResponse('unauthorized')

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            family.short_description = form.cleaned_data['short_description']
            family.about_family_content = form.cleaned_data['about_family_content']
            family.analysis_status = form.cleaned_data['analysis_status']
            if 'pedigree_image' in request.FILES:
                family.pedigree_image = request.FILES['pedigree_image']
            family.save()
            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else:
        form = EditFamilyForm(initial={'short_description': family.short_description, 'about_family_content': family.about_family_content})

    return render(request, 'family_edit.html', {
        'project': project,
        'family': family,
        'error': error,
        'form': form,
        'analysis_statuses': ANALYSIS_STATUS_CHOICES
    })
Ejemplo n.º 2
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        return HttpResponse('unauthorized')

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            family.short_description = form.cleaned_data['short_description']
            family.about_family_content = form.cleaned_data['about_family_content']
            family.analysis_status = form.cleaned_data['analysis_status']
            if 'pedigree_image' in request.FILES:
                family.pedigree_image = request.FILES['pedigree_image']
            family.save()
            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else: 
        form = EditFamilyForm(initial={'short_description': family.short_description, 'about_family_content': family.about_family_content})

    return render(request, 'family_edit.html', {
        'project': project, 
        'family': family, 
        'error': error, 
        'form': form, 
    })
Ejemplo n.º 3
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            update_xbrowse_model(
                family,
                coded_phenotype=form.cleaned_data['coded_phenotype'],
                short_description=form.cleaned_data['short_description'],
                about_family_content=form.cleaned_data['about_family_content'],
                analysis_summary_content=form.cleaned_data['analysis_summary_content'],
                post_discovery_omim_number=form.cleaned_data['post_discovery_omim_number'])

            if family.analysis_status != form.cleaned_data['analysis_status']:
                if family.analysis_status not in ('Q', 'I'):
                    if not settings.DEBUG: settings.EVENTS_COLLECTION.insert({
                            'event_type': 'family_analysis_status_changed', 'project_id': project_id, 'family_id': family_id, 'date': timezone.now(), 
                            'username': request.user.username, 'email': request.user.email,
                            'from': family.analysis_status, 'to': form.cleaned_data['analysis_status'] })

                update_xbrowse_model(
                    family,
                    analysis_status=form.cleaned_data['analysis_status'],
                    analysis_status_date_saved=timezone.now(),
                    analysis_status_saved_by=request.user)

            if 'pedigree_image' in request.FILES:
                update_xbrowse_model(
                    family,
                    pedigree_image = request.FILES['pedigree_image'])

            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else:
        form = EditFamilyForm(initial={
            'coded_phenotype': family.coded_phenotype,
            'short_description': family.short_description,
            'about_family_content': family.about_family_content,
            'analysis_summary_content': family.analysis_summary_content,
            'post_discovery_omim_number': family.post_discovery_omim_number,
        })

    return render(request, 'family_edit.html', {
        'user': request.user,
        'project': project,
        'family': family,
        'error': error,
        'form': form,
        'analysis_statuses': ANALYSIS_STATUS_CHOICES,
        'new_page_url': '/project/{0}/family_page/{1}'.format(
            family.seqr_family.project.guid, family.seqr_family.guid) if family.seqr_family else None,
    })
Ejemplo n.º 4
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            update_xbrowse_model(
                family,
                coded_phenotype=form.cleaned_data['coded_phenotype'],
                short_description=form.cleaned_data['short_description'],
                about_family_content=form.cleaned_data['about_family_content'],
                analysis_summary_content=form.cleaned_data['analysis_summary_content'],
                post_discovery_omim_number=form.cleaned_data['post_discovery_omim_number'])

            if family.analysis_status != form.cleaned_data['analysis_status']:
                if family.analysis_status not in ('Q', 'I'):
                    if not settings.DEBUG: settings.EVENTS_COLLECTION.insert({
                            'event_type': 'family_analysis_status_changed', 'project_id': project_id, 'family_id': family_id, 'date': timezone.now(), 
                            'username': request.user.username, 'email': request.user.email,
                            'from': family.analysis_status, 'to': form.cleaned_data['analysis_status'] })

                update_xbrowse_model(
                    family,
                    analysis_status=form.cleaned_data['analysis_status'],
                    analysis_status_date_saved=timezone.now(),
                    analysis_status_saved_by=request.user)

            if 'pedigree_image' in request.FILES:
                update_xbrowse_model(
                    family,
                    pedigree_image = request.FILES['pedigree_image'])

            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else:
        form = EditFamilyForm(initial={
            'coded_phenotype': family.coded_phenotype,
            'short_description': family.short_description,
            'about_family_content': family.about_family_content,
            'analysis_summary_content': family.analysis_summary_content,
            'post_discovery_omim_number': family.post_discovery_omim_number,
        })

    return render(request, 'family_edit.html', {
        'user': request.user,
        'project': project,
        'family': family,
        'error': error,
        'form': form,
        'analysis_statuses': ANALYSIS_STATUS_CHOICES,
        'new_page_url': '/project/{0}/family_page/{1}'.format(
            family.seqr_family.project.guid, family.seqr_family.guid) if family.seqr_family else None,
    })
Ejemplo n.º 5
0
def edit_family_cause(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    causal_variants = list(CausalVariant.objects.filter(family=family))

    if request.GET.get('variant'):
        xpos, ref, alt = request.GET['variant'].split('|')
        c = CausalVariant.objects.get_or_create(
            family=family,
            xpos=int(xpos),
            ref=ref,
            alt=alt,
        )[0]
        causal_variants = list(CausalVariant.objects.filter(family=family))

    if request.method == 'POST':
        form = EditFamilyCauseForm(family, request.POST)
        if form.is_valid():
            CausalVariant.objects.filter(family=family).delete()
            for v_str in request.POST.getlist('variants'):
                xpos, ref, alt = v_str.split('|')
                CausalVariant.objects.create(
                    family=family,
                    xpos=int(xpos),
                    ref=ref,
                    alt=alt,
                )
                update_xbrowse_model(family,
                                     analysis_status='S',
                                     causal_inheritance_mode=form.
                                     cleaned_data['inheritance_mode'])

            return redirect('family_home',
                            project_id=project.project_id,
                            family_id=family.family_id)
        else:
            error = server_utils.form_error_string(form)
    else:
        form = EditFamilyForm(family)

    variants = []
    for c in causal_variants:
        variants.append(
            get_datastore(project).get_single_variant(project_id, family_id,
                                                      c.xpos, c.ref, c.alt))

    return render(
        request, 'family/edit_cause.html', {
            'project': project,
            'family': family,
            'error': error,
            'form': form,
            'variants': [v.toJSON() for v in variants],
        })
Ejemplo n.º 6
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            family.short_description = form.cleaned_data['short_description']
            family.about_family_content = form.cleaned_data[
                'about_family_content']
            family.analysis_summary_content = form.cleaned_data[
                'analysis_summary_content']

            if family.analysis_status != form.cleaned_data['analysis_status']:
                family.analysis_status = form.cleaned_data['analysis_status']
                family.analysis_status_date_saved = timezone.now()
                family.analysis_status_saved_by = request.user
            if 'pedigree_image' in request.FILES:
                family.pedigree_image = request.FILES['pedigree_image']
            family.save()

            return redirect('family_home',
                            project_id=project.project_id,
                            family_id=family.family_id)
    else:
        form = EditFamilyForm(
            initial={
                'short_description': family.short_description,
                'about_family_content': family.about_family_content,
                'analysis_summary_content': family.analysis_summary_content
            })

    return render(
        request, 'family_edit.html', {
            'project': project,
            'family': family,
            'error': error,
            'form': form,
            'analysis_statuses': ANALYSIS_STATUS_CHOICES,
        })
Ejemplo n.º 7
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            family.short_description = form.cleaned_data['short_description']
            family.about_family_content = form.cleaned_data['about_family_content']
            family.analysis_summary_content = form.cleaned_data['analysis_summary_content']

            if family.analysis_status != form.cleaned_data['analysis_status']:
                print("Analysis status changed to: %s" % form.cleaned_data['analysis_status'])
                if family.analysis_status not in ('Q', 'I'):
                    settings.EVENTS_COLLECTION.insert({
                            'event_type': 'family_analysis_status_changed', 'project_id': project_id, 'family_id': family_id, 'date': timezone.now(), 
                            'username': request.user.username, 'email': request.user.email,
                            'from': family.analysis_status, 'to': form.cleaned_data['analysis_status'] })

                family.analysis_status = form.cleaned_data['analysis_status']
                family.analysis_status_date_saved = timezone.now()
                family.analysis_status_saved_by = request.user

            if 'pedigree_image' in request.FILES:
                family.pedigree_image = request.FILES['pedigree_image']

            family.save()

            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else:
        form = EditFamilyForm(initial={'short_description': family.short_description, 'about_family_content': family.about_family_content, 'analysis_summary_content': family.analysis_summary_content})

    return render(request, 'family_edit.html', {
        'project': project,
        'family': family,
        'error': error,
        'form': form,
        'analysis_statuses': ANALYSIS_STATUS_CHOICES,
    })
Ejemplo n.º 8
0
def edit_family(request, project_id, family_id):
    error = None

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_admin(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        form = EditFamilyForm(request.POST, request.FILES)
        if form.is_valid():
            family.short_description = form.cleaned_data['short_description']
            family.about_family_content = form.cleaned_data['about_family_content']
            family.analysis_summary_content = form.cleaned_data['analysis_summary_content']
            family.analysis_status = form.cleaned_data['analysis_status']
            if 'pedigree_image' in request.FILES:
                family.pedigree_image = request.FILES['pedigree_image']
            family.save()

            analysis_status, created = AnalysisStatus.objects.get_or_create(family=family)
            if created or analysis_status.status != form.cleaned_data['analysis_status']:
                analysis_status.user = request.user
                analysis_status.date_saved = datetime.datetime.now()
                analysis_status.status = form.cleaned_data['analysis_status']
                analysis_status.save()

            return redirect('family_home', project_id=project.project_id, family_id=family.family_id)
    else:
        form = EditFamilyForm(initial={'short_description': family.short_description, 'about_family_content': family.about_family_content, 'analysis_summary_content': family.analysis_summary_content})

    return render(request, 'family_edit.html', {
        'project': project,
        'family': family,
        'error': error,
        'form': form,
        'analysis_statuses': ANALYSIS_STATUS_CHOICES,
    })