示例#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)
示例#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)
示例#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)
示例#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)
示例#5
0
文件: views.py 项目: Daouda46/e_shop
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)
示例#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)
示例#7
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.produce_id = id
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()
            messages.success(
                request, "Yorumunuz başarı ile göndeilmiştir.TEŞEKKÜR EDERİZ.")
            return HttpResponseRedirect(url)
    messages.warning(request,
                     "Yorumunuz Kaydedilemedi.Lütfen kontrol ediniz!!!")
    return HttpResponseRedirect(url)
示例#8
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    # return HttpResponse(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.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 message is sent . Thank you For Message")
            return HttpResponseRedirect(url)
        else:
            messages.warning(request, "something is wrong")
    return HttpResponseRedirect(url)
示例#9
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.email = form.cleaned_data['email']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()
            messages.success(request, "Yorum Gönderildi")

            return HttpResponseRedirect(url)
    messages.warning(request, "Yorum Gönderilemedi !  ")
    return HttpResponseRedirect(url)
示例#10
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)
示例#11
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.name = form.cleaned_data['name']
            data.email = form.cleaned_data['email']
            data.subject = form.cleaned_data['subject']
            data.comment = form.cleaned_data['comment']
            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, "پیام شما با موفقیت ارسال شد.")
            return HttpResponseRedirect(url)

    return HttpResponseRedirect(url)
示例#12
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)
示例#13
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)
示例#14
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)
示例#15
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)
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)
示例#17
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.ip = request.META.get('REMOTE_ADDR')
            data.save()
            messages.success(
                request,
                "Yorumunuz alınmıştır. Görüşleriniz için teşekkkür ederiz")
            return HttpResponseRedirect(url)

    messages.warning(request,
                     "Yorumunuz kaydedilmedi. Lütfen tekrar deneyiniz.")
    return HttpResponseRedirect(url)
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)
示例#19
0
文件: views.py 项目: yagizoral/Ozel-2
def addcomment(request,id):
     url = request.META.get('HTTP_REFERER')
     if request.method == 'POST': #POST EDİLDİYSE
         form = CommentForm(request.POST)
         if form.is_valid():
             current_user=request.user#access user session information

             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()#veritabanına kaydet

             messages.success(request, "yorum gönderildi saolun")


             return HttpResponseRedirect(url)

     messages.warning(request, "yorum gönderilemedi lan bişey bozuk")
     return HttpResponseRedirect(url)
示例#20
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)
示例#21
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)
示例#22
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)
示例#23
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)
示例#24
0
def addcomment(request, id):
    url = request.META.get('HTTP_REFERER')
    if request.method == 'POST':  #form post edildiyse demek
        form = CommentForm(request.POST)
        if form.is_valid():
            current_user = request.user
            data = Comment()  #model ile bağlantı kuruyor
            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.changed_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 Kaydedilmedi. Lütfen Kontrol Ediniz!")
        # return HttpResponse("Kaydedilme İşlemi Gerçekleşmedi")
        return HttpResponseRedirect(url)