Ejemplo n.º 1
0
def comment_add(request, proid):
    # if this is a POST request we need to process the form data

    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':

        # create a form instance and populate it with data from the request:
        form = CommentForm(request.POST)
        # check whether it's valid:

        if form.is_valid():
            current_user = request.user
            data = Comment()
            data.product_id = proid
            data.user_id = current_user.id
            data.subject = form.cleaned_data['subject']
            data.rating = form.cleaned_data['rating']
            data.message = form.cleaned_data['message']
            data.save()

            messages.success(
                request,
                "Your review has been sent. Thank You for your interest ")
            return HttpResponseRedirect(url)
    else:
        return HttpResponseRedirect(url)
Ejemplo n.º 2
0
def comment_add(request, proid):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user
            data = Comment()
            data.product_id = proid
            data.user_id = current_user.id
            data.subject = form.cleaned_data['subject']
            data.rating = form.cleaned_data['rating']
            data.message = form.cleaned_data['message']
            data.save()
            messages.success(request, "Your review has been sent")
            return HttpResponseRedirect(url)
    else:
        return HttpResponseRedirect(url)