# HG changeset patch # User Madhusudan.C.S # Date 1249848482 -19800 # Node ID 37612f295cd4bf82a1a203836052da8703b1c80f # Parent 97bd3c28c9579a14fecdcd960372394640da8439 Added comments for ranks and reviews. diff -r 97bd3c28c957 -r 37612f295cd4 app/projrev/views/helpers/templatetags/review_helpers.py --- 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} diff -r 97bd3c28c957 -r 37612f295cd4 app/projrev/views/proposal.py --- 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 diff -r 97bd3c28c957 -r 37612f295cd4 app/templates/projrev/proposal/rank.html --- 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 %}
@@ -155,6 +157,15 @@ (New Submission) {% endif %} -

+

+ {% if reviews %} +

+

+

Reviews: Comments and Scores:

+ {% for review in reviews %} + {% as_review review %} + {% endfor %} +

+ {% endif %}
{% endblock content %} \ No newline at end of file diff -r 97bd3c28c957 -r 37612f295cd4 app/templates/projrev/proposal/review.html --- 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 %}
@@ -82,9 +84,13 @@

{% if reviews %} +

+

+

Reviews: Comments and Scores:

{% for review in reviews %} {% as_review review %} {% endfor %} +

{% endif %}
{% endblock content %} \ No newline at end of file diff -r 97bd3c28c957 -r 37612f295cd4 app/templates/projrev/templatetags/_as_review.html --- 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 @@ -
-
- 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 %} - - ΒΆ - -
-
-

- {% if comment.content %} - {{ comment.content|safe }}

- {% else %} - (No Comment was entered for this change.) - {% endif %} -
- {% if comment.changes %} -
-
- Changes: - {{ comment.changes|join:"; " }} -
-
- {% endif %} -
-
\ No newline at end of file +

+ Comment by: {{ review.reviewer}}, +On {{ review.reviewed_on|date:"jS F Y h:iA" }} + Total Score: {{ total_score }}
+ Attribute 1: {{ review.attribute1 }}, + Attribute 2: {{ review.attribute2 }}, + Attribute 3: {{ review.attribute3 }}, + Attribute 4: {{ review.attribute4 }}, + Attribute 5: {{ review.attribute5 }}, + Attribute 6: {{ review.attribute6 }}, + Attribute 7: {{ review.attribute7 }}, + Attribute 8: {{ review.attribute8 }}, + Attribute 9: {{ review.attribute9 }} +

+
+ {{ review.comment }} +
\ No newline at end of file