Пример #1
0
def add(request, project_id):
    project = Project.objects.get(pk=project_id)
    if request.method == 'POST':
        form = SprintForm(request.POST)
        if form.is_valid():
            sprint = form.save(False)
            sprint.project = project
            sprint.save()
            request.user.message_set.create(message="New sprint has been added.")
            return HttpResponseRedirect('/sprint/show/' + str(sprint.id))
    else:
        form = SprintForm()
    return render_to_response('sprint/add.html', {'form': form, 'project': project}, context_instance=RequestContext(request))
Пример #2
0
def edit(request, sprint_id):
    sprint = Sprint.objects.get(pk=sprint_id)
    if request.method == 'POST':
        form = SprintForm(request.POST)
        if form.is_valid():
            sprint.name = form.cleaned_data['name']
            sprint.description = form.cleaned_data['description']
            sprint.start_at = form.cleaned_data['start_at']
            sprint.end_at = form.cleaned_data['end_at']
            sprint.save()
            request.user.message_set.create(message="Sprint has been modified.")
            return HttpResponseRedirect('/sprint/show/' + str(sprint.id))
    else:
        form = SprintForm(instance=sprint)
    return render_to_response('sprint/edit.html', {'form': form, 'project': sprint.project}, context_instance=RequestContext(request))