diff --git a/hypha/apply/funds/templates/funds/includes/review_sidebar.html b/hypha/apply/funds/templates/funds/includes/review_sidebar.html index c07359379117dddcd77c97e79a13f4759b3dfbad..e584ba00c7af501e3429a954fc92a7f44d951584 100644 --- a/hypha/apply/funds/templates/funds/includes/review_sidebar.html +++ b/hypha/apply/funds/templates/funds/includes/review_sidebar.html @@ -1,12 +1,15 @@ {% load i18n review_tags %} -<ul class="reviews-sidebar" x-data='{showHiddenReviewers: false}'> - <li class="reviews-sidebar__item reviews-sidebar__item--header"> - <div></div> - <div>{{ recommendation|traffic_light }}</div> - <div></div> - </li> - +<div class="flex items-center justify-around px-2 py-1 bg-gray-100"> + <span> + {{ recommendation|traffic_light }} + </span> + <span class="font-medium"> + {% trans 'Avg. Score'%}: {{assigned_reviewers|average_review_score|floatformat:'1'}} + </span> +</div> + +<ul class="reviews-sidebar mt-4" x-data='{showHiddenReviewers: false}'> {% if not staff_reviewers_exist %} <li class="reviews-sidebar__no-reviews">{% trans "No staff reviewers yet" %}</li> <hr class="reviews-sidebar__split"> diff --git a/hypha/apply/review/templatetags/review_tags.py b/hypha/apply/review/templatetags/review_tags.py index b240d5ede275b4609e5b991c0fa9001ac7a4ebd8..7c0aac1b65d5dcb918b9bb747adb5b1a648b00cc 100644 --- a/hypha/apply/review/templatetags/review_tags.py +++ b/hypha/apply/review/templatetags/review_tags.py @@ -2,6 +2,7 @@ from django import template from django.utils.safestring import mark_safe from ..models import MAYBE, NO, YES +from ..options import NA register = template.Library() @@ -40,3 +41,19 @@ def can_review(user, submission): @register.filter def has_draft(user, submission): return submission.can_review(user) and submission.assigned.draft_reviewed().filter(reviewer=user).exists() + + +@register.filter +def average_review_score(reviewers): + if reviewers: + scores = [ + reviewer.review.score + for reviewer in reviewers + if not reviewer.has_review and not reviewer.review.is_draft and not reviewer.review.score == NA + ] + if len(scores) > 0: + return sum(scores) / len(scores) + else: + return 0 + else: + return reviewers diff --git a/hypha/static_src/src/sass/apply/components/_reviews-sidebar.scss b/hypha/static_src/src/sass/apply/components/_reviews-sidebar.scss index 44a5bb75382338416383ef941f4146b684d15174..d34b31ed64a15a6c6bd89632d52cd021b80d32ba 100644 --- a/hypha/static_src/src/sass/apply/components/_reviews-sidebar.scss +++ b/hypha/static_src/src/sass/apply/components/_reviews-sidebar.scss @@ -51,12 +51,6 @@ } } - &--header { - background-color: $color--light-grey; - padding: 10px; - align-items: center; - } - &.is-hidden { display: none; }