Esempio n. 1
0
def postquestion(request):
    try:
        data = QuestionForm(request.POST)
        print data
        if data.is_valid() == True:
            data.save()
            return HttpResponse("Question posted Successfully")
        return HttpResponse("Question could not be posted")
    except Exception, e:
        logging.exception("")
Esempio n. 2
0
def product_view(request, product_id):
    try:
        product = Product.objects.get(pk=product_id)
    except ObjectDoesNotExist:
        return HttpResponseNotFound("<h1>Page not found</h1>")
    if request.method == 'POST':
        form = QuestionForm(request.POST)
        if form.is_valid():
            qn = form.cleaned_data['question']
            answers = req_rank_retrieve(qn, product_id)
            return render(request, 'portal/answer.html', {'answers': answers, 'product_id': product_id, 'qn': qn})
    else:
        form = QuestionForm()

    return render(request, 'portal/product.html', {'form': form, 'product_id': product_id, 'product': product})
Esempio n. 3
0
def product_view(request, product_id):
    try:
        product = Product.objects.get(pk=product_id)
    except ObjectDoesNotExist:
        return HttpResponseNotFound("<h1>Page not found</h1>")
    if request.method == 'POST':
        form = QuestionForm(request.POST)
        if form.is_valid():
            qn = form.cleaned_data['question']
            answers = req_rank_retrieve(qn, product_id)
            return render(request, 'portal/answer.html', {
                'answers': answers,
                'product_id': product_id,
                'qn': qn
            })
    else:
        form = QuestionForm()

    return render(request, 'portal/product.html', {
        'form': form,
        'product_id': product_id,
        'product': product
    })