Exemplo n.º 1
0
def add_review(request, wine_id):
    wine = get_object_or_404(Wine, pk=wine_id)
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        comment = form.cleaned_data['comment']
        user_name = request.user.username
        review = Review()
        review.wine = wine
        review.user_name = user_name
        review.rating = rating
        review.comment = comment
        review.pub_date = datetime.datetime.now()
        review.save()
        update_clusters()
        # Always return an HttpResponseRedirect after successfully dealing
        # with POST data. This prevents data from being posted twice if a
        # user hits the Back button.
        return HttpResponseRedirect(
            reverse('reviews:wine_detail', args=(wine.id, )))

    return render(request, 'reviews/wine_detail.html', {
        'wine': wine,
        'form': form
    })
Exemplo n.º 2
0
def save_review_from_row(review_row):
    review = Review()
    review.user_name = review_row[0]
    review.comment = review_row[1]
    review.rating = review_row[2]
    review.movie_id = review_row[3]
    review.save()
Exemplo n.º 3
0
def save_review_from_row(sword_row):
    if sword_row.note != 'missing':
        review = Review()
        review.comment = sword_row.note
        review.author_id = randint(1, 4)
        review.sword_id = sword_row.name
        review.rating = randint(1, 5)
        review.save()
Exemplo n.º 4
0
def save_review_from_row(review_row):
    review = Review()
    review.id = review_row[0]
    review.user_name = review_row[1]
    review.repo = Repo.objects.get(id=review_row[2])
    review.rating = review_row[3]
    review.pub_date = datetime.datetime.now()
    review.comment = review_row[4]
    review.save()
def save_review_from_row(review_row):
    review = Review()
    review.id = review_row[0]
    review.user_name = review_row[1]
    review.wine = Wine.objects.get(id=review_row[2])
    review.rating = review_row[3]
    review.pub_date = datetime.datetime.now()
    review.comment = review_row[4]
    review.save()
def save_review_from_row(review_row):
	review = Review()
	review.id = review_row[0]
	review.user_name = review_row[1]
	# This can be an error if you gave not imported the wines yet
	review.wine = Wine.objects.get(id=review_row[2])
	review.rating = review_row[3]
	review.pub_date = datetime.datetime.now()
	review.comment = review_row[4]
	review.save()
Exemplo n.º 7
0
def save_review_from_row(review_row):
    review=Review()
    review.id=review_row[0]
    review.user_name=review_row[1]
    # we use the wine id to look for the wine instance
    # this means that we need to load wines before we load reviews
    review.wine=Wine.objects.get(id=review_row[2])
    review.rating=review_row[3]
    review.pub_date=datetime.datetime.now()
    review.comment=review_row[4]
    review.save()
Exemplo n.º 8
0
def save_review_from_row(review_row):
    review = Review()
#    review.id = review_row[0]
    review.user_name = review_row[0]
#    review.wine = Wine.objects.get(id=review_row[2])
#    print(review.wine)
    review.wine = review_row[1]
    review.rating = review_row[3]
    review.pub_date = datetime.datetime.now()
    review.comment = review_row[2]
    review.save()
Exemplo n.º 9
0
def save_review_from_row(review_row):
    review = Review()
    try:
        review.id = Review.objects.last().pk + 1  #review_row[0]
    except:  #TypeError:
        review.id = 1

    user = User.objects.get(username='' + str(int(review_row[1])))
    review.user_name = user
    #review.user_name = User.objects.get(id=review_row[1])
    review.movie = Movie.objects.get(id=review_row[2])
    review.rating = review_row[3]
    review.comment = review_row[4]
    review.pub_date = datetime.datetime.now()
    # review.pub_date = review_row[5].strip() if review_row[5].strip() else datetime.datetime.now()
    print 'saving ' + review.id
    review.save()
Exemplo n.º 10
0
def add_review(request, game_id):
    game = get_object_or_404(Game, pk=game_id)
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        comment = form.cleaned_data['comment']
        user_name = request.user.username
        review = Review()
        review.game = game
        review.user_name = user_name
        review.rating = rating
        review.comment = comment
        review.pub_date = datetime.datetime.now()
        review.save()
        """Always return an HttpResponseRedirect after successfully dealing
        with POST data. This prevents data from being posted twice if a
        user hits the Back button."""
        return HttpResponseRedirect(reverse('game_detail', args=(game.id,)))

    return render(request, 'game_detail.html', {'game': game, 'form': form})
Exemplo n.º 11
0
def add_review(request, game_id):
    game = get_object_or_404(Game, pk=game_id)
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        comment = form.cleaned_data['comment']
        user_name = request.user.username
        review = Review()
        review.game = game
        review.user_name = user_name
        review.rating = rating
        review.comment = comment
        review.pub_date = datetime.datetime.now()
        review.save()
        """Always return an HttpResponseRedirect after successfully dealing
        with POST data. This prevents data from being posted twice if a
        user hits the Back button."""
        return HttpResponseRedirect(reverse('game_detail', args=(game.id, )))

    return render(request, 'game_detail.html', {'game': game, 'form': form})
Exemplo n.º 12
0
def add_review(request, company_id):
    company = get_object_or_404(Company, pk=company_id)
    form = ReviewForm(request.POST)
    if form.is_valid():
        rating = form.cleaned_data['rating']
        comment = form.cleaned_data['comment']
        user_name = form.cleaned_data['user_name']
        review = Review()
        review.company = company
        review.user_name = user_name
        review.rating = rating
        review.comment = comment
        review.pub_date = datetime.datetime.now()
        review.save()
        # Always return an HttpResponseRedirect after successfully dealing
        # with POST data. This prevents data from being posted twice if a
        # user hits the Back button.
        return HttpResponseRedirect(reverse('reviews:company_detail', args=(company.id,)))

    return render(request, 'reviews/company_detail.html', {'company': company, 'form': form})
def save_review_from_row(review_row):
    review = Review()

    # id, username, wine_id, rating, published_date, comment

    review.id = int(review_row[0]) + 1

    review.user_name = review_row[5]

    review.wine = Wine.objects.get(id=review_row[2])

    review.rating = review_row[3]

    review.pub_date = datetime.datetime.now()

    review.comment = datetime.datetime.fromtimestamp(int(
        review_row[4])).strftime('%Y-%m-%d %H:%M:%S')

    print(review.id, review.user_name, review.wine, review.rating,
          review.pub_date, review.comment)

    review.save()