Ejemplo n.º 1
0
def project_edit(request, project_id):	
	project = get_object_or_404(Project, pk=project_id)
	if request.method == "POST":
		form = ProjectForm(request.POST, instance = project)
		
		if form.is_valid():
			form.save()
			return redirect('project_list')
	else:
		form = ProjectForm(instance = project)
	return render(request, 'projects/edit.html', {"project" : project, "form" : form})
Ejemplo n.º 2
0
def project_add(request):
    if request.method == "POST":
        form = ProjectForm(request.POST)
        if form.is_valid():
            form.instance.start = datetime.date.today()
            form.instance.end = datetime.date.today()
            form.instance.added_by_user = request.user
            form.save()
            return redirect('project_list')
    else:
        form = ProjectForm()

    return render(request, 'projects/add.html', {"form": form})
Ejemplo n.º 3
0
def project_add(request):
	if request.method == "POST":
		form = ProjectForm(request.POST)
		if form.is_valid():
			form.instance.start = datetime.date.today()
			form.instance.end = datetime.date.today()
			form.instance.added_by_user = request.user
			form.save()
			return redirect('project_list')
	else:
		form = ProjectForm()
	
	return render(request, 'projects/add.html', {"form": form})
Ejemplo n.º 4
0
def project_edit(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    if request.method == "POST":
        form = ProjectForm(request.POST, instance=project)

        if form.is_valid():
            form.save()
            return redirect('project_list')
    else:
        form = ProjectForm(instance=project)
    return render(request, 'projects/edit.html', {
        "project": project,
        "form": form
    })