898 possible_mentor = mentor_logic.logic.getFromKeyName(mentor_key.id_or_name()) |
898 possible_mentor = mentor_logic.logic.getFromKeyName(mentor_key.id_or_name()) |
899 mentor_names.append(possible_mentor.id_or_name()) |
899 mentor_names.append(possible_mentor.id_or_name()) |
900 |
900 |
901 context['possible_mentors'] = ', '.join(mentor_names) |
901 context['possible_mentors'] = ', '.join(mentor_names) |
902 |
902 |
903 # TODO(ljvderijk) listing of total given scores per mentor |
|
904 # a dict with key as role.user ? |
|
905 |
|
906 # order the reviews by ascending creation date |
903 # order the reviews by ascending creation date |
907 order = ['created'] |
904 order = ['created'] |
908 |
905 |
909 # get the public reviews |
906 # get the public reviews |
910 context['public_reviews'] = review_logic.getReviewsForEntity(entity, |
907 public_reviews = review_logic.getReviewsForEntity(entity, |
911 is_public=True, order=order) |
908 is_public=True, order=order) |
912 |
909 |
913 # get the private reviews |
910 # get the private reviews |
914 context['private_reviews'] = review_logic.getReviewsForEntity(entity, |
911 private_reviews = review_logic.getReviewsForEntity(entity, |
915 is_public=False, order=order) |
912 is_public=False, order=order) |
|
913 |
|
914 # store the reviews in the context |
|
915 context['public_reviews'] = public_reviews |
|
916 context['private_reviews'] = private_reviews |
|
917 |
|
918 review_summary = {} |
|
919 |
|
920 for review in private_reviews: |
|
921 |
|
922 reviewer = review.reviewer |
|
923 if not reviewer: |
|
924 continue |
|
925 |
|
926 reviewer_key = reviewer.key() |
|
927 reviewer_summary = review_summary.get(reviewer_key) |
|
928 |
|
929 if reviewer_summary: |
|
930 # we already have something on file for this reviewer |
|
931 old_total_score = reviewer_summary['total_score'] |
|
932 reviewer_summary['total_score'] = old_total_score + review.score |
|
933 |
|
934 old_total_comments = reviewer_summary['total_comments'] |
|
935 reviewer_summary['total_comments'] = old_total_comments + 1 |
|
936 else: |
|
937 review_summary[reviewer_key] = { |
|
938 'name': reviewer.name(), |
|
939 'total_comments': 1, |
|
940 'total_score': review.score} |
|
941 |
|
942 context['review_summary'] = review_summary |
916 |
943 |
917 # which button should we show to the mentor? |
944 # which button should we show to the mentor? |
918 if mentor: |
945 if mentor: |
919 context['is_mentor'] = True |
946 context['is_mentor'] = True |
920 if mentor.key() in possible_mentors: |
947 if mentor.key() in possible_mentors: |