# HG changeset patch # User Lennard de Rijk # Date 1239552540 0 # Node ID 27731db8ab1e59862d4cf0ed6311896a3de6f8e2 # Parent ac7bd3b467ff581855e4f1ee025c19fd05bc2bfa Added overview of private reviews to the Student Proposal review page. Addresses Issue 496. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r ac7bd3b467ff -r 27731db8ab1e app/soc/templates/soc/student_proposal/review.html --- a/app/soc/templates/soc/student_proposal/review.html Sun Apr 12 13:22:43 2009 +0000 +++ b/app/soc/templates/soc/student_proposal/review.html Sun Apr 12 16:09:00 2009 +0000 @@ -60,6 +60,12 @@


+Summary of Reviews: +{% for key, value in review_summary.items %} +
  • {{ value.name }} ({{ value.total_comments }} posts, {{ value.total_score }} points)
  • +{% endfor %} + +
    Score and Review diff -r ac7bd3b467ff -r 27731db8ab1e app/soc/views/models/student_proposal.py --- a/app/soc/views/models/student_proposal.py Sun Apr 12 13:22:43 2009 +0000 +++ b/app/soc/views/models/student_proposal.py Sun Apr 12 16:09:00 2009 +0000 @@ -900,20 +900,47 @@ context['possible_mentors'] = ', '.join(mentor_names) - # TODO(ljvderijk) listing of total given scores per mentor - # a dict with key as role.user ? - # order the reviews by ascending creation date order = ['created'] # get the public reviews - context['public_reviews'] = review_logic.getReviewsForEntity(entity, + public_reviews = review_logic.getReviewsForEntity(entity, is_public=True, order=order) # get the private reviews - context['private_reviews'] = review_logic.getReviewsForEntity(entity, + private_reviews = review_logic.getReviewsForEntity(entity, is_public=False, order=order) + # store the reviews in the context + context['public_reviews'] = public_reviews + context['private_reviews'] = private_reviews + + review_summary = {} + + for review in private_reviews: + + reviewer = review.reviewer + if not reviewer: + continue + + reviewer_key = reviewer.key() + reviewer_summary = review_summary.get(reviewer_key) + + if reviewer_summary: + # we already have something on file for this reviewer + old_total_score = reviewer_summary['total_score'] + reviewer_summary['total_score'] = old_total_score + review.score + + old_total_comments = reviewer_summary['total_comments'] + reviewer_summary['total_comments'] = old_total_comments + 1 + else: + review_summary[reviewer_key] = { + 'name': reviewer.name(), + 'total_comments': 1, + 'total_score': review.score} + + context['review_summary'] = review_summary + # which button should we show to the mentor? if mentor: context['is_mentor'] = True