Exemplo n.º 1
0
def add_review(request, pk):
    store = get_object_or_404(LiquorLocation, pk=pk)
    ratings = LiquorLocation.getRatings(store)
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        price = form.cleaned_data['price']
        comment = form.cleaned_data['comment']
        user_name = request.user.username
        review = Review()
        review.store = store
        review.user_name = user_name
        review.rating = rating
        review.price = price
        review.comment = comment
        review.pub_date = datetime.now()
        review.save()
        #store.avg_rating = store.get_average_rating()
        #store.save()
        return redirect('map:store', pk)
    return render(request, 'StoreProfile/index.html', {
        'store': store,
        'ratings': ratings,
        'form': form
    })
Exemplo n.º 2
0
def store_profile(request, pk):
    store = get_object_or_404(LiquorLocation, pk=pk)
    # most_recent = LiquorLocation.review_set.order_by('pub_date')

    locations = serializers.serialize(
        "json", LiquorLocation.objects.exclude(city__isnull=True))
    latitude = store.latitude
    longitude = store.longitude
    address = store.address
    average_rating = LiquorLocation.get_average_rating(store)

    if request.user.is_authenticated():
        return render(
            request, 'StoreProfile/authenticated_user.html', {
                'store': store,
                'average_rating': average_rating,
                'locations': locations,
                'user': request.user,
                'form': ReviewForm()
            })
    else:
        return render(
            request, 'StoreProfile/anonymous_user.html', {
                'store': store,
                'average_rating': average_rating,
                'locations': locations,
                'form': ReviewForm()
            })
Exemplo n.º 3
0
def store_profile(request, pk):
    store = get_object_or_404(LiquorLocation, pk=pk)
    # most_recent = LiquorLocation.review_set.order_by('pub_date')

    locations = serializers.serialize("json", LiquorLocation.objects.exclude(city__isnull=True))
    latitude = store.latitude;
    longitude = store.longitude;
    address = store.address;
    average_rating = LiquorLocation.get_average_rating(store);

    if request.user.is_authenticated():
        return render(request,'StoreProfile/authenticated_user.html',{'store':store, 'average_rating': average_rating, 'locations': locations, 'user': request.user, 'form':ReviewForm()})
    else:
        return render(request,'StoreProfile/anonymous_user.html',{'store':store, 'average_rating': average_rating, 'locations': locations, 'form':ReviewForm()})
Exemplo n.º 4
0
def add_review(request, pk):
    store = get_object_or_404(LiquorLocation, pk=pk)
    ratings = LiquorLocation.getRatings(store);
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        price = form.cleaned_data['price']
        comment = form.cleaned_data['comment']
        user_name = request.user.username
        review = Review()
        review.store = store
        review.user_name = user_name
        review.rating = rating
        review.price = price
        review.comment = comment
        review.pub_date = datetime.now()
        review.save()
        #store.avg_rating = store.get_average_rating()
        #store.save()
        return redirect('map:store',pk)
    return render(request, 'StoreProfile/index.html', {'store': store, 'ratings':ratings, 'form': form})