Esempio n. 1
0
def add_obj(request):
	form = ObjectiveForm(request.POST or None)
	if request.method == "POST" and form.is_valid():
		o = form.save(commit=False)
		o.user = request.user
		o.save()
		return HttpResponseRedirect(reverse('okr:index'))
	return render(request, "okr/add_obj.html", {'form': form})
Esempio n. 2
0
def add_obj(request):
    form = ObjectiveForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        o = form.save(commit=False)
        o.user = request.user
        o.save()
        return redirect('okr:index')
    return render(request, "okr/add_obj.html", {'form': form})
Esempio n. 3
0
def edit_obj(request, id):
	obj = get_object_or_404(Objective, id=id, user=request.user)
	if request.method == "POST":
		form = ObjectiveForm(request.POST, instance=obj)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect(reverse('okr:index'))
	else:
		form = ObjectiveForm(instance=obj)
	context = {
		'form': form,
		'objective': obj
	}
	return render(request, "okr/edit_obj.html", context)
Esempio n. 4
0
def edit_obj(request, id):
    obj = get_object_or_404(Objective, id=id, user=request.user)
    if request.method == "POST":
        form = ObjectiveForm(request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return redirect('okr:index')
    else:
        form = ObjectiveForm(instance=obj)
    context = {
        'form': form,
        'objective': obj
    }
    return render(request, "okr/edit_obj.html", context)
Esempio n. 5
0
def create_obj_form(name, end_date):
	return ObjectiveForm(data={'name': name,
							   'end_date': end_date,
	})