示例#1
0
def view_ticket(request):
    ticket_req = request.GET.get('ticket', '')
    ticket = False
    email = request.GET.get('email', '')
    error_message = ''

    if ticket_req and email:
        parts = ticket_req.split('-')
        queue = '-'.join(parts[0:-1])
        ticket_id = parts[-1]

        try:
            ticket = Ticket.objects.get(id=ticket_id, queue__slug__iexact=queue, submitter_email__iexact=email)
        except:
            ticket = False
            error_message = _('Invalid ticket ID or e-mail address. Please try again.')

        if ticket:

            if request.user.is_staff:
                redirect_url = reverse('helpdesk_view', args=[ticket_id])
                if request.GET.has_key('close'):
                    redirect_url += '?close'
                return HttpResponseRedirect(redirect_url)

            if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket
                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    'new_status': Ticket.CLOSED_STATUS,
                    'public': 1,
                    'title': ticket.title,
                    'comment': _('Submitter accepted resolution and closed ticket'),
                    }
                if ticket.assigned_to:
                    request.POST['owner'] = ticket.assigned_to.id
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)

            # redirect user back to this ticket if possible.
            redirect_url = ''
            if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED:
                redirect_url = reverse('helpdesk_view', args=[ticket_id])

            return render_to_response('helpdesk/public_view_ticket.html',
                RequestContext(request, {
                    'ticket': ticket,
                    'helpdesk_settings': helpdesk_settings,
                    'next': redirect_url,
                }))

    return render_to_response('helpdesk/public_view_form.html',
        RequestContext(request, {
            'ticket': ticket,
            'email': email,
            'error_message': error_message,
            'helpdesk_settings': helpdesk_settings,
        }))
示例#2
0
文件: account.py 项目: brat002/ebscab
def view_ticket(request, ticket_id):
    """ Show a ticket comments, accepts new comments from user """
    ticket = get_object_or_404(Ticket, pk=ticket_id)
    if request.method == 'POST':
        if 'comment' in request.POST:
            from helpdesk.views.staff import update_ticket
            _resp = update_ticket(request, ticket.id, public=True)
            del _resp
            request.notifications.add(u"Комментарий успешно сохранен", 'success')

    return {'ticket':ticket, 'current_view_name':'helpdesk_account_tickets_view'}
示例#3
0
def view_ticket(request):
    ticket_req = request.GET.get('ticket', '')
    email = request.GET.get('email', '')

    if ticket_req and email:
        queue, ticket_id = Ticket.queue_and_id_from_query(ticket_req)
        try:
            ticket = Ticket.objects.get(id=ticket_id, submitter_email__iexact=email)
        except ObjectDoesNotExist:
            error_message = _('Invalid ticket ID or e-mail address. Please try again.')

            return render(request, 'helpdesk/public_view_form.html', {
                'ticket': False,
                'email': email,
                'error_message': error_message,
                'helpdesk_settings': helpdesk_settings,
            })
        else:
            if request.user.is_staff:
                redirect_url = reverse('helpdesk:view', args=[ticket_id])
                if 'close' in request.GET:
                    redirect_url += '?close'
                return HttpResponseRedirect(redirect_url)

            if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket
                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    'new_status': Ticket.CLOSED_STATUS,
                    'public': 1,
                    'title': ticket.title,
                    'comment': _('Submitter accepted resolution and closed ticket'),
                }
                if ticket.assigned_to:
                    request.POST['owner'] = ticket.assigned_to.id
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)

            # redirect user back to this ticket if possible.
            redirect_url = ''
            if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED:
                redirect_url = reverse('helpdesk:view', args=[ticket_id])

            return render(request, 'helpdesk/public_view_ticket.html', {
                'ticket': ticket,
                'helpdesk_settings': helpdesk_settings,
                'next': redirect_url,
            })
示例#4
0
文件: public.py 项目: brat002/ebscab
def view_ticket(request):
    ticket_req = request.GET.get('ticket', '')
    ticket = False
    email = request.GET.get('email', '')
    error_message = ''

    if ticket_req:
        parts = ticket_req.split('-')
        queue = '-'.join(parts[0:-1])
        ticket_id = parts[-1]

        try:
            ticket = Ticket.objects.get(id=ticket_id, owner=request.user)
            if ticket.notify_owner:
                ticket.notify_owner=False
                ticket.save()
                
                ticket.notify_owner=True
        except:
            ticket = False
            error_message = _('Invalid ticket ID or e-mail address. Please try again.')
        #print ticket
        if ticket:
            
            if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket
                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    'new_status': Ticket.CLOSED_STATUS,
                    'public': 1,
                    'owner': ticket.owner.id,
                    'title': ticket.title,
                    'comment': _('Submitter accepted resolution and closed ticket'),
                    }
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)
            
            return render_to_response('helpdesk/public_view_ticket.html',
                RequestContext(request, {
                    'ticket': ticket,
                }))

    return render_to_response('helpdesk/public_view_form.html',
        RequestContext(request, {
            'ticket': ticket,
            'email': email,
            'error_message': error_message,
        }))
示例#5
0
def view_ticket(request):
    ticket_req = request.GET.get("ticket", "")
    ticket = False
    email = request.GET.get("email", "")
    error_message = ""

    if ticket_req and email:
        parts = ticket_req.split("-")
        queue = "-".join(parts[0:-1])
        ticket_id = parts[-1]

        try:
            ticket = Ticket.objects.get(id=ticket_id, queue__slug__iexact=queue, submitter_email__iexact=email)
        except:
            ticket = False
            error_message = _("Invalid ticket ID or e-mail address. Please try again.")

        if ticket:

            if request.GET.has_key("close") and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket

                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    "new_status": Ticket.CLOSED_STATUS,
                    "public": 1,
                    "owner": ticket.assigned_to.id,
                    "title": ticket.title,
                    "comment": _("Submitter accepted resolution and closed ticket"),
                }
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)

            return render_to_response("helpdesk/public_view_ticket.html", RequestContext(request, {"ticket": ticket}))

    return render_to_response(
        "helpdesk/public_view_form.html",
        RequestContext(request, {"ticket": ticket, "email": email, "error_message": error_message}),
    )
示例#6
0
def view_ticket(request):
    ticket_req = request.GET.get('ticket', None)
    email = request.GET.get('email', None)

    if ticket_req and email:
        queue, ticket_id = Ticket.queue_and_id_from_query(ticket_req)
        try:
            ticket = Ticket.objects.get(id=ticket_id,
                                        submitter_email__iexact=email)
        except ObjectDoesNotExist:
            error_message = _(
                'Invalid ticket ID or e-mail address. Please try again.')
        else:
            if request.user.is_staff:
                redirect_url = reverse('helpdesk:view', args=[ticket_id])
                if 'close' in request.GET:
                    redirect_url += '?close'
                return HttpResponseRedirect(redirect_url)

            if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket
                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    'new_status':
                    Ticket.CLOSED_STATUS,
                    'public':
                    1,
                    'title':
                    ticket.title,
                    'comment':
                    _('Submitter accepted resolution and closed ticket'),
                }
                if ticket.assigned_to:
                    request.POST['owner'] = ticket.assigned_to.id
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)

            # redirect user back to this ticket if possible.
            redirect_url = ''
            if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED:
                redirect_url = reverse('helpdesk:view', args=[ticket_id])

            return render(
                request, 'helpdesk/public_view_ticket.html', {
                    'ticket': ticket,
                    'helpdesk_settings': helpdesk_settings,
                    'next': redirect_url,
                })
    elif ticket_req is None and email is None:
        error_message = None
    else:
        error_message = _(
            'Missing ticket ID or e-mail address. Please try again.')

    return render(
        request, 'helpdesk/public_view_form.html', {
            'ticket': False,
            'email': email,
            'error_message': error_message,
            'helpdesk_settings': helpdesk_settings,
        })
示例#7
0
def view_ticket(request):
    ticket_req = request.GET.get('ticket', None)
    email = request.GET.get('email', None)
    key = request.GET.get('key', '')

    if not (ticket_req and email):
        if ticket_req is None and email is None:
            return search_for_ticket(request)
        else:
            return search_for_ticket(
                request,
                _('Missing ticket ID or e-mail address. Please try again.'))

    queue, ticket_id = Ticket.queue_and_id_from_query(ticket_req)
    try:
        if hasattr(settings, 'HELPDESK_VIEW_A_TICKET_PUBLIC'
                   ) and settings.HELPDESK_VIEW_A_TICKET_PUBLIC:
            ticket = Ticket.objects.get(id=ticket_id,
                                        submitter_email__iexact=email)
        else:
            ticket = Ticket.objects.get(id=ticket_id,
                                        submitter_email__iexact=email,
                                        secret_key__iexact=key)
    except (ObjectDoesNotExist, ValueError):
        return search_for_ticket(
            request,
            _('Invalid ticket ID or e-mail address. Please try again.'))

    if is_helpdesk_staff(request.user):
        redirect_url = reverse('helpdesk:view', args=[ticket_id])
        if 'close' in request.GET:
            redirect_url += '?close'
        return HttpResponseRedirect(redirect_url)

    if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS:
        from helpdesk.views.staff import update_ticket
        # Trick the update_ticket() view into thinking it's being called with
        # a valid POST.
        request.POST = {
            'new_status': Ticket.CLOSED_STATUS,
            'public': 1,
            'title': ticket.title,
            'comment': _('Submitter accepted resolution and closed ticket'),
        }
        if ticket.assigned_to:
            request.POST['owner'] = ticket.assigned_to.id
        request.GET = {}

        return update_ticket(request, ticket_id, public=True)

    # redirect user back to this ticket if possible.
    redirect_url = ''
    if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED:
        redirect_url = reverse('helpdesk:view', args=[ticket_id])

    return render(
        request, 'helpdesk/public_view_ticket.html', {
            'key': key,
            'mail': email,
            'ticket': ticket,
            'helpdesk_settings': helpdesk_settings,
            'next': redirect_url,
        })
示例#8
0
def view_ticket(request):
    ticket_req = request.GET.get('ticket', '')
    ticket = False
    email = request.GET.get('email', '')
    error_message = ''

    if ticket_req and email:
        parts = ticket_req.split('-')
        queue = '-'.join(parts[0:-1])
        ticket_id = parts[-1]

        try:
            ticket = Ticket.objects.get(id=ticket_id,
                                        queue__slug__iexact=queue,
                                        submitter_email__iexact=email)
        except:
            ticket = False
            error_message = _(
                'Invalid ticket ID or e-mail address. Please try again.')

        if ticket:

            if request.user.is_staff:
                redirect_url = reverse('helpdesk_view', args=[ticket_id])
                if 'close' in request.GET:
                    redirect_url += '?close'
                return HttpResponseRedirect(redirect_url)

            if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS:
                from helpdesk.views.staff import update_ticket
                # Trick the update_ticket() view into thinking it's being called with
                # a valid POST.
                request.POST = {
                    'new_status':
                    Ticket.CLOSED_STATUS,
                    'public':
                    1,
                    'title':
                    ticket.title,
                    'comment':
                    _('Submitter accepted resolution and closed ticket'),
                }
                if ticket.assigned_to:
                    request.POST['owner'] = ticket.assigned_to.id
                request.GET = {}

                return update_ticket(request, ticket_id, public=True)

            # redirect user back to this ticket if possible.
            redirect_url = ''
            if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED:
                redirect_url = reverse('helpdesk_view', args=[ticket_id])

            return render_to_response(
                'helpdesk/public_view_ticket.html',
                RequestContext(
                    request, {
                        'ticket': ticket,
                        'helpdesk_settings': helpdesk_settings,
                        'next': redirect_url,
                    }))

    return render_to_response(
        'helpdesk/public_view_form.html',
        RequestContext(
            request, {
                'ticket': ticket,
                'email': email,
                'error_message': error_message,
                'helpdesk_settings': helpdesk_settings,
            }))