Beispiel #1
0
def set_review(request):

    obj = get_object(request.REQUEST.get("id", None))

    form = ReviewForm(request.REQUEST,
                      instance=obj,
                      user=request.user)

    if form.is_valid():
        form.save()
        return dict(status="success")
    else:
        return dict(errors=form._errors)
Beispiel #2
0
def set_review(request):

    obj = get_object(request.REQUEST.get("id", None))

    content_type = ContentType.objects.get_for_model(obj)

    review = get_object_or_None(Review,
        content_type=content_type,
        object_id=obj.id,
        user=request.user,
    ) or Review(
        content_type=content_type,
        object_id=obj.id,
        user=request.user,
    )

    form = ReviewForm(request.REQUEST,
                      instance=review)

    if form.is_valid():
        form.save()
        return dict(status="success")
    else:
        return dict(errors=form._errors)