def review(request, pk):
    restaurant = get_object_or_404(Restaurant, pk=pk)
    new_review = RestaurantReview(
        rating=request.POST['rating'],
        comment=request.POST['comment'],
        user=request.user,
        restaurant=restaurant)
    new_review.save()
    return HttpResponseRedirect(urlresolvers.reverse('myrestaurants:restaurant_detail', args=(restaurant.id,)))
Beispiel #2
0
def review(request, pk):
  restaurant = get_object_or_404(Restaurant, pk=pk)
  review = RestaurantReview(
      rating=request.POST['rating'],
      comment=request.POST['comment'],
      user=request.user,
      restaurant=restaurant)
  review.save()
  return HttpResponseRedirect(reverse('myrestaurants:restaurant_detail', args=(restaurant.id,)))
Beispiel #3
0
def review(request, pk):
    restaurant = get_object_or_404(Restaurant, pk=pk)
    if RestaurantReview.objects.filter(restaurant=restaurant,
                                       user=request.user).exists():
        RestaurantReview.objects.get(restaurant=restaurant,
                                     user=request.user).delete()
    new_review = RestaurantReview(rating=request.POST['rating'],
                                  comment=request.POST['comment'],
                                  user=request.user,
                                  restaurant=restaurant)
    new_review.save()
    return HttpResponseRedirect(
        reverse('myrestaurants:restaurant_detail', args=(restaurant.id, )))