Beispiel #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)
Beispiel #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)
Beispiel #3
0
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)
Beispiel #4
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')

    if request.method == 'POST':  # check post
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()
            data.comment = form.cleaned_data['comment']
            data.ip = request.META.get('REMOTE_ADDR')
            data.item_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()
            messages.success(
                request,
                "Your comment has been sent. Thank you for your interest.")
            return HttpResponseRedirect(url)

    return HttpResponseRedirect(url)
Beispiel #5
0
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)