Beispiel #1
0
def add(request, project_id):

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

    if request.method == 'POST':
        form = base_forms.AddCohortForm(project, request.POST)
        if form.is_valid():
            cohort = Cohort.objects.create(
                project=project,
                cohort_id=form.cleaned_data['cohort_id'],
                display_name=form.cleaned_data['name'],
                short_description=form.cleaned_data['description'],
            )
            for indiv in form.cleaned_data['individuals']:
                cohort.individuals.add(indiv)
            cohort.save()

            # TODO figure out a way to launch variant loading in the background
            #xbrowse_controls.load_variants_for_cohort_list(project, [cohort])

            return JSONResponse({'is_error': False, 'next_page': reverse('cohort_home', args=(project.project_id, cohort.cohort_id))})
        else:
            return JSONResponse({'is_error': True, 'error': server_utils.form_error_string(form)})

    individuals_json = json_displays.individual_list(project.get_individuals())

    return render(request, 'cohort/add.html', {
        'project': project,
        'individuals_json': json.dumps(individuals_json),
    })
Beispiel #2
0
def add(request, project_id):

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

    if request.method == 'POST':
        form = base_forms.AddCohortForm(project, request.POST)
        if form.is_valid():
            cohort = Cohort.objects.create(
                project=project,
                cohort_id=form.cleaned_data['cohort_id'],
                display_name=form.cleaned_data['name'],
                short_description=form.cleaned_data['description'],
            )
            for indiv in form.cleaned_data['individuals']:
                cohort.individuals.add(indiv)
            tasks.reload_cohort_variants.delay(project_id, cohort.cohort_id)
            return JSONResponse({'is_error': False, 'next_page': reverse('cohort_home', args=(project.project_id, cohort.cohort_id))})
        else:
            return JSONResponse({'is_error': True, 'error': server_utils.form_error_string(form)})

    individuals_json = json_displays.individual_list(project.get_individuals())

    return render(request, 'cohort/add.html', {
        'project': project,
        'individuals_json': json.dumps(individuals_json),
    })
Beispiel #3
0
def add(request, project_id):

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

    if request.method == 'POST':
        form = base_forms.AddCohortForm(project, request.POST)
        if form.is_valid():
            cohort = Cohort.objects.create(
                project=project,
                cohort_id=form.cleaned_data['cohort_id'],
                display_name=form.cleaned_data['name'],
                short_description=form.cleaned_data['description'],
            )
            for indiv in form.cleaned_data['individuals']:
                cohort.individuals.add(indiv)
            cohort.save()

            # TODO figure out a way to launch variant loading in the background
            #xbrowse_controls.load_variants_for_cohort_list(project, [cohort])

            return JSONResponse({'is_error': False, 'next_page': reverse('cohort_home', args=(project.project_id, cohort.cohort_id))})
        else:
            return JSONResponse({'is_error': True, 'error': server_utils.form_error_string(form)})

    individuals_json = json_displays.individual_list(project.get_individuals())

    return render(request, 'cohort/add.html', {
        'project': project,
        'individuals_json': json.dumps(individuals_json),
    })
Beispiel #4
0
def project_individuals(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        return HttpResponse("unauthorized")

    _individuals = json_displays.individual_list(project.get_individuals())

    return render(
        request, "individual/individuals.html", {"project": project, "individuals_json": json.dumps(_individuals)}
    )
Beispiel #5
0
def project_individuals(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        return HttpResponse('unauthorized')

    _individuals = json_displays.individual_list(project.get_individuals())

    return render(request, 'individual/individuals.html', {
        'project': project,
        'individuals_json': json.dumps(_individuals),
    })
Beispiel #6
0
def project_individuals(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        raise PermissionDenied

    _individuals = json_displays.individual_list(project.get_individuals())

    return render(request, 'individual/individuals.html', {
        'project': project,
        'individuals_json': json.dumps(_individuals),
    })
Beispiel #7
0
def project_individuals(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        raise PermissionDenied

    _individuals = json_displays.individual_list(project.get_individuals())

    return render(request, 'individual/individuals.html', {
        'project': project,
        'individuals_json': json.dumps(_individuals),
    })
Beispiel #8
0
def project_individuals(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        return HttpResponse('unauthorized')

    _individuals = json_displays.individual_list(project.get_individuals())

    return render(request, 'individual/individuals.html', {
        'project': project,
        'individuals_json': json.dumps(_individuals),
    })