diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index b2d7d546afa08547171073ec9fe9776727e3da79..914409308e03ac45870e04317dd1c5661eb7cd5c 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -414,9 +414,10 @@ class LeaderboardFilter(filters.FilterSet): class LeaderboardTable(tables.Table): - full_name = tables.LinkColumn('funds:submissions:leaderboard_detail', args=[A('pk')], orderable=True, verbose_name="Reviewer") + full_name = tables.LinkColumn('funds:submissions:leaderboard_detail', args=[A('pk')], orderable=True, verbose_name="Reviewer", attrs={'td': {'class': 'title'}}) class Meta: + model = User fields = [ 'full_name', 'total', @@ -424,18 +425,21 @@ class LeaderboardTable(tables.Table): 'this_year', 'last_year', ] - model = User order_by = ('-total',) + attrs = {'class': 'all-reviews-table'} + empty_text = _('No reviews available') class LeaderboardDetailTable(tables.Table): - title = tables.LinkColumn('funds:submissions:reviews:review', text=render_title, args=[A('submission_id'), A('pk')], orderable=True, verbose_name="Submission") + title = tables.LinkColumn('funds:submissions:reviews:review', text=render_title, args=[A('submission_id'), A('pk')], orderable=True, verbose_name="Submission", attrs={'td': {'data-title-tooltip': lambda record: record.submission.title, 'class': 'title js-title'}}) class Meta: + model = Review fields = [ 'title', 'recommendation', 'created_at', ] - model = Review order_by = ('-created_at',) + attrs = {'class': 'all-reviews-table'} + empty_text = _('No reviews available') diff --git a/hypha/apply/funds/templates/funds/review_leaderboard_detail.html b/hypha/apply/funds/templates/funds/review_leaderboard_detail.html index 6753028bab85db24c3e9826be08b61d9d2c7763e..2c063c3761eac442f2edef32997a488aecd12197 100644 --- a/hypha/apply/funds/templates/funds/review_leaderboard_detail.html +++ b/hypha/apply/funds/templates/funds/review_leaderboard_detail.html @@ -9,7 +9,7 @@ <div class="admin-bar__inner wrapper--search"> {% block page_header %} <div> - <h1 class="gamma heading heading--no-margin heading--bold">Reviewer Leaderboard</h1> + <h1 class="gamma heading heading--no-margin heading--bold">Reviews by {{ object }}</h1> <h5>Track and explore the reviews</h5> </div> {% endblock %} diff --git a/hypha/apply/funds/tests/test_views.py b/hypha/apply/funds/tests/test_views.py index 5590ad44df8be568c12782613ec9bdd41eb2b2a6..6c99325ede22f6a9604f50b70430a1eef14d1846 100644 --- a/hypha/apply/funds/tests/test_views.py +++ b/hypha/apply/funds/tests/test_views.py @@ -1218,7 +1218,7 @@ class TestUserReminderDeleteView(BaseProjectDeleteTestCase): self.assertEqual(response.status_code, 403) -@override_settings(ROOT_URLCONF='opentech.apply.urls') +@override_settings(ROOT_URLCONF='hypha.apply.urls') class TestReviewerLeaderboard(TestCase): def test_applicant_cannot_access_reviewer_leaderboard(self): self.client.force_login(ApplicantFactory()) diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 6e84a809cf33d19cbfb7afffd29565b1cd265b69..a23aa20c161d5f34675acabc333459dacbaae428 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -3,6 +3,7 @@ from datetime import timedelta from statistics import mean from django.contrib import messages +from django.contrib.auth import get_user_model from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.mixins import UserPassesTestMixin from django.contrib.humanize.templatetags.humanize import intcomma @@ -79,9 +80,9 @@ from .models import ( from .permissions import is_user_has_access_to_view_submission from .tables import ( AdminSubmissionsTable, + LeaderboardDetailTable, LeaderboardFilter, LeaderboardTable, - LeaderboardDetailTable, ReviewerSubmissionsTable, RoundsFilter, RoundsTable, @@ -1190,10 +1191,20 @@ class SubmissionResultView(FilterView): @method_decorator(login_required, name='dispatch') class ReviewLeaderboard(UserPassesTestMixin, SingleTableMixin, FilterView): filterset_class = LeaderboardFilter + filter_action = '' table_class = LeaderboardTable table_pagination = False template_name = 'funds/review_leaderboard.html' + def get_context_data(self, **kwargs): + search_term = self.request.GET.get('query') + + return super().get_context_data( + search_term=search_term, + filter_action=self.filter_action, + **kwargs, + ) + def get_table_data(self): ninety_days_ago = timezone.now() - timedelta(days=90) this_year = timezone.now().year @@ -1217,6 +1228,11 @@ class ReviewLeaderboardDetail(UserPassesTestMixin, SingleTableMixin, ListView): table_pagination = {'per_page': 25} template_name = 'funds/review_leaderboard_detail.html' + def get_context_data(self, **kwargs): + User = get_user_model() + obj = User.objects.get(pk=self.kwargs.get('pk')) + return super().get_context_data(object=obj, **kwargs) + def get_table_data(self): return super().get_table_data().filter(author__reviewer_id=self.kwargs.get('pk')).select_related('submission') diff --git a/hypha/static_src/src/sass/apply/abstracts/_mixins.scss b/hypha/static_src/src/sass/apply/abstracts/_mixins.scss index ec269cd16c687695bcba7835739154ed2a8aae54..d8069921a066642723a2af2e30148271525553a7 100644 --- a/hypha/static_src/src/sass/apply/abstracts/_mixins.scss +++ b/hypha/static_src/src/sass/apply/abstracts/_mixins.scss @@ -196,7 +196,7 @@ &::after { position: absolute; - top: 32px; + top: 50%; margin-left: 3px; } diff --git a/hypha/static_src/src/sass/apply/components/_all-reviews-table.scss b/hypha/static_src/src/sass/apply/components/_all-reviews-table.scss new file mode 100644 index 0000000000000000000000000000000000000000..bf46e5a2167580bd23847268f3a8ab110f508333 --- /dev/null +++ b/hypha/static_src/src/sass/apply/components/_all-reviews-table.scss @@ -0,0 +1,72 @@ +.all-reviews-table { + @include table-ordering-styles; + $root: &; + font-size: 14px; + + + thead { + display: none; + + @include media-query($table-breakpoint) { + display: table-header-group; + } + + tr { + &:hover { + box-shadow: none; + } + } + } + + tbody { + td { + &.title { + position: relative; + padding-top: 15px; + padding-left: 10px; + font-weight: $weight--bold; + + @include media-query($table-breakpoint) { + display: flex; + align-items: center; + } + + @include media-query(desktop) { + display: table-cell; + } + + &.has-tooltip { + @include media-query($table-breakpoint) { + &::before { + position: absolute; + top: 50px; + left: 45px; + z-index: -1; + width: 200px; + padding: 5px; + font-size: 12px; + font-weight: $weight--normal; + white-space: normal; + background: $color--sky-blue; + border: 1px solid $color--marine; + content: attr(data-title-tooltip); + opacity: 0; + transition: opacity $transition; + } + + &:hover { + &::before { + z-index: 10; + opacity: 1; + } + } + } + } + + a { + color: $color--primary; + } + } + } + } +} diff --git a/hypha/static_src/src/sass/apply/main.scss b/hypha/static_src/src/sass/apply/main.scss index 4c68827bf29f9e444a594f9417c9a10d71697735..2ac36be09675a5081891c818447450973a9d1d63 100644 --- a/hypha/static_src/src/sass/apply/main.scss +++ b/hypha/static_src/src/sass/apply/main.scss @@ -10,6 +10,7 @@ // Components @import 'components/alert'; @import 'components/all-submissions-table'; +@import 'components/all-reviews-table'; @import 'components/admin-bar'; @import 'components/actions-bar'; @import 'components/card';