Exemple #1
0
def update(request, id, aid):
    project = request.user.participate_projects.get(id=id)
    action = get_object_or_404(Action, pk=aid)
    form = ActionForm(instance=action)
    if request.method == 'POST':
        form = ActionForm(request.POST, instance=action)
        if form.is_valid():
            action = form.save()
            return HttpResponseRedirect(reverse('action_list', args=[action.project.id]))
    return render(request, 'project/action/update.html', {'project': project, 'form': form})
Exemple #2
0
def create(request, id):
    project = request.user.participate_projects.get(id=id)
    form = ActionForm()
    if request.method == "POST":
        form = ActionForm(request.POST)
        if form.is_valid():
            action = form.save(commit=False)
            action.project = project
            action.save()
            return HttpResponseRedirect(reverse('action_list', args=[id]))
    return render(request, 'project/action/create.html', {'project': project, 'form': form})