Beispiel #1
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 #2
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)