Exemple #1
0
def setTask(request):
    obj = Task(owner=request.user)
    form = TaskForm(request.user, request.POST, request.FILES, instance=obj)
    if form.is_valid(): 
        obj = form.save()
        return getTaskDetail(request.user, obj.id)
    else:
        message = {'task': {'error':{ } } }
        for k, v in form.errors.iteritems():
            message['job']['error'][k] = v[0]
        return message
Exemple #2
0
def editTask(request):
    try:
        obj = Task.objects.get(owner=request.user, id=request.POST['id'])
    except:
        return {'joblist': {'error':"Joblist does not exist", } }
    
    form = TaskForm(request.user, request.POST, request.FILES, instance=obj)
    if form.is_valid(): 
        obj = form.save()
        return getTaskDetail(request.user, obj.id)
    else:
        message = {'task': {'error':{ } } }
        for k, v in form.errors.iteritems():
            message['job']['error'][k] = v[0]
        return message