Ejemplo n.º 1
0
def edit_tissue(request, pk):
    tissue = Tissue.objects.get(pk=pk)
    form = TissueForm(request.POST or None, instance=tissue)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/tissue/%s' % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed tissue."
            reversion.set_comment(comment)
            log(request, tissue, comment)
            return redirect('/annotations/tissue/%s' % pk)
    ctx = {'tissue': tissue, 'form': form, 'action': 'Edit'}
    return render_to_response('annotations/tissue_form.html', ctx,
        context_instance=RequestContext(request))
Ejemplo n.º 2
0
def edit_tissue(request, pk):
    tissue = Tissue.objects.get(pk=pk)
    form = TissueForm(request.POST or None, instance=tissue)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/tissue/%s' % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed tissue."
            reversion.set_comment(comment)
            log(request, tissue, comment)
            return redirect('/annotations/tissue/%s' % pk)
    ctx = {'tissue': tissue, 'form': form, 'action': 'Edit'}
    return render_to_response('annotations/tissue_form.html',
                              ctx,
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def add_tissue(request):
    form = TissueForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        with reversion.create_revision():
            tissue = form.save(commit=False)
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="******")
            reversion.set_user(request.user)
            comment = "Added tissue. %s" % request.POST['comment'] or ''
            reversion.set_comment(comment)
            log(request, tissue, comment)
            msg = "Successfully added tissue."
            messages.add_message(request, messages.SUCCESS, ugettext(msg))
            return redirect('/annotations/tissue/%s' % tissue.pk)
    ctx = {'form': form, 'action': 'Add'}
    return render_to_response('annotations/tissue_form.html', ctx,
        context_instance=RequestContext(request))
Ejemplo n.º 4
0
def add_tissue(request):
    form = TissueForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        with reversion.create_revision():
            tissue = form.save(commit=False)
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="******")
            reversion.set_user(request.user)
            comment = "Added tissue. %s" % request.POST['comment'] or ''
            reversion.set_comment(comment)
            log(request, tissue, comment)
            msg = "Successfully added tissue."
            messages.add_message(request, messages.SUCCESS, ugettext(msg))
            return redirect('/annotations/tissue/%s' % tissue.pk)
    ctx = {'form': form, 'action': 'Add'}
    return render_to_response('annotations/tissue_form.html',
                              ctx,
                              context_instance=RequestContext(request))