def ajax_post_form_create(request, instance_id, reviewer_id): comment = request.POST[u'comment'] score = request.POST[u'score'] submission = Instance.objects.get(id=instance_id) reviewer = User.objects.get(id=reviewer_id) qr = QualityReview(comment=comment, \ score=score, \ submission=submission, \ reviewer=reviewer) qr.save() return HttpResponseRedirect("/xforms/quality_reviews/")
def ajax_review_post(request, submission_id, reviewer_id): submission = Instance.objects.get(id=submission_id) reviewer = User.objects.get(id=reviewer_id) try: qr = QualityReview.objects.get(submission=submission, \ reviewer=reviewer) qr.score = request.POST[u'score'] qr.comment = request.POST[u'comment'] except: qr = QualityReview(submission=submission, \ reviewer=reviewer, score=request.POST[u'score'], \ comment=request.POST[u'comment']) try: qr.save() errors = False except ValueError, e: errors = "Error: %s" % e.message