Added comments for ranks and reviews.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Mon, 10 Aug 2009 01:38:02 +0530
changeset 27 37612f295cd4
parent 26 97bd3c28c957
child 28 be65e84e7d03
Added comments for ranks and reviews.
app/projrev/views/helpers/templatetags/review_helpers.py
app/projrev/views/proposal.py
app/templates/projrev/proposal/rank.html
app/templates/projrev/proposal/review.html
app/templates/projrev/templatetags/_as_review.html
--- a/app/projrev/views/helpers/templatetags/review_helpers.py	Mon Aug 10 01:00:32 2009 +0530
+++ b/app/projrev/views/helpers/templatetags/review_helpers.py	Mon Aug 10 01:38:02 2009 +0530
@@ -11,9 +11,13 @@
 register = template.Library()
 
 
-@register.inclusion_tag('projrev/templatetags/_as_comment.html')
-def as_comment(review):
+@register.inclusion_tag('projrev/templatetags/_as_review.html')
+def as_review(review):
   """Returns the comment contexts for the template tag.
   """
 
-  return {'comment_entity': review}
+  total_score = (review.attribute1 + review.attribute2 + review.attribute3 + 
+                 review.attribute4 + review.attribute5 + review.attribute6 +
+                 review.attribute7 + review.attribute8 + review.attribute9)
+
+  return {'review': review, 'total_score': total_score}
--- 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
 
--- a/app/templates/projrev/proposal/rank.html	Mon Aug 10 01:00:32 2009 +0530
+++ b/app/templates/projrev/proposal/rank.html	Mon Aug 10 01:38:02 2009 +0530
@@ -1,4 +1,6 @@
 {% extends "projrev/base.html" %}
+{% load review_helpers %}
+
 {% block content %}
 <div class="post">
 			
@@ -155,6 +157,15 @@
       (<i>New Submission</i>)
     {% endif %} 
     </span> 
-  </p>				
+  </p>
+  {% if reviews %}
+  <br /><br />
+  <p>
+  <h2>Reviews: Comments and Scores:</h2>
+  {% for review in reviews %}
+    {% as_review review %}
+  {% endfor %}
+  </p>
+  {% endif %}
 </div>
 {% endblock content %}
\ No newline at end of file
--- a/app/templates/projrev/proposal/review.html	Mon Aug 10 01:00:32 2009 +0530
+++ b/app/templates/projrev/proposal/review.html	Mon Aug 10 01:38:02 2009 +0530
@@ -1,4 +1,6 @@
 {% extends "projrev/base.html" %}
+{% load review_helpers %}
+
 {% block content %}
 <div class="post">
 			
@@ -82,9 +84,13 @@
     </span> 
   </p>
   {% if reviews %}
+  <br /><br />
+  <p>
+  <h2>Reviews: Comments and Scores:</h2>
 	{% for review in reviews %}
 	  {% as_review review %}
 	{% endfor %}
+	</p>
 	{% endif %}
 </div>
 {% endblock content %}
\ No newline at end of file
--- a/app/templates/projrev/templatetags/_as_review.html	Mon Aug 10 01:00:32 2009 +0530
+++ b/app/templates/projrev/templatetags/_as_review.html	Mon Aug 10 01:38:02 2009 +0530
@@ -1,31 +1,17 @@
-<div class="ghoptaskcomment">
- <div class="title" id="c{{ comment_id }}">
-  On {{ comment.created_on|date:"jS F Y H:i" }},
-  by
-  {% if comment.created_by %} 
-    {{ comment.created_by.name }}:
-  {% else %}
-    {{ site_name }} Automatic Updater:
-  {% endif %}
-  <span class="spc{{ comment_id }}">
-   <a title="Permalink to this Comment" href="#c{{ comment_id }}">ΒΆ</a>
-  </span>
- </div>
- <div class="box-inner">
-  <p>
-   {% if comment.content %}
-     {{ comment.content|safe }}</p>
-   {% else %}
-   (No Comment was entered for this change.)
-   {% endif %}
- </div>
- {% if comment.changes %}
-  <div class="changes">
-   <div class="box-inner">
-    <b>Changes:</b>
-    {{ comment.changes|join:"; " }} 
-   </div>
-  </div>
- {% endif %}
-</div>
-<hr />
\ No newline at end of file
+<p class="post-footer align-right">
+  Comment by: <strong>{{ review.reviewer}}</strong>,
+On <strong>{{ review.reviewed_on|date:"jS F Y h:iA" }}</strong>
+  Total Score: <strong>{{ total_score }}</strong><br />
+  Attribute 1: <strong>{{ review.attribute1 }},</strong> 
+  Attribute 2: <strong>{{ review.attribute2 }},</strong>
+  Attribute 3: <strong>{{ review.attribute3 }},</strong>
+  Attribute 4: <strong>{{ review.attribute4 }},</strong>
+  Attribute 5: <strong>{{ review.attribute5 }},</strong>
+  Attribute 6: <strong>{{ review.attribute6 }},</strong>
+  Attribute 7: <strong>{{ review.attribute7 }},</strong>
+  Attribute 8: <strong>{{ review.attribute8 }},</strong>
+  Attribute 9: <strong>{{ review.attribute9 }}</strong>
+</p>
+<div class="review-center-box">
+  {{ review.comment }}
+</div>
\ No newline at end of file