Ejemplo n.º 1
0
Archivo: views.py Proyecto: 5n1p/treeio
def task_status_edit(request, status_id, response_format='html'):
    "TaskStatus edit"

    status = get_object_or_404(TaskStatus, pk=status_id)
    if not request.user.get_profile().has_permission(status, mode='w'):
        return user_denied(request, message="You don't have access to this Task Status")

    if request.POST:
        if not 'cancel' in request.POST:
            form = TaskStatusForm(
                request.user.get_profile(), request.POST, instance=status)
            if form.is_valid():
                status = form.save()
                return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id]))
        else:
            return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id]))
    else:
        form = TaskStatusForm(request.user.get_profile(), instance=status)

    context = _get_default_context(request)
    context.update({'form': form,
                    'status': status})

    return render_to_response('projects/status_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
Ejemplo n.º 2
0
Archivo: views.py Proyecto: 5n1p/treeio
def task_status_add(request, response_format='html'):
    "TaskStatus add"

    if not request.user.get_profile().is_admin('treeio.projects'):
        return user_denied(request, message="You don't have administrator access to the Projects module")

    if request.POST:
        if not 'cancel' in request.POST:
            status = TaskStatus()
            form = TaskStatusForm(
                request.user.get_profile(), request.POST, instance=status)
            if form.is_valid():
                status = form.save()
                status.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id]))
        else:
            return HttpResponseRedirect(reverse('projects_settings_view'))
    else:
        form = TaskStatusForm(request.user.get_profile())

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('projects/status_add', context,
                              context_instance=RequestContext(request), response_format=response_format)