diff --git a/docs/user-guides/applications/submission-search.md b/docs/user-guides/applications/submission-search.md index a659af8e8673b4a1facac6281613ecc1f4bb7688..91d3d943b01e8e9e0cef26dacf0f74420f89a283 100644 --- a/docs/user-guides/applications/submission-search.md +++ b/docs/user-guides/applications/submission-search.md @@ -8,6 +8,7 @@ You can use advanced filters to search for application submissions that meet spe - Filter when applications were submitted: `submitted:2023-09-01`, `submitted:>2023-01`, `submitted:<=2023` - Filter when applications was last updated: `updated:2023-09-01`, `updated:>2023-01`, `updated:<=2023` - Filter your flagged submissions: `flagged:@me` +- Filter staff flagged submissions: `flagged:@staff` ## Sharing Filters diff --git a/hypha/apply/dashboard/templates/dashboard/includes/flagged.html b/hypha/apply/dashboard/templates/dashboard/includes/flagged.html index 0badca3a3a724d9c1c504520033f0d3dae239f42..ef096a47f64f326176afc4df5012adc8ea81bbf5 100644 --- a/hypha/apply/dashboard/templates/dashboard/includes/flagged.html +++ b/hypha/apply/dashboard/templates/dashboard/includes/flagged.html @@ -2,7 +2,7 @@ {% load i18n %} <h2 class="text-xl mb-2"> - {% trans "Your Flagged Submissions" %} + {% trans "Your flagged submissions" %} </h2> {% if my_flagged.data %} diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index 766fadbc5020798c9d38b95292c2c089484e6aa2..0665f4ae0258dd455a4f5b647c6fffee1f7fcad4 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -16,8 +16,8 @@ from hypha.apply.funds.tables import ( SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SubmissionsTable, - SummarySubmissionsTable, SummarySubmissionsTableWithRole, + UserFlaggedSubmissionsTable, review_filter_for_user, ) from hypha.apply.projects.filters import ProjectListFilter @@ -62,17 +62,12 @@ class MySubmissionContextMixin: class MyFlaggedMixin: def my_flagged(self, submissions): submissions = submissions.flagged_by(self.request.user).order_by("-submit_time") - row_attrs = dict( - {"data-flag-type": "user"}, **SummarySubmissionsTable._meta.row_attrs - ) limit = 5 return { - "table": SummarySubmissionsTable( + "table": UserFlaggedSubmissionsTable( submissions[:limit], prefix="my-flagged-", - attrs={"class": "all-submissions-table flagged-table"}, - row_attrs=row_attrs, ), "display_more": submissions.count() > limit, } diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index d381df11fa0ba718f10d444c018f5d83cd957ce2..082b468325e228daadbd3dbe89413068f28b695f 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -243,6 +243,22 @@ class SummarySubmissionsTableWithRole(BaseAdminSubmissionsTable): return "" +class StaffFlaggedSubmissionsTable(SummarySubmissionsTable): + class Meta(SummarySubmissionsTable.Meta): + row_attrs = dict( + {"data-flag-type": "staff"}, **SummarySubmissionsTable._meta.row_attrs + ) + attrs = {"class": "all-submissions-table flagged-table"} + + +class UserFlaggedSubmissionsTable(SummarySubmissionsTable): + class Meta(SummarySubmissionsTable.Meta): + row_attrs = dict( + {"data-flag-type": "user"}, **SummarySubmissionsTable._meta.row_attrs + ) + attrs = {"class": "all-submissions-table flagged-table"} + + def get_used_rounds(request): return Round.objects.filter(submissions__isnull=False).distinct() diff --git a/hypha/apply/funds/templates/funds/base_submissions_table.html b/hypha/apply/funds/templates/funds/base_submissions_table.html index bd1e3720c0afaf39800a42e1443a28c6212f1b5b..33b9669cf4de67e728095c83fab48e76c8ea51d2 100644 --- a/hypha/apply/funds/templates/funds/base_submissions_table.html +++ b/hypha/apply/funds/templates/funds/base_submissions_table.html @@ -25,5 +25,4 @@ <script src="{% static 'js/submission-filters.js' %}"></script> <script src="{% static 'js/tabs.js' %}"></script> <script src="{% static 'js/batch-actions.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/reviewer_leaderboard.html b/hypha/apply/funds/templates/funds/reviewer_leaderboard.html index 26b2491d803aca7a6a751295438bdf9c1727b355..7779ab602dc25d2313e76fb63480898cc65a8049 100644 --- a/hypha/apply/funds/templates/funds/reviewer_leaderboard.html +++ b/hypha/apply/funds/templates/funds/reviewer_leaderboard.html @@ -1,4 +1,4 @@ -{% extends "funds/submissions_overview.html" %} +{% extends "funds/base_submissions_table.html" %} {% load i18n static %} {% load render_table from django_tables2 %} diff --git a/hypha/apply/funds/templates/funds/reviewer_leaderboard_detail.html b/hypha/apply/funds/templates/funds/reviewer_leaderboard_detail.html index ab2dba329321d4423f785fdcb2d5db31c86e1870..03d0d18bc23eefa772e6dc34afd6deaa18c2011b 100644 --- a/hypha/apply/funds/templates/funds/reviewer_leaderboard_detail.html +++ b/hypha/apply/funds/templates/funds/reviewer_leaderboard_detail.html @@ -1,4 +1,4 @@ -{% extends "funds/submissions_overview.html" %} +{% extends "funds/base_submissions_table.html" %} {% load i18n static %} {% load render_table from django_tables2 %} diff --git a/hypha/apply/funds/templates/funds/staff_assignments.html b/hypha/apply/funds/templates/funds/staff_assignments.html index bf5bae87f973735ffe7191659bcb531f02820403..0be6503cc566a8c363b9b9400ef8160a5528bc50 100644 --- a/hypha/apply/funds/templates/funds/staff_assignments.html +++ b/hypha/apply/funds/templates/funds/staff_assignments.html @@ -1,4 +1,4 @@ -{% extends "funds/submissions_overview.html" %} +{% extends "funds/base_submissions_table.html" %} {% load i18n static %} {% load render_table from django_tables2 %} @@ -17,3 +17,9 @@ {% endblock %} </div> {% endblock %} + +{% block extra_js %} + {{ filter.form.media.js }} + <script src="{% static 'js/symbol-es6.min.js' %}"></script> + <script src="{% static 'js/flag.js' %}"></script> +{% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions.html b/hypha/apply/funds/templates/funds/submissions.html index 205b3bb45373a2c72300d513dbba381b9ccc27a9..347896fbe8150d5d739460441b2c219df890da67 100644 --- a/hypha/apply/funds/templates/funds/submissions.html +++ b/hypha/apply/funds/templates/funds/submissions.html @@ -8,14 +8,14 @@ {% adminbar %} {% slot header %} - {% trans "All Submissions" %}<span class="submissions-count"> ({{ table.rows|length }}) - <a class="text-sm text-lime-300 border-b border-transparent hover:opacity-70 transition-all" - hx-boost="true" - href="{% url 'apply:submissions:list-beta' %}" - > - {% heroicon_outline "rocket-launch" aria_hidden="true" size=15 stroke_width="2" class="inline align-text-bottom" %} - {% trans "Try newer version" %} - </a> + {% trans "All Submissions" %}<span class="submissions-count"> ({{ table.rows|length }})</span> + <a class="text-sm text-lime-300 border-b border-transparent hover:opacity-70 transition-all" + hx-boost="true" + href="{% url 'apply:submissions:list-beta' %}" + > + {% heroicon_outline "rocket-launch" aria_hidden="true" size=15 stroke_width="2" class="inline align-text-bottom" %} + {% trans "Try newer version" %} + </a> {% endslot %} {% slot sub_heading %}{% trans "Search and filter all submissions" %}{% endslot %} {% endadminbar %} diff --git a/hypha/apply/funds/templates/funds/submissions_overview.html b/hypha/apply/funds/templates/funds/submissions_overview.html index 77f2725d0f0a1e8c9c6f9811abc6df14d6e49d45..410be73ac7efe7301345a57212e02f65e0f930fb 100644 --- a/hypha/apply/funds/templates/funds/submissions_overview.html +++ b/hypha/apply/funds/templates/funds/submissions_overview.html @@ -32,7 +32,7 @@ {% if staff_flagged.table.data %} <div class="wrapper wrapper--bottom-space"> - <h4 class="heading heading--normal">{% trans "Staff Flagged Submissions" %}</h4> + <h4 class="heading heading--normal">{% trans "Staff flagged submissions" %}</h4> {% render_table staff_flagged.table %} {% if staff_flagged.display_more %} <div class="all-submissions-table__more"> diff --git a/hypha/apply/funds/templates/funds/submissions_result.html b/hypha/apply/funds/templates/funds/submissions_result.html index 9d6c917f3dd25ab2d112c58489da107191f60d30..e696b8240f82c156e6787cf3438211254c3c186a 100644 --- a/hypha/apply/funds/templates/funds/submissions_result.html +++ b/hypha/apply/funds/templates/funds/submissions_result.html @@ -1,4 +1,4 @@ -{% extends "funds/submissions_overview.html" %} +{% extends "funds/base_submissions_table.html" %} {% load i18n static apply_tags %} {% block title %}{% trans "Submissions results" %}{% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_search.html b/hypha/apply/funds/templates/funds/submissions_search.html deleted file mode 100644 index 8457dcba36f92549e1e9f829d000a530d0a145ee..0000000000000000000000000000000000000000 --- a/hypha/apply/funds/templates/funds/submissions_search.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "funds/submissions.html" %} -{% load i18n %} - -{% block page_header %} - <div class="wrapper wrapper--medium"> - <h3>{% trans "Search results" %}</h3> - {% if search_term %} - <h5>{% blocktrans with count=object_list.count %}There are {{ count }} results for: {{ search_term }}{% endblocktrans %}</h5> - {% endif %} - </div> -{% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_staff_flagged.html b/hypha/apply/funds/templates/funds/submissions_staff_flagged.html index 187911ccf99d17c03bcb3ae4a29743a558d5fc33..00436c3c907ffb8f29b962620331df5d9f60c857 100644 --- a/hypha/apply/funds/templates/funds/submissions_staff_flagged.html +++ b/hypha/apply/funds/templates/funds/submissions_staff_flagged.html @@ -1,8 +1,29 @@ -{% extends "funds/submissions.html" %} -{% load i18n %} +{% extends "funds/base_submissions_table.html" %} +{% load i18n static %} +{% load render_table from django_tables2 %} -{% block page_header %} - <div> - <h1 class="gamma heading heading--no-margin heading--bold">{% trans "Staff Flagged Submissions" %}</h1> +{% block title %}{% trans "Staff flagged submissions" %}{% endblock %} + +{% block content %} + + {% adminbar %} + {% slot header %} + {% trans "Staff flagged submissions" %}<span class="submissions-count"> ({{ table.rows|length }})</span> + {% endslot %} + {% slot sub_heading %}{% trans "Submissions flagged by staff" %}{% endslot %} + {% endadminbar %} + + + <div class="wrapper wrapper--large wrapper--inner-space-medium"> + {% block table %} + {% render_table table %} + {% endblock %} </div> {% endblock %} + +{% block extra_js %} + {{ filter.form.media.js }} + <script src="{% static 'js/all-submissions-table.js' %}"></script> + <script src="{% static 'js/symbol-es6.min.js' %}"></script> + <script src="{% static 'js/flag.js' %}"></script> +{% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_user_flagged.html b/hypha/apply/funds/templates/funds/submissions_user_flagged.html index b570eb1c7494a89fb888c0275d0f492757942ce4..05653fdf80420ce3d722978734fdd000d025c169 100644 --- a/hypha/apply/funds/templates/funds/submissions_user_flagged.html +++ b/hypha/apply/funds/templates/funds/submissions_user_flagged.html @@ -1,8 +1,22 @@ -{% extends "funds/submissions.html" %} -{% load i18n %} +{% extends "funds/base_submissions_table.html" %} +{% load i18n static %} +{% load render_table from django_tables2 %} -{% block page_header %} - <div> - <h1 class="gamma heading heading--no-margin heading--bold">{% trans "Your Flagged Submissions" %}</h1> +{% block title %}{% trans "Your flagged submissions" %}{% endblock %} + +{% block content %} + + {% adminbar %} + {% slot header %} + {% trans "Your flagged submissions" %} <span class="submissions-count">({{ table.rows|length }})</span> + {% endslot %} + {% slot sub_heading %}{% trans "Submissions flagged by you" %}{% endslot %} + {% endadminbar %} + + + <div class="wrapper wrapper--large wrapper--inner-space-medium"> + {% block table %} + {% render_table table %} + {% endblock %} </div> {% endblock %} diff --git a/hypha/apply/funds/templates/submissions/all.html b/hypha/apply/funds/templates/submissions/all.html index 6d36bd2c0ea4c07453e4ead81e08167712989f3e..e3241d6f884762ce959214d50cade031373492e1 100644 --- a/hypha/apply/funds/templates/submissions/all.html +++ b/hypha/apply/funds/templates/submissions/all.html @@ -51,6 +51,18 @@ {% endif %} {% trans "Your flagged submissions" %} </a> + <a + href="{% url "apply:submissions:list-beta" %}?query=flagged:@staff" + hx-get="{% url "apply:submissions:list-beta" %}?query=flagged:@staff" + hx-push-url="true" + hx-target="#main" + hx-swap="outerHTML" + class="flex {% if request.GET.query == "flagged:@staff" %}ps-2 font-medium bg-gray-100{% else %}ps-8 font-normal{% endif %} pe-3 py-2 text-gray-800 border-b items-center hover:bg-gray-100 focus:bg-gray-100"> + {% if request.GET.query == "flagged:@staff" %} + {% heroicon_mini "check" aria_hidden="true" size=16 class="stroke-2 me-1" %} + {% endif %} + {% trans "Staff flagged submissions" %} + </a> <a href="{% url "apply:submissions:list-beta" %}?query=reviewer:@me" href="{% url "apply:submissions:list-beta" %}?query=reviewer:@me" diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index e5dc76c60db5e6e89dc1ea9b0b5b5065ede42407..81a2cef5c47d6c97587f7783cf427dfbec6323f5 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -114,9 +114,11 @@ from .tables import ( RoundsFilter, RoundsTable, StaffAssignmentsTable, + StaffFlaggedSubmissionsTable, SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, + UserFlaggedSubmissionsTable, ) from .utils import get_default_screening_statues from .workflow import ( @@ -582,6 +584,7 @@ class SubmissionListView(ViewDispatcher): @method_decorator(staff_required, name="dispatch") class SubmissionStaffFlaggedView(BaseAdminSubmissionsTable): + table_class = StaffFlaggedSubmissionsTable template_name = "funds/submissions_staff_flagged.html" def get_queryset(self): @@ -595,6 +598,7 @@ class SubmissionStaffFlaggedView(BaseAdminSubmissionsTable): @method_decorator(login_required, name="dispatch") class SubmissionUserFlaggedView(UserPassesTestMixin, BaseAdminSubmissionsTable): + table_class = UserFlaggedSubmissionsTable template_name = "funds/submissions_user_flagged.html" def get_queryset(self): diff --git a/hypha/apply/funds/views_beta.py b/hypha/apply/funds/views_beta.py index 4c8eedb300c3813b433c2cec75a1ff5638b3e4bb..65044abfd9b746db334c9db9286e22d18f4f0f62 100644 --- a/hypha/apply/funds/views_beta.py +++ b/hypha/apply/funds/views_beta.py @@ -124,6 +124,8 @@ def submission_all_beta( if "flagged" in search_filters: if "@me" in search_filters["flagged"]: qs = qs.flagged_by(request.user) + if "@staff" in search_filters["flagged"]: + qs = qs.flagged_staff() if "lead" in search_filters: if "@me" in search_filters["lead"]: diff --git a/hypha/core/navigation.py b/hypha/core/navigation.py index 0b036c577082b2368953cf8c2311d5bfbb093200..2e77ea2683b773ea6f1aad5d50db175c44b429ec 100644 --- a/hypha/core/navigation.py +++ b/hypha/core/navigation.py @@ -34,6 +34,11 @@ nav_items = [ "url": reverse_lazy("apply:submissions:result"), "permission_method": "is_apply_staff", }, + { + "title": _("Staff flagged"), + "url": reverse_lazy("apply:submissions:staff_flagged"), + "permission_method": "is_apply_staff", + }, ], }, {