Exemplo n.º 1
0
def review(request, title, app, model):
    if request.method == 'POST':
        model_object = get_model(app, model)
        review_item = get_object_or_404(model_object, url=title)
        api.review(
            user_id=request.session['_auth_user_id'],
            item_id=review_item.pk,
            text=request.POST['text'],
            rating=int(request.POST['rating'])
        )
    
    return redirect(request.META.get('HTTP_REFERER', None))
Exemplo n.º 2
0
def disagree(request, review_id):
    if request.method == 'POST' and request.is_ajax():
        error = api.review(
            user_id=request.session['_auth_user_id'],
            item_id=get_object_or_404(Review, pk=review_id).item_id,
            text=request.POST['text'],
            rating=int(request.POST['rating'])
        )

        if not error:
            return HttpResponse(status=201)
        else:
            return HttpResponse(content=error, status=202)
    return HttpResponse(status=403)