コード例 #1
0
ファイル: staff.py プロジェクト: beholderrk/commonapps
def followup_edit(request, ticket_id, followup_id, ):
    "Edit followup options with an ability to change the ticket."
    followup = get_object_or_404(FollowUp, id=followup_id)
    ticket = get_object_or_404(Ticket, id=ticket_id)
    if request.method == 'GET':
        form = EditFollowUpForm(initial=
                                     {'title': escape(followup.title),
                                      'ticket': followup.ticket,
                                      'comment': escape(followup.comment),
                                      'public': followup.public,
                                      'new_status': followup.new_status,
                                      })
        
        return render_to_response('helpdesk/followup_edit.html',
            RequestContext(request, {
                'followup': followup,
                'ticket': ticket,
                'form': form,
        }))
    elif request.method == 'POST':
        form = EditFollowUpForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            _ticket = form.cleaned_data['ticket']
            comment = form.cleaned_data['comment']
            public = form.cleaned_data['public']
            new_status = form.cleaned_data['new_status']
            #will save previous date
            old_date = followup.date
            followup.delete()
            new_followup = FollowUp(title=title, date=old_date, ticket=_ticket, comment=comment, public=public, new_status=new_status, )
            new_followup.save()
        return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
コード例 #2
0
ファイル: staff.py プロジェクト: albertogaona/django-helpdesk
def followup_edit(request, ticket_id, followup_id, ):
    "Edit followup options with an ability to change the ticket."
    followup = get_object_or_404(FollowUp, id=followup_id)
    ticket = get_object_or_404(Ticket, id=ticket_id)
    if request.method == 'GET':
        form = EditFollowUpForm(initial=
                                     {'title': escape(followup.title),
                                      'ticket': followup.ticket,
                                      'comment': escape(followup.comment),
                                      'public': followup.public,
                                      'new_status': followup.new_status,
                                      })
        
        return render_to_response('helpdesk/followup_edit.html',
            RequestContext(request, {
                'followup': followup,
                'ticket': ticket,
                'form': form,
        }))
    elif request.method == 'POST':
        form = EditFollowUpForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            _ticket = form.cleaned_data['ticket']
            comment = form.cleaned_data['comment']
            public = form.cleaned_data['public']
            new_status = form.cleaned_data['new_status']
            #will save previous date
            old_date = followup.date
            followup.delete()
            new_followup = FollowUp(title=title, date=old_date, ticket=_ticket, comment=comment, public=public, new_status=new_status, )
            new_followup.save()
        return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
コード例 #3
0
ファイル: staff.py プロジェクト: yekibud/django-helpdesk
def followup_edit(request, ticket_id, followup_id):
    "Edit followup options with an ability to change the ticket."
    followup = get_object_or_404(FollowUp, id=followup_id)
    ticket = get_object_or_404(Ticket, id=ticket_id)
    if request.method == "GET":
        form = EditFollowUpForm(
            initial={
                "title": escape(followup.title),
                "ticket": followup.ticket,
                "comment": escape(followup.comment),
                "public": followup.public,
                "new_status": followup.new_status,
            }
        )

        return render_to_response(
            "helpdesk/followup_edit.html",
            RequestContext(request, {"followup": followup, "ticket": ticket, "form": form}),
        )
    elif request.method == "POST":
        form = EditFollowUpForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data["title"]
            _ticket = form.cleaned_data["ticket"]
            comment = form.cleaned_data["comment"]
            public = form.cleaned_data["public"]
            new_status = form.cleaned_data["new_status"]
            # will save previous date
            old_date = followup.date
            new_followup = FollowUp(
                title=title, date=old_date, ticket=_ticket, comment=comment, public=public, new_status=new_status
            )
            # keep old user if one did exist before.
            if followup.user:
                new_followup.user = followup.user
            new_followup.save()
            # get list of old attachments & link them to new_followup
            attachments = Attachment.objects.filter(followup=followup)
            for attachment in attachments:
                attachment.followup = new_followup
                attachment.save()
            # delete old followup
            followup.delete()
        return HttpResponseRedirect(reverse("helpdesk_view", args=[ticket.id]))