Skip to content

Commit

Permalink
New submission table view (#4080)
Browse files Browse the repository at this point in the history
Changes

- [x] Replaces the old view with new table view, that is powered by the
filtering and rendering logic build for the new list view.
- [x] removes round detail view and round export, reuse the submission
all page.
- [x] Add rounds/labs menu to primary nav, makes it easy to list and
view status of different rounds, for staff.
- [x] Update my flags view on the dashboard page.
- [x] Implement `SUBMISSION_LIST_EXCLUDE_FIELDS` on both list and table
view (in progress)
- [x] Expose old table view at an accessible url

---------

Co-authored-by: Fredrik Jonsson <frjo@xdeb.org>
  • Loading branch information
theskumar and frjo authored Sep 9, 2024
1 parent c20578f commit f0ca4ae
Show file tree
Hide file tree
Showing 37 changed files with 754 additions and 531 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ <h2 class="text-xl mb-2">
{% trans "Your flagged submissions" %}
</h2>

{% if my_flagged.data %}
{% if my_flagged.table.data %}

{% render_table my_flagged %}
{% render_table my_flagged.table %}

{% if display_more %}
<div class="all-submissions-table__more">
<a href="{% url 'apply:submissions:list-alt' %}?query=flagged:@me">{% trans "Show all" %}</a>
<a href="{% url 'apply:submissions:list' %}?query=flagged:@me">{% trans "Show all" %}</a>
</div>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ <h2 class="text-xl mb-2">
</h2>

{% if my_review.data %}
{% render_table my_review %}

{% include "submissions/partials/submissions-inline.html" with submissions=my_review.data row_layout="table" %}
{% comment %} {% render_table my_review %} {% endcomment %}

{% if display_more %}
<div class="all-submissions-table__more">
Expand Down
20 changes: 15 additions & 5 deletions hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,29 @@
{% include "dashboard/includes/submissions-waiting-for-review.html" with in_review_count=awaiting_reviews.count my_review=awaiting_reviews.table display_more=awaiting_reviews.display_more active_statuses_filter=awaiting_reviews.active_statuses_filter %}
</div>

{% if my_flagged.table.data %}
{% if my_flagged.submissions %}
<div id="submissions-flagged" class="wrapper wrapper--bottom-space">
{% include "dashboard/includes/flagged.html" with my_flagged=my_flagged.table display_more=my_flagged.display_more %}
<h3 class="text-xl mb-2">
<a href="{% url "apply:submissions:list" %}?query=flagged:@me">Your flagged submissions <span class="text-sm">({{ my_flagged.count }})</span></a>
</h3>

{% include "submissions/partials/submissions-inline.html" with submissions=my_flagged.submissions row_layout="table" %}

{% if my_flagged.display_more %}
<div class="border-x border-b flex items-center justify-center py-3 font-semibold">
<a href="{% url "apply:submissions:list" %}?query=flagged:@me">Show All</a>
</div>
{% endif %}
</div>
{% endif %}

{% if my_reviewed.table.data %}
<div class="wrapper wrapper--bottom-space">
<h3 class="text-xl mb-2">Your previous reviews</h3>

{% trans "Your previous reviews" as review_heading %}
{% render_table my_reviewed.table %}
{% include "submissions/partials/submissions-inline.html" with submissions=my_reviewed.table.data row_layout="table" %}

<div class="all-submissions-table__more">
<div class="border-x border-b flex items-center justify-center py-3 font-semibold">
<a href="{{ my_reviewed.url }}?reviewers={{ request.user.pk }}">{% trans "Show all" %}</a>
</div>
</div>
Expand Down
21 changes: 17 additions & 4 deletions hypha/apply/dashboard/templates/dashboard/staff_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,19 @@
{% include "dashboard/includes/submissions-waiting-for-review.html" with in_review_count=awaiting_reviews.count my_review=awaiting_reviews.table display_more=awaiting_reviews.display_more active_statuses_filter=awaiting_reviews.active_statuses_filter %}
</div>

{% if my_flagged.table.data %}
{% if my_flagged.submissions %}
<div id="submissions-flagged" class="wrapper wrapper--bottom-space">
{% include "dashboard/includes/flagged.html" with my_flagged=my_flagged.table display_more=my_flagged.display_more %}
<h3 class="text-xl mb-2">
<a href="{% url "apply:submissions:list" %}?query=flagged:@me">Your flagged submissions <span class="text-sm">({{ my_flagged.count }})</span></a>
</h3>

{% include "submissions/partials/submissions-inline.html" with submissions=my_flagged.submissions row_layout="table" %}

{% if my_flagged.display_more %}
<div class="border-x border-b flex items-center justify-center py-3 font-semibold">
<a href="{% url "apply:submissions:list" %}?query=flagged:@me">Show All</a>
</div>
{% endif %}
</div>
{% endif %}

Expand All @@ -83,14 +93,17 @@

{% if PROJECTS_ENABLED and paf_for_review.count %}
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
<h3 class="text-xl mb-2">{% trans "PAFs for review" %}</h3>
{% render_table paf_for_review.table %}
</div>
{% endif %}

{% if PROJECTS_ENABLED and projects.table.data %}
<div id="active-projects" class="wrapper wrapper--bottom-space">
{% trans "Your projects" as project_heading %}
<h3 class="text-xl mb-2">
{% trans "Your projects" %}
</h3>

{% render_table projects.table %}

<div class="all-submissions-table__more">
Expand Down
8 changes: 3 additions & 5 deletions hypha/apply/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SubmissionReviewerFilterAndSearch,
SubmissionsTable,
SummarySubmissionsTableWithRole,
UserFlaggedSubmissionsTable,
review_filter_for_user,
)
from hypha.apply.projects.filters import ProjectListFilter
Expand Down Expand Up @@ -65,10 +64,8 @@ def my_flagged(self, submissions):

limit = 5
return {
"table": UserFlaggedSubmissionsTable(
submissions[:limit],
prefix="my-flagged-",
),
"submissions": submissions[:limit],
"count": submissions.count(),
"display_more": submissions.count() > limit,
}

Expand Down Expand Up @@ -197,6 +194,7 @@ def rounds(self):
.order_by("-end_date")
.by_lead(self.request.user)
)

return {
"closed": rounds.closed()[:limit],
"open": rounds.open()[:limit],
Expand Down
7 changes: 7 additions & 0 deletions hypha/apply/funds/models/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from django.http import Http404
from django.shortcuts import redirect, render
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -834,6 +835,12 @@ def __eq__(self, other):

objects = RoundsAndLabsManager()

def get_absolute_url(self):
params = f"fund={self.pk}"
if self.fund:
params = f"round={self.pk}"
return f'{reverse("apply:submissions:list")}?{params}'

def save(self, *args, **kwargs):
raise NotImplementedError("Do not save through this model")

Expand Down
6 changes: 3 additions & 3 deletions hypha/apply/funds/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def can_change_external_reviewers(user, submission) -> bool:
return False


def can_access_drafts(user):
def can_access_drafts(user) -> bool:
if user.is_apply_staff and settings.SUBMISSIONS_DRAFT_ACCESS_STAFF:
return True
if user.is_apply_staff_admin and settings.SUBMISSIONS_DRAFT_ACCESS_STAFF_ADMIN:
return True
return False


def can_export_submissions(user):
def can_export_submissions(user) -> bool:
if user.is_apply_staff and settings.SUBMISSIONS_EXPORT_ACCESS_STAFF:
return True
if user.is_apply_staff_admin and settings.SUBMISSIONS_EXPORT_ACCESS_STAFF_ADMIN:
Expand Down Expand Up @@ -166,7 +166,7 @@ def can_view_submission_screening(user, submission):
submission_view, _ = is_user_has_access_to_view_submission(user, submission)
if not submission_view:
return False, "No access to view submission"
if user.is_applicant:
if submission.user == user:
return False, "Applicant cannot view submission screening"
return True, ""

Expand Down
14 changes: 2 additions & 12 deletions hypha/apply/funds/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ def render_role_icon(self, value):
return ""


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()

Expand Down Expand Up @@ -509,11 +501,9 @@ class SubmissionReviewerFilterAndSearch(SubmissionDashboardFilter):


class RoundsTable(tables.Table):
title = tables.LinkColumn(
"funds:rounds:detail",
args=[A("pk")],
title = tables.Column(
linkify=lambda record: record.get_absolute_url(),
orderable=True,
text=lambda record: record.title,
)
fund = tables.Column(accessor=A("specific__fund"))
lead = tables.Column()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% if request.GET.ref == 'all-alt' %}
<a class="simplified__submissions-link"
hx-boost="true"
href="{% url "funds:submissions:list-alt" %}"
href="{% url "funds:submissions:list" %}"
>
{% trans "Back to submissions" %}
</a>
Expand All @@ -29,7 +29,7 @@ <h1 class="mt-2 mb-0 font-medium">{{ object.title }}<span class="text-gray-400">
{% if request.user.is_apply_staff %}
<span>
<a class="link--transparent link--underlined"
href="{% url 'apply:rounds:detail' pk=object.round.pk %}"
href="{% url 'apply:submissions:list' %}?round={{ object.round.pk }}"
>{{ object.round }}</a>
</span>
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
{% for round in rounds %}
{% if forloop.counter0 < 5 %}
<li class="round-block__item">
<a href="{% url 'apply:rounds:detail' pk=round.pk %}" class="round-block__title">{{ round }}</a>
<p class="round-block__fund"> {{ round.fund|default_if_none:"-" }} </p>
<a href="{{round.get_absolute_url}}"
class="round-block__title hover:text-dark-blue"
>{{ round }}</a>
<p class="round-block__fund">
{{ round.fund|default_if_none:"-" }} </p>
<p class="round-block__date">
{% if round.end_date %}
{{ display_text }} {{ round.end_date|date:"SHORT_DATE_FORMAT" }}
Expand All @@ -20,9 +23,10 @@
{{ round.progress }}% {% trans 'Determined' %} ({{ round.closed_submissions }}/{{ round.total_submissions }})
{% endif %}
</p>
<a class="round-block__view" href="{% url 'apply:rounds:detail' pk=round.pk %}">{% trans 'View' %}</a>
<a class="round-block__view" href="{{round.get_absolute_url}}">{% trans 'View' %}
</a>
{% if can_export %}
<a class="round-block__view" href="{% url 'apply:rounds:export' pk=round.pk %}">{% trans 'Export' %}</a>
<a class="round-block__view" href="{% url 'apply:submissions:list' %}{% if round.fund %}?round={{round.pk}}{% else %}?fund={{round.pk}}{% endif %}&format=csv">{% trans 'Export' %}</a>
{% endif %}
</li>
{% else %}
Expand Down
61 changes: 33 additions & 28 deletions hypha/apply/funds/templates/funds/includes/round-block.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,41 @@
x-init="activeTab = window.location.hash && ['#open-rounds', '#closed-rounds'].includes(window.location.hash) ? window.location.hash.substring(1) : activeTab"
>
<section class="section section--with-options">
<h4 class="heading heading--normal heading--no-margin">{{ title }}</a></h4>
<div>
<a class="tab__item tab__item--alt"
href="#open-rounds"
@click="activeTab = 'open-rounds'"
:class="{ 'tab__item--active': activeTab === 'open-rounds' }"
>{% trans "Open" %}</a>
<a class="tab__item tab__item--alt"
href="#closed-rounds"
@click="activeTab = 'closed-rounds'"
:class="{ 'tab__item--active': activeTab === 'closed-rounds' }"
>{% trans "Closed" %}</a>
</div>
</section>
<h3 class="text-xl mb-2">
<a href="{% url 'apply:rounds:list' %}">{{ title }}</a>
</h3>
<div>
<a
class="tab__item tab__item--alt"
href="#open-rounds"
@click="activeTab = 'open-rounds'"
:class="{ 'tab__item--active': activeTab === 'open-rounds' }"
>{% trans "Open" %}</a>

<a
class="tab__item tab__item--alt"
href="#closed-rounds"
@click="activeTab = 'closed-rounds'"
:class="{ 'tab__item--active': activeTab === 'closed-rounds' }"
>{% trans "Closed" %}</a>
</div>
</section>

{# Open rounds/labs tab #}
<div x-cloak x-show="activeTab === 'open-rounds'">
{% if page_type == 'dashboard' %}
{% include "funds/includes/no_round_block_dashboard.html" with rounds=open_rounds display_text="Open until" query=open_query type="Open" %}
{% else %}
{% include "funds/includes/round-block-listing.html" with can_export=can_export rounds=open_rounds display_text="Open until" query=open_query type="Open" %}
{% endif %}
</div>
<div x-cloak x-show="activeTab === 'open-rounds'">
{% if page_type == 'dashboard' %}
{% include "funds/includes/no_round_block_dashboard.html" with rounds=open_rounds display_text="Open until" query=open_query type="Open" %}
{% else %}
{% include "funds/includes/round-block-listing.html" with can_export=can_export rounds=open_rounds display_text="Open until" query=open_query type="Open" %}
{% endif %}
</div>

{# Closed rounds/labs tab #}
<div x-cloak x-show="activeTab === 'closed-rounds'">
{% if page_type == 'dashboard' %}
{% include "funds/includes/no_round_block_dashboard.html" with rounds=closed_rounds display_text="Closed" query=closed_query type="Closed" %}
{% else %}
{% include "funds/includes/round-block-listing.html" with rounds=closed_rounds display_text="Closed" query=closed_query type="Closed" %}
{% endif %}
</div>
<div x-cloak x-show="activeTab === 'closed-rounds'">
{% if page_type == 'dashboard' %}
{% include "funds/includes/no_round_block_dashboard.html" with rounds=closed_rounds display_text="Closed" query=closed_query type="Closed" %}
{% else %}
{% include "funds/includes/round-block-listing.html" with rounds=closed_rounds display_text="Closed" query=closed_query type="Closed" %}
{% endif %}
</div>
</div>
Loading

0 comments on commit f0ca4ae

Please sign in to comment.