Ejemplo n.º 1
0
def alignment_detail(request, alignment_id):

    alignment = get_object_or_404(Alignment, pk=alignment_id)

    if request.method == 'POST':
        if request.POST['action'] == 'delete':
            alignment.delete()
            return HttpResponseRedirect(reverse(deleted))

        if request.POST['action'] == 'edit':
            form = EditAlignmentForm(request.POST, instance=alignment)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(alignment.get_absolute_url())
            else:
                return HttpResponseBadRequest("That input wasn't valid")

    elif request.method == 'GET':
        context = {}

        if 'edit' in request.GET:
            context['edit_form'] = EditAlignmentForm(instance=alignment)
        elif 'delete' in request.GET:
            context['show_delete_form'] = True

        alignment_rows = alignment.rows.order_by("clade__lft").values(
            "num", "name", "sequence")

        pre = PreRenderer("noraseq/prerendered_row_tds.html", alignment)
        for row in alignment_rows:
            row['prerendered_tds'] = pre.render_row(row['sequence'])

        context['alignment'] = alignment
        context['alignment_rows'] = alignment_rows
        context['header_row'] = range(1, alignment.length + 1)
        context['num_cols'] = alignment.length

        return render_to_response('noraseq/alignment_detail.html', context,
                                  RequestContext(request))
Ejemplo n.º 2
0
def alignment_detail(request, alignment_id):

    alignment = get_object_or_404(Alignment, pk=alignment_id)

    if request.method == 'POST':
        if request.POST['action'] == 'delete':
            alignment.delete()
            return HttpResponseRedirect(reverse(deleted))
        
        if request.POST['action'] == 'edit':
            form = EditAlignmentForm(request.POST, instance=alignment)
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(alignment.get_absolute_url())
            else:
                return HttpResponseBadRequest("That input wasn't valid")
                
    elif request.method == 'GET':
        context = {}
        
        if 'edit' in request.GET:
            context['edit_form'] = EditAlignmentForm(instance=alignment)
        elif 'delete' in request.GET:
            context['show_delete_form'] = True

        alignment_rows = alignment.rows.order_by("clade__lft").values("num", "name", "sequence")
        
        pre = PreRenderer("noraseq/prerendered_row_tds.html", alignment)
        for row in alignment_rows:
            row['prerendered_tds'] = pre.render_row(row['sequence'])

        context['alignment'] = alignment 
        context['alignment_rows'] = alignment_rows
        context['header_row'] = range(1,alignment.length+1)
        context['num_cols'] = alignment.length

        return render_to_response('noraseq/alignment_detail.html', context, RequestContext(request))
Ejemplo n.º 3
0
def prerender_tds(rows, alignment):
    pre = PreRenderer("noraseq/prerendered_row_tds.html", alignment)
    for row in rows:
        row['prerendered_tds'] = pre.render_row(row['sequence'])