app/projrev/views/proposal.py
changeset 27 37612f295cd4
parent 26 97bd3c28c957
child 30 94fe7fe7394d
--- a/app/projrev/views/proposal.py	Mon Aug 10 01:00:32 2009 +0530
+++ b/app/projrev/views/proposal.py	Mon Aug 10 01:38:02 2009 +0530
@@ -285,9 +285,10 @@
     context['proposal_name'] = proposal_name
     context['last_submitted'] = proposal.submitted_on
 
-  reviews = project.review_set.all().order_by('-reviewed_on')
+  reviews = project.review_set.all().order_by('reviewed_on')
   if reviews:
-    context['last_reviewed'] = reviews[0].reviewed_on
+    context['reviews'] = reviews
+    context['last_reviewed'] = reviews[len(reviews)-1].reviewed_on
     context['nr_reviews'] = len(reviews)
 
   template = 'projrev/proposal/review.html'
@@ -323,12 +324,15 @@
     context['proposal_name'] = proposal_name
     context['last_submitted'] = proposal.submitted_on
 
-  reviews = project.review_set.all().order_by('-reviewed_on')
+  # Get all the reviews and put them to context.
+  reviews = project.review_set.all().order_by('reviewed_on')
   nr_reviews = len(reviews)
   if reviews:
-    context['last_reviewed'] = reviews[0].reviewed_on
+    context['reviews'] = reviews
+    context['last_reviewed'] = reviews[len(reviews)-1].reviewed_on
     context['nr_reviews'] = nr_reviews
 
+  # Calculate the review scores
   review_score = [0] * 9
   for review in reviews:
     review_score[0] += review.attribute1
@@ -343,15 +347,16 @@
 
   total_score = sum(review_score)
 
+  # Get the Average for each attribute
   review_avg = [0] * 9
   for i, rs in enumerate(review_score):
     try:
-      review_avg[i] = float(rs) / nr_reviews
+      review_avg[i] = "%.2f" % (float(rs) / nr_reviews)
     except ZeroDivisionError:
       review_avg[i] = 0
 
   try:
-    total_avg = float(total_score) / nr_reviews
+    total_avg = "%.2f" % (float(total_score) / nr_reviews)
   except ZeroDivisionError:
     total_avg = 0