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, }, )
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 })
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})