예제 #1
0
def edit_ticket(request, ticket_id):
    user = request.user
    ticket = get_object_or_404(Ticket, id=ticket_id)
    if request.method == 'POST':
        form = AddTicket(request.POST)
        if form.is_valid():
            ticket.name = form.cleaned_data['name']
            ticket.description_ticket = form.cleaned_data['description']
            ticket.recent_user = user.email
            ticket.status = form.cleaned_data['status']
            ticket.save()
            ticket.developer = form.cleaned_data['developer']

            return HttpResponseRedirect(reverse('project', kwargs={ 'project_id':ticket.project.id }))
    else:
        form = AddTicket(
            initial={
                'name': ticket.name,
                'description': ticket.description_ticket,
                'developer': ticket.developer.all(),
                'status': ticket.status,
            })

    context = {'form':form, 'user':request.user }

    return render(request, 'project_ticket/edit_ticket.html', context)
예제 #2
0
def edit_ticket(request, ticket_id):
    user = request.user
    ticket = get_object_or_404(Ticket, id=ticket_id)
    if request.method == 'POST':
        form = AddTicket(request.POST)
        if form.is_valid():
            ticket.name = form.cleaned_data['name']
            ticket.description_ticket = form.cleaned_data['description']
            ticket.recent_user = user.email
            ticket.status = form.cleaned_data['status']
            ticket.save()
            ticket.developer = form.cleaned_data['developer']

            return HttpResponseRedirect(
                reverse('project', kwargs={'project_id': ticket.project.id}))
    else:
        form = AddTicket(
            initial={
                'name': ticket.name,
                'description': ticket.description_ticket,
                'developer': ticket.developer.all(),
                'status': ticket.status,
            })

    context = {'form': form, 'user': request.user}

    return render(request, 'project_ticket/edit_ticket.html', context)
예제 #3
0
def addticket(request, project_id):
    user = request.user
    ticket = Ticket()
    if request.method == 'POST':
        form = AddTicket(request.POST)
        if form.is_valid():
            ticket.name = form.cleaned_data['name']
            ticket.description_ticket = form.cleaned_data['description']
            ticket.recent_user = user.email
            ticket.project = Project.objects.get(pk=project_id)
            ticket.status = form.cleaned_data['status']
            ticket.save()
            ticket.developer = form.cleaned_data['developer'] # needs to be assigned after ticket.save(why?)
                                                              # ManyToManyField items can't be added to a model until after it's been saved.

            return HttpResponseRedirect(reverse('project', kwargs={ 'project_id':ticket.project.id }))
    else:
        form = AddTicket()

    context = {'form':form, 'user':request.user, 'proj_id': project_id}

    return render(request, 'project_ticket/addticket.html', context)
예제 #4
0
def addticket(request, project_id):
    user = request.user
    ticket = Ticket()
    if request.method == 'POST':
        form = AddTicket(request.POST)
        if form.is_valid():
            ticket.name = form.cleaned_data['name']
            ticket.description_ticket = form.cleaned_data['description']
            ticket.recent_user = user.email
            ticket.project = Project.objects.get(pk=project_id)
            ticket.status = form.cleaned_data['status']
            ticket.save()
            ticket.developer = form.cleaned_data[
                'developer']  # needs to be assigned after ticket.save(why?)
            # ManyToManyField items can't be added to a model until after it's been saved.

            return HttpResponseRedirect(
                reverse('project', kwargs={'project_id': ticket.project.id}))
    else:
        form = AddTicket()

    context = {'form': form, 'user': request.user, 'proj_id': project_id}

    return render(request, 'project_ticket/addticket.html', context)