Esempio n. 1
0
def status_add(request, response_format='html'):
    "Status add"
    
    if request.POST:    
        form = ChangeSetStatusForm(request.user.get_profile(), request.POST)
        if form.is_valid():
            status = form.save()
            return HttpResponseRedirect(reverse('changes_status_view', args=[status.id]))
    else:
        form = ChangeSetStatusForm(request.user.get_profile())
    
    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('changes/status_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
Esempio n. 2
0
def status_edit(request, status_id, response_format='html'):
    "Status edit"
    
    status = get_object_or_404(ChangeSetStatus, pk=status_id)
    
    if request.POST:    
        form = ChangeSetStatusForm(request.user.get_profile(), request.POST, instance=status)
        if form.is_valid():
            status = form.save()
            return HttpResponseRedirect(reverse('changes_status_view', args=[status.id]))
    else:
        form = ChangeSetStatusForm(request.user.get_profile(), instance=status)
    
    context = _get_default_context(request)
    context.update({'status': status, 'form': form})

    return render_to_response('changes/status_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)