Exemplo n.º 1
0
def edittask(request, department=None,task=None):
    tasks = Task.objects.get(id=task)
    if request.method == 'POST':
        form = TaskForm(request.POST, instance=tasks)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department/{0}/task'.format(department), {'success': 'Task edited'})
        else:
            return render(request,'mapping/edittask.html', {'title': 'Department', 'form': form, 'department_id': department ,'task_id' : task })
    else:
        form = TaskForm(instance=tasks)
        return render(request,'mapping/edittask.html', {'title': 'Department', 'form': form , 'department_id': department,'task_id' : task })
Exemplo n.º 2
0
def newtask(request):
    departments = Department.objects.all().order_by('name')
    tasks = Task.objects.all().order_by('name')
    if request.method == "POST":
        form = TaskForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/newtask', {'success': 'Task Added'})
        else:
            return render(request,'mapping/newtask.html',{'departments': departments, 'title':'NEW TASK ', 'tasks': tasks , 'form' : form})

    else:
        form = TaskForm()
        return render(request,'mapping/newtask.html',{'departments': departments, 'title':'NEW TASK ', 'tasks': tasks , 'form' : form})
Exemplo n.º 3
0
def newtask(request,id=None):
    if request.method == "POST":
        form = TaskForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.department = Department.objects.get(id=id)
            instance.save()
            return HttpResponseRedirect('/admin/department/{0}/task'.format(id), {'success': 'Task Added'})
        else:
            return render(request,'mapping/newtask.html',{'title':'NEW TASK ', 'department_id': id, 'tasks': tasks , 'form' : form})

    else:
        form = TaskForm()
        return render(request,'mapping/newtask.html',{ 'title':'NEW TASK ','department_id': id ,'tasks': tasks , 'form' : form})
Exemplo n.º 4
0
def edittask(request, department=None,task=None):
    if not request.user.is_superuser:
        return HttpResponseRedirect('/department')

    tasks = Task.objects.get(id=task)
    if request.method == 'POST':
        form = TaskForm(request.POST, instance=tasks)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/admin/department/{0}/task'.format(department), {'success': 'Task edited'})
        else:
            return render(request,'mapping/edittask.html', {'title': 'Department', 'form': form, 'department_id': department ,'task_id' : task })
    else:
        form = TaskForm(instance=tasks)
        return render(request,'mapping/edittask.html', {'title': 'Department', 'form': form , 'department_id': department,'task_id' : task })
Exemplo n.º 5
0
def newtask(request,id=None):
    if not request.user.is_superuser:
        return HttpResponseRedirect('/department')

    if request.method == "POST":
        form = TaskForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.department = Department.objects.get(id=id)
            instance.save()
            return HttpResponseRedirect('/admin/department/{0}/task'.format(id), {'success': 'Task Added'})
        else:
            return render(request,'mapping/newtask.html',{'title':'NEW TASK ', 'department_id': id, 'tasks': tasks , 'form' : form})

    else:
        form = TaskForm()
        return render(request,'mapping/newtask.html',{ 'title':'NEW TASK ','department_id': id ,'tasks': tasks , 'form' : form})