示例#1
0
def new(request):
    excludes = ['resolution']

    if request.method == 'POST':
        form = TicketsForm(request.POST, exclude_list=excludes, is_stuff=request.user.is_staff, user=request.user, customer=request.organisation.id)
        if form.is_valid():
            tic = form.save()
            if tic.keep_it_simple:
                tic.keep_it_simple = False
                tic.save(user=request.user)

            assigned = form.cleaned_data.get('assigned')
            if assigned:
                touch_ticket(assigned, tic.pk)

            for ele in form.changed_data:
                form.initial[ele] = ''
            remember_changes(request, form, tic)

            touch_ticket(request.user, tic.pk)

            mail_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_MAIL_RCPT)
            jabber_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_JABBER_RCPT)

            if form.cleaned_data.get('file_addition', False):
                return HttpResponseRedirect('/tickets/upload/%s/' % tic.pk)
            else:
                return HttpResponseRedirect('/tickets/view/%s/' % tic.pk)

    else:
        form = TicketsForm(exclude_list=excludes, is_stuff=request.user.is_staff, user=request.user, customer=request.organisation.id)
    form.fields['state'].queryset = form.fields['state'].queryset.exclude(type=2)

    return render(request, 'tickets/new.html', {'layout': 'horizontal', 'form': form})
示例#2
0
def new(request):
    excludes = ['resolution']

    if request.method == 'POST':
        form = TicketsForm(request.POST, exclude_list=excludes, is_stuff=request.user.is_staff, user=request.user, customer=request.organisation.id)
        if form.is_valid():
            tic = form.save()
            if tic.keep_it_simple:
                tic.keep_it_simple = False
                tic.save(user=request.user)

            assigned = form.cleaned_data.get('assigned')
            if assigned:
                touch_ticket(assigned, tic.pk)

            for ele in form.changed_data:
                form.initial[ele] = ''
            remember_changes(request, form, tic)

            touch_ticket(request.user, tic.pk)

            mail_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_MAIL_RCPT)
            jabber_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_JABBER_RCPT)

            if form.cleaned_data.get('file_addition', False):
                return HttpResponseRedirect('/tickets/upload/%s/' % tic.pk)
            else:
                return HttpResponseRedirect('/tickets/view/%s/' % tic.pk)

    else:
        form = TicketsForm(exclude_list=excludes, is_stuff=request.user.is_staff, user=request.user, customer=request.organisation.id)
    form.fields['state'].queryset = form.fields['state'].queryset.exclude(type=2)

    return render(request, 'tickets/new.html', {'layout': 'horizontal', 'form': form})
示例#3
0
def create(attributes={}, notify=True, **kwargs):
    """
    array ticket.create(struct attributes={}, boolean notify=False)
    create a ticket, returning the new ticket in the same form as getTicket(). Requires a valid 'action' in attributes to support workflow.
    """
    from yats.forms import TicketsForm

    excludes = ['resolution']

    request = kwargs['request']
    params = {}
    for key, value in attributes.iteritems():
        params[TracNameTofieldName(key)] = value

    fakePOST = QueryDict(mutable=True)
    fakePOST.update(params)

    form = TicketsForm(fakePOST,
                       exclude_list=excludes,
                       is_stuff=request.user.is_staff,
                       user=request.user,
                       customer=request.organisation.id)
    if form.is_valid():
        tic = form.save()
        if tic.keep_it_simple:
            tic.keep_it_simple = False
            tic.save(user=request.user)

        assigned = form.cleaned_data.get('assigned')
        if assigned:
            touch_ticket(assigned, tic.pk)

        for ele in form.changed_data:
            form.initial[ele] = ''
        remember_changes(request, form, tic)

        touch_ticket(request.user, tic.pk)

        if notify:
            mail_ticket(request,
                        tic.pk,
                        form,
                        rcpt=settings.TICKET_NEW_MAIL_RCPT)
            jabber_ticket(request,
                          tic.pk,
                          form,
                          rcpt=settings.TICKET_NEW_JABBER_RCPT)

        return get(tic.id, **kwargs)

    else:
        raise Exception('missing attributes')
示例#4
0
文件: api.py 项目: mediafactory/yats
def create(attributes={}, notify=True, **kwargs):
    """
    array ticket.create(struct attributes={}, boolean notify=False)
    create a ticket, returning the new ticket in the same form as getTicket(). Requires a valid 'action' in attributes to support workflow.
    """
    from yats.forms import TicketsForm

    excludes = ['resolution']

    request = kwargs['request']
    params = {}
    for key, value in attributes.iteritems():
        params[TracNameTofieldName(key)] = value

    fakePOST = QueryDict(mutable=True)
    fakePOST.update(params)

    form = TicketsForm(fakePOST, exclude_list=excludes, is_stuff=request.user.is_staff, user=request.user, customer=request.organisation.id)
    if form.is_valid():
        tic = form.save()
        if tic.keep_it_simple:
            tic.keep_it_simple = False
            tic.save(user=request.user)

        assigned = form.cleaned_data.get('assigned')
        if assigned:
            touch_ticket(assigned, tic.pk)

        for ele in form.changed_data:
            form.initial[ele] = ''
        remember_changes(request, form, tic)

        touch_ticket(request.user, tic.pk)

        if notify:
            mail_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_MAIL_RCPT)
            jabber_ticket(request, tic.pk, form, rcpt=settings.TICKET_NEW_JABBER_RCPT)

        return get(tic.id, **kwargs)

    else:
        raise Exception('missing attributes')