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)
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)
def comment_add(request, proid): url = request.META.get('HTTP_REFERER') if request.method == 'POST': current_user = request.user data = Comment() data.product_id = proid data.user_id = current_user.id data.name = current_user.username data.email = current_user.email data.subject = request.POST['subject'] data.message = request.POST['message'] data.save() messages.success(request, "ur review has been sent.") return HttpResponseRedirect(url) else: return HttpResponseRedirect(url)
def addComment(request, id): url = request.META.get('HTTP_REFERER') # get last url if request.method == 'POST': form = CommentForm(request.POST) if form.is_valid(): current_user = request.user data = Comment() data.user_id = current_user.id data.product_id = id data.subject = form.cleaned_data['subject'] data.comment = form.cleaned_data['comment'] data.rate = form.cleaned_data['rate'] data.ip = request.META.get('REMOTE_ADDR') data.save() messages.success(request, "Yorumunuz başarı ile gönderildi") return HttpResponseRedirect(url) messages.warning(request, "Yorumunuz kaydedilmedi, kontrol edin") return HttpResponseRedirect(url)