From b0901f0b3b05703d42d898a9f7baa5b5f4e1ab12 Mon Sep 17 00:00:00 2001 From: Ghulam Murtaza Date: Wed, 9 Nov 2022 10:08:45 -0500 Subject: [PATCH 1/2] Allow reviewers to see all submissions Issue #3966 --- .../dashboard/reviewer_dashboard.html | 14 ++++++++ hypha/apply/dashboard/views.py | 12 +++++++ hypha/apply/funds/views.py | 32 +++++++++++-------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html index 609bf94924..b6f1474e1d 100644 --- a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -77,6 +77,20 @@

{% render_table my_inactive_submissions %} {% endif %} + + {% if all_submissions.table.data %} +
+ +

{% trans "All Submissions" %}

+ {% render_table all_submissions.table %} + + {% if all_submissions.display_more %} + + {% endif %} +
+ {% endif %} {% endblock %} diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index 2edd5e9a24..da69c8060e 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.db.models import F from django.http import HttpResponseForbidden, HttpResponseRedirect from django.shortcuts import render from django.urls import reverse, reverse_lazy @@ -317,11 +318,22 @@ def get_context_data(self, **kwargs): "awaiting_reviews": self.awaiting_reviews(submissions), "my_reviewed": self.my_reviewed(submissions), "my_flagged": self.my_flagged(submissions), + "all_submissions": self.all_submissions(submissions), } ) return context + def all_submissions(self, submissions): + limit = 5 + submissions = submissions.order_by(F("last_update").desc(nulls_last=True)) + + return { + "table": ReviewerSubmissionsTable(submissions[:limit], prefix="my-review-"), + "display_more": submissions.count() > limit, + "url": reverse("funds:submissions:list"), + } + def awaiting_reviews(self, submissions): submissions = submissions.in_review_for(self.request.user).order_by( "-submit_time" diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 429e7cfe7a..dcd7aa7021 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -124,7 +124,6 @@ StaffAssignmentsTable, StaffFlaggedSubmissionsTable, SubmissionFilterAndSearch, - SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, UserFlaggedSubmissionsTable, ) @@ -401,23 +400,28 @@ def form_valid(self, form): class BaseReviewerSubmissionsTable(BaseAdminSubmissionsTable): table_class = ReviewerSubmissionsTable - filterset_class = SubmissionReviewerFilterAndSearch + filterset_class = SubmissionFilterAndSearch def get_queryset(self): - """ - If use_settings variable is set for ReviewerSettings use settings - parameters to filter submissions or return only reviewed_by as it - was by default. - """ - reviewer_settings = ReviewerSettings.for_request(self.request) - if reviewer_settings.use_settings: + if self.request.GET.get("reviewers"): + """ + If use_settings variable is set for ReviewerSettings use settings + parameters to filter submissions or return only reviewed_by as it + was by default. + """ + reviewer_settings = ReviewerSettings.for_request(self.request) + if reviewer_settings.use_settings: + return ( + super() + .get_queryset() + .for_reviewer_settings(self.request.user, reviewer_settings) + .order_by("-submit_time") + ) + return super().get_queryset().reviewed_by(self.request.user) + else: return ( - super() - .get_queryset() - .for_reviewer_settings(self.request.user, reviewer_settings) - .order_by("-submit_time") + super().get_queryset().order_by(F("last_update").desc(nulls_last=True)) ) - return super().get_queryset().reviewed_by(self.request.user) @method_decorator(login_required, name="dispatch") From 9236006bd234f0fcf6c150ca176b952224be829e Mon Sep 17 00:00:00 2001 From: Ghulam Murtaza Date: Wed, 9 Nov 2022 12:04:06 -0500 Subject: [PATCH 2/2] Added a new view for my reviewed submissions Issue #3966 --- .../dashboard/reviewer_dashboard.html | 2 +- hypha/apply/dashboard/views.py | 2 +- .../funds/templates/funds/submissions.html | 7 +++- hypha/apply/funds/urls.py | 4 +++ hypha/apply/funds/views.py | 34 ++++++++----------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html index b6f1474e1d..6c0654e5be 100644 --- a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -35,7 +35,7 @@ {% if my_reviewed.display_more %} {% endif %} diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index da69c8060e..c9ac4236f9 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -366,7 +366,7 @@ def my_reviewed(self, submissions): ), "table": ReviewerSubmissionsTable(submissions[:limit], prefix="my-review-"), "display_more": submissions.count() > limit, - "url": reverse("funds:submissions:list"), + "url": reverse("funds:submissions:my_reviewed"), } diff --git a/hypha/apply/funds/templates/funds/submissions.html b/hypha/apply/funds/templates/funds/submissions.html index 8c7dc6bfe7..95d31afad2 100644 --- a/hypha/apply/funds/templates/funds/submissions.html +++ b/hypha/apply/funds/templates/funds/submissions.html @@ -8,7 +8,12 @@ {% adminbar %} {% slot header %} - {% trans "All Submissions" %} ({{ table.rows|length }}) + {% if page_heading %} + {{ page_heading }} + {% else %} + {% trans "All Submissions" %} + {% endif %} + ({{ table.rows|length }}) {% endslot %} {% slot sub_heading %}{% trans "Search and filter all submissions" %}{% endslot %} diff --git a/hypha/apply/funds/urls.py b/hypha/apply/funds/urls.py index da8e5bd0a2..0445a54fbd 100644 --- a/hypha/apply/funds/urls.py +++ b/hypha/apply/funds/urls.py @@ -8,6 +8,7 @@ AwaitingReviewSubmissionsListView, ExportSubmissionsByRound, GroupingApplicationsListView, + MyReviewedSubmissionListView, ReminderDeleteView, ReviewerLeaderboard, ReviewerLeaderboardDetail, @@ -167,6 +168,9 @@ AwaitingReviewSubmissionsListView.as_view(), name="awaiting_review", ), + path( + "my_reviewed/", MyReviewedSubmissionListView.as_view(), name="my_reviewed" + ), path( "assignments/", include( diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index dcd7aa7021..d81c9a9187 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -124,6 +124,7 @@ StaffAssignmentsTable, StaffFlaggedSubmissionsTable, SubmissionFilterAndSearch, + SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, UserFlaggedSubmissionsTable, ) @@ -400,28 +401,21 @@ def form_valid(self, form): class BaseReviewerSubmissionsTable(BaseAdminSubmissionsTable): table_class = ReviewerSubmissionsTable - filterset_class = SubmissionFilterAndSearch + filterset_class = SubmissionReviewerFilterAndSearch def get_queryset(self): - if self.request.GET.get("reviewers"): - """ - If use_settings variable is set for ReviewerSettings use settings - parameters to filter submissions or return only reviewed_by as it - was by default. - """ - reviewer_settings = ReviewerSettings.for_request(self.request) - if reviewer_settings.use_settings: - return ( - super() - .get_queryset() - .for_reviewer_settings(self.request.user, reviewer_settings) - .order_by("-submit_time") - ) - return super().get_queryset().reviewed_by(self.request.user) - else: + reviewer_settings = ReviewerSettings.for_request(self.request) + if reviewer_settings.use_settings: return ( - super().get_queryset().order_by(F("last_update").desc(nulls_last=True)) + super() + .get_queryset() + .for_reviewer_settings(self.request.user, reviewer_settings) + .order_by("-submit_time") ) + return super().get_queryset().reviewed_by(self.request.user) + + def get_context_data(self, **kwargs): + return super().get_context_data(page_heading="My Reviewed", **kwargs) @method_decorator(login_required, name="dispatch") @@ -585,13 +579,13 @@ class GroupingApplicationsListView(TemplateView): template_name = "funds/grouped_application_list.html" -class SubmissionReviewerListView(BaseReviewerSubmissionsTable): +class MyReviewedSubmissionListView(BaseReviewerSubmissionsTable): template_name = "funds/submissions.html" class SubmissionListView(ViewDispatcher): admin_view = SubmissionAdminListView - reviewer_view = SubmissionReviewerListView + reviewer_view = SubmissionAdminListView @method_decorator(staff_required, name="dispatch")