app/soc/views/models/student_proposal.py
changeset 2185 09ca8e661728
parent 2179 efc3a50a81ef
child 2191 d20557e217dc
equal deleted inserted replaced
2184:a1bda9afa5d0 2185:09ca8e661728
   895       context['possible_mentors'] = "None"
   895       context['possible_mentors'] = "None"
   896     else:
   896     else:
   897       mentor_names = []
   897       mentor_names = []
   898 
   898 
   899       for mentor_key in possible_mentors:
   899       for mentor_key in possible_mentors:
   900         possible_mentor = mentor_logic.logic.getFromKeyName(mentor_key.id_or_name())
   900         possible_mentor = mentor_logic.logic.getFromKeyName(
       
   901             mentor_key.id_or_name())
   901         mentor_names.append(possible_mentor.name())
   902         mentor_names.append(possible_mentor.name())
   902 
   903 
   903       context['possible_mentors'] = ', '.join(mentor_names)
   904       context['possible_mentors'] = ', '.join(mentor_names)
   904 
   905 
   905     # order the reviews by ascending creation date
   906     # order the reviews by ascending creation date
   918     context['private_reviews'] = private_reviews
   919     context['private_reviews'] = private_reviews
   919 
   920 
   920     # create a summary of all the private reviews
   921     # create a summary of all the private reviews
   921     review_summary = {}
   922     review_summary = {}
   922 
   923 
   923     for review in private_reviews:
   924     for private_review in private_reviews:
   924       # make sure there is a reviewer
   925       # make sure there is a reviewer
   925       reviewer = review.reviewer
   926       reviewer = private_review.reviewer
   926       if not reviewer:
   927       if not reviewer:
   927         continue
   928         continue
   928 
   929 
   929       reviewer_key = reviewer.key()
   930       reviewer_key = reviewer.key()
   930       reviewer_summary = review_summary.get(reviewer_key)
   931       reviewer_summary = review_summary.get(reviewer_key)
   931 
   932 
   932       if reviewer_summary:
   933       if reviewer_summary:
   933         # we already have something on file for this reviewer
   934         # we already have something on file for this reviewer
   934         old_total_score = reviewer_summary['total_score']
   935         old_total_score = reviewer_summary['total_score']
   935         reviewer_summary['total_score'] = old_total_score + review.score
   936         reviewer_summary['total_score'] = old_total_score + private_review.score
   936 
   937 
   937         old_total_comments = reviewer_summary['total_comments']
   938         old_total_comments = reviewer_summary['total_comments']
   938         reviewer_summary['total_comments'] = old_total_comments + 1
   939         reviewer_summary['total_comments'] = old_total_comments + 1
   939       else:
   940       else:
   940         review_summary[reviewer_key] = {
   941         review_summary[reviewer_key] = {
   941             'name': reviewer.name(),
   942             'name': reviewer.name(),
   942             'total_comments': 1,
   943             'total_comments': 1,
   943             'total_score': review.score}
   944             'total_score': private_review.score}
   944 
   945 
   945     context['review_summary'] = review_summary
   946     context['review_summary'] = review_summary
   946 
   947 
   947     # which button should we show to the mentor?
   948     # which button should we show to the mentor?
   948     if mentor:
   949     if mentor: