Exemplo n.º 1
0
def addcomment(request, id):
    category = Category.objects.all()
    product = Product.objects.get(pk=id)
    images = Images.objects.filter(product_id=id)
    comments = Comment.objects.filter(product_id=id, status='True')

    url = request.META.get('HTTP_REFERER')  # get last url
    # return HttpResponse(url)
    if request.method == 'POST':  # check post
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()  # create relation with model
            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.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()  # save data to table
            messages.success(request, "Your review has ben sent.")

    context = {
        'product': product,
        'category': category,
        'images': images,
        'comments': comments,
    }

    return render(request, 'product_detail.html', context)
Exemplo n.º 2
0
def addcomment(request,id):
    url = request.META.get('HTTP_REFERER') #get last url
    if request.method == 'POST':
        data = Comment()  # create relation with model
        data.subject = request.POST.get('subject')
        data.comment = request.POST.get('comment')
        data.rate = request.POST.get('rate')
        data.ip = request.META.get('REMOTE_ADDR')
        data.product_id=id
        current_user= request.user
        data.user_id=current_user.id
        data.save()  # save data to table
        messages.success(request, "Your review has ben sent. Thank you for your interest.")
        return HttpResponseRedirect(url)
Exemplo n.º 3
0
def Comment_Add(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        pos = CommenttForm(request.POST)
        if pos.is_valid():
            data = Comment()
            data.subject = pos.cleaned_data['subject']
            data.comment = pos.cleaned_data['comment']
            data.rate = pos.cleaned_data['rate']
            data.ip = request.META.get('REMOTE_ADDR')
            data.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()
            messages.success(request, 'Your informative comment has been sent')
            return HttpResponseRedirect(url)
    return HttpResponseRedirect(url)
Exemplo n.º 4
0
def addcoment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()
            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.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()
            messages.success(request, "Your review has been sent.")
            return HttpResponseRedirect(url)
    return HttpResponseRedirect(url)
Exemplo n.º 5
0
def comment(request, id):
    url = request.META.get('HTTP_REFERER')  # Le dernier url
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()
            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.produit_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()
            messages.success(request, 'votre avis compte')
            return HttpResponseRedirect(url)

    return HttpResponseRedirect(url)
Exemplo n.º 6
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')  # get last url
    # return HttpResponse(url)
    if request.method == 'POST':  # check post
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()  # create relation with model
            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.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()  # save data to table
            messages.success(request, "Your review has ben sent. Thank you for your interest.")
            return HttpResponseRedirect(url)

    return HttpResponseRedirect(url)
Exemplo n.º 7
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        form = CommentFrom(request.POST)
        if form.is_valid():
            current_user = request.user  # Access User session info
            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önderilmiştir. Teşekkür Ederiz..")
            return HttpResponseRedirect('/')
        messages.warning("Yorumunuz Gönderilemedi. Lütfen kontrol ediniz..")
    return HttpResponseRedirect(url)
Exemplo n.º 8
0
def addcomment(request,id):
        url = request.META.get('HTTP_REFERER')  # en son url'e dönüş yapmak için
        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'] #fields
                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ıyla Gönderilmiştir. Teşekkür ederiz..")

                return HttpResponseRedirect(url)
        messages.warning(request,'Yorum Gönderilmedi')
        return HttpResponseRedirect(url)
Exemplo n.º 9
0
def addcomment(request, id):

    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        print(request)
        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, 'Yorum Başarılı')
            return HttpResponseRedirect(url)

    messages.warning(request, "Yorum Kaydedilemedi.")
    return HttpResponseRedirect(url)
Exemplo n.º 10
0
def addcomment(request, id):
    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.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ıyla gönderilmiştir.")
            return HttpResponseRedirect(url)

    messages.warning(request,
                     "Yorumunuz gönderilemedi. Lütfen puan belirtiniz.")
    return HttpResponseRedirect(url)
Exemplo n.º 11
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')  #get last url
    #return HttpResponse(url)
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            data = Comment()  # create relation with model
            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.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()  # save data to table
            messages.success(
                request,
                "Sizning kommentariyangiz yuborildi,qiziqish uchun rahmat!")
            return HttpResponseRedirect(url)

    return HttpResponseRedirect(url)
Exemplo n.º 12
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    #return HttpResponse(url)
    # if this is a POST request we need to process the form data
    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():
            data = Comment()  #create relation with model
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']
            data.rate = form.cleaned_data['rate']
            data.ip_address = request.META['REMOTE_ADDR']
            data.product_id = id
            current_user = request.user
            data.user_id = current_user.id
            data.save()  #save data to table
            messages.success(
                request, "Your Review has been sent. Thanks for Reviewing")
            return HttpResponseRedirect(url)
    return HttpResponseRedirect(url)
Exemplo n.º 13
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')  # get last url
    if request.method == 'POST':  # form post edildiyse
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user  # Access User Session information
            data = Comment()  # model ile bağlantı kur
            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')  # Client computer ip address
            data.save()  # veritabanına kaydet
            messages.success(
                request,
                "Yorumunuz başarı ile gönderilmiştir. Teşekkür Ederiz")
            return HttpResponseRedirect(url)
            #return HttpResponse("Kaydedildi")
    messages.warning(request, "Yorumunuz kaydedilmedi. Lütfen kontrol ediniz")
    return HttpResponseRedirect(url)
Exemplo n.º 14
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')  # get last url
    if request.method == 'POST':  # form post edildiyse
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user

            data = Comment()  # model ile bağlantı kur
            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önderilmiştir.Teşekkür Ederiz.")

            return HttpResponseRedirect(url)
    messages.warning(request, "Yorumunuz gönderilememiştir tekrar deneyiniz.")
    return HttpResponseRedirect(url)
Exemplo n.º 15
0
def addcomment(request, id):
    url = request.META.get(
        'HTTP_REFERER')  # mesaj gittikten sonra olduğumuz yere dönmek için
    if request.method == 'POST':  # form post edildiyse
        form = CommentForm(request.POST)
        if form.is_valid():  # form geldi mi gelmedi mi kontrol eder
            current_user = request.user  # login olan userı getirir

            data = Comment()  # model ile bağlantı kur
            data.user_id = current_user.id
            data.product_id = id
            data.rate = form.cleaned_data['rate']
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']
            data.ip = request.META.get(
                'REMOTE_ADDR')  # client computer ip adress
            data.save()  # veritabanını kaydet

            messages.success(
                request, "Yorumunuz başarı ile gönderilmiştir.Teşekkür ederiz")
            return HttpResponseRedirect(url)
    messages.error(request, "Yorumunuz kaydedilmedi.Lütfen kontrol ediniz!")
    return HttpResponseRedirect(url)
Exemplo n.º 16
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':  #form post edildiyse
        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 gerçekleştirilmiştir. Teşekkür ederiz")

            return HttpResponseRedirect(url)

    messages.warning(request, "Yorumunuz kaydedilmedi. Lütfen kontrol ediniz")
    return HttpResponseRedirect(url)
Exemplo n.º 17
0
def addcomment(request, id):
    url = request.META.get(
        "HTTP_REFERER"
    )  # get last url yani post edilen url (yorum yazılan yer)
    if request.method == 'POST':  # form post edildiyse
        form = CommentForm(request.POST)
        if form.is_valid():  # form geçerli ise
            current_user = request.user  #user bilgisini aldık
            data = Comment()  # model ile bağlantı kur
            data.user_id = current_user.id
            data.car_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')  #pc id alıyoruz
            data.save()  # veritabanına kaydet
            messages.success(
                request,
                "Yorumunuz başarı ile gönderilmişitir.Teşekkür ederiz")

            return HttpResponseRedirect(url)
    messages.warning(request, "Yorumunuz kaydedilemedi.")
    return HttpResponseRedirect(url)
Exemplo n.º 18
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user  #Access User Session Information

            data = Comment()  #model ile bağlantı kur
            data.user_id = current_user.id
            data.pictures_id = id
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']  #formdan bilgiyi al
            data.rate = form.cleaned_data['rate']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()  #veritabanına kaydet
            messages.success(
                request,
                'Yorumunuz başarıyla gönderilmiştir. Teşekkür ederiz...')

            return HttpResponseRedirect(url)

    messages.warning(request,
                     "Yorumunuz kaydedilmedi. Lütfen kontrol ediniz..")
    return HttpResponseRedirect(url)