コード例 #1
0
    def test_submit_ticket(self, get_zendesk):
        """Verify the http calls that are triggered by submit_ticket"""
        zd = FauxZendesk('https://appsmarket.zendesk.com', '[email protected]', 'pwd')
        get_zendesk.return_value = zd

        submit_ticket('[email protected]', 'cat', 'subject', 'description')
        zd.client.request.assert_called_with(
            'https://appsmarket.zendesk.com/tickets.json?',
            'POST',
            body='{"ticket": {"requester_email": "[email protected]", "set_tags": "cat", '
                 '"description": "description", '
                 '"subject": "[TEST] subject"}}',
            headers={
                'Content-Type': 'application/json',
                'User-agent': 'Zendesk Python Library v1.1.0'})
コード例 #2
0
    def test_submit_ticket(self, get_zendesk):
        """Verify the http calls that are triggered by submit_ticket"""
        zd = FauxZendesk('https://appsmarket.zendesk.com', '[email protected]', 'pwd')
        get_zendesk.return_value = zd

        submit_ticket('[email protected]', 'cat', 'subject', 'description')
        zd.client.request.assert_called_with(
            'https://appsmarket.zendesk.com/tickets.json?',
            'POST',
            body='{"ticket": {"requester_email": "[email protected]", "set_tags": "cat", '
            '"description": "description", '
            '"subject": "[TEST] subject"}}',
            headers={
                'Content-Type': 'application/json',
                'User-agent': 'Zendesk Python Library v1.1.0'
            })
コード例 #3
0
ファイル: views.py プロジェクト: pablocubico/kitsune
def marketplace_category(request, category_slug, template=None):
    """AAQ category page. Handles form post that submits ticket."""
    try:
        category_name = MARKETPLACE_CATEGORIES[category_slug]
    except KeyError:
        raise Http404

    error_message = None

    if request.method == "GET":
        form = MarketplaceAaqForm(request.user)
    else:
        form = MarketplaceAaqForm(request.user, request.POST)
        if form.is_valid():
            subject = form.cleaned_data["subject"]
            body = form.cleaned_data["body"]
            category = form.cleaned_data["category"]

            if request.user.is_authenticated():
                email = request.user.email
            else:
                email = form.cleaned_data["email"]

            # Submit ticket
            try:
                submit_ticket(email, category, subject, body)
            except ZendeskError:
                error_message = _("There was an error submitting the ticket, " "please try again later.")

            if not error_message:
                return HttpResponseRedirect(reverse("questions.marketplace_aaq_success"))

    return jingo.render(
        request,
        template,
        {
            "category": category_name,
            "category_slug": category_slug,
            "categories": MARKETPLACE_CATEGORIES,
            "form": form,
            "error_message": error_message,
        },
    )
コード例 #4
0
ファイル: views.py プロジェクト: ibai/kitsune
def marketplace_category(request, category_slug, template=None):
    """AAQ category page. Handles form post that submits ticket."""
    try:
        category_name = MARKETPLACE_CATEGORIES[category_slug]
    except KeyError:
        raise Http404

    error_message = None

    if request.method == 'GET':
        form = MarketplaceAaqForm(request.user)
    else:
        form = MarketplaceAaqForm(request.user, request.POST)
        if form.is_valid():
            subject = form.cleaned_data['subject']
            body = form.cleaned_data['body']
            category = form.cleaned_data['category']

            if request.user.is_authenticated():
                email = request.user.email
            else:
                email = form.cleaned_data['email']

            # Submit ticket
            try:
                submit_ticket(email, category, subject, body)
            except ZendeskError:
                error_message = _('There was an error submitting the ticket, '
                                  'please try again later.')

            if not error_message:
                return HttpResponseRedirect(
                    reverse('questions.marketplace_aaq_success'))

    return jingo.render(
        request, template, {
            'category': category_name,
            'category_slug': category_slug,
            'categories': MARKETPLACE_CATEGORIES,
            'form': form,
            'error_message': error_message
        })
コード例 #5
0
ファイル: views.py プロジェクト: victorneo/kitsune
def marketplace_category(request, category_slug, template=None):
    """AAQ category page. Handles form post that submits ticket."""
    try:
        category_name = MARKETPLACE_CATEGORIES[category_slug]
    except KeyError:
        raise Http404

    error_message = None

    if request.method == 'GET':
        form = MarketplaceAaqForm(request.user)
    else:
        form = MarketplaceAaqForm(request.user, request.POST)
        if form.is_valid():
            subject = form.cleaned_data['subject']
            body = form.cleaned_data['body']
            category = form.cleaned_data['category']

            if request.user.is_authenticated():
                email = request.user.email
            else:
                email = form.cleaned_data['email']

            # Submit ticket
            try:
                submit_ticket(email, category, subject, body)
            except ZendeskError:
                error_message = _('There was an error submitting the ticket, '
                                  'please try again later.')

            if not error_message:
                return HttpResponseRedirect(
                    reverse('questions.marketplace_aaq_success'))

    return jingo.render(request, template, {
        'category': category_name,
        'category_slug': category_slug,
        'categories': MARKETPLACE_CATEGORIES,
        'form': form,
        'error_message': error_message})