Beispiel #1
0
def task_edit(request,pk):
	if request.user.is_authenticated():
		user=request.user
		task = Task.objects.get(pk=pk)
		if request.method=="POST" and request.POST:
			t = TaskForm(request.POST)
			if t.is_valid():
				t = TaskForm(request.POST,instance=task)
				t.save()
				return HttpResponseRedirect(reverse("task.views.task_view"))
			else:
				return HttpResponse("Validation Error")
		else:
			tform = TaskForm(instance=task)
			d=dict(user=user,tform=tform)
			d.update(csrf(request))
			return render_to_response('task_edit.html',d)
	else:
		return HttpResponse("No Authentication")
Beispiel #2
0
def save(request):
    if request.method == 'POST':
        task = TaskForm(request.POST)
        if task.is_valid():
            new_task = task.save(commit=False)
            new_task.author = request.user
            new_task.save()
    # task = request.POST
    # name = task.name
    # topic = task.topic
    # level = task.level
    # content = task.content
    # author = request.user
    # Task.object.create_task(name, author, level, topic, content)
    return HttpResponseRedirect('/profile/')
Beispiel #3
0
def task_entry(request):
	if request.user.is_authenticated():
		if request.method=="POST" and request.POST:
			t = TaskForm(request.POST)
			if t.is_valid():
				task = t.save(commit=False)
				task.user = request.user
				task.save()
				return HttpResponse("Data Saved To Task")
			else:
				return HttpResponse("Reenter Task in Form")
		else:
			return HttpResponseRedirect(reverse("task.views.user"))
	else:
		return HttpResponse("No Authentication")