예제 #1
0
 def test_send_bad_review(self):
     kind = ProposalKindFactory()
     proposal = ProposalFactory(kind=kind)
     review = ReviewFactory(proposal=proposal, user=self.user)
     data = {"score": 5}
     form = ReviewForm(instance=review, data=data)
     self.assertFalse(form.is_valid())
예제 #2
0
 def test_send_review_round(self):
     kind = ProposalKindFactory()
     proposal = ProposalFactory(kind=kind)
     review = ReviewFactory(proposal=proposal, user=self.user)
     data = {"score": 1.67}
     form = ReviewForm(instance=review, data=data)
     self.assertTrue(form.is_valid())
     review = form.save()
     self.assertNotAlmostEqual(review.score, data["score"])
예제 #3
0
 def post(self, request, pk):
     if request.user.is_superuser:
         review = get_object_or_404(Review, pk=pk)
     else:
         review = get_object_or_404(Review, pk=pk, user=request.user)
     form = ReviewForm(request.POST, instance=review)
     if form.is_valid():
         form.save()
         return redirect(
             reverse("reviewers:details", kwargs={"pk": review.pk}))
     data = {"review": review, "proposal": review.proposal, "form": form}
     return render(request, self.template_name, data)
예제 #4
0
 def get(self, request, pk):
     if request.user.is_superuser:
         review = get_object_or_404(Review, pk=pk)
     else:
         review = get_object_or_404(Review, pk=pk, user=request.user)
     form = ReviewForm(instance=review)
     data = {"review": review, "proposal": review.proposal, "form": form}
     return render(request, self.template_name, data)