Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 21 additions & 43 deletions hypha/apply/dashboard/templates/dashboard/community_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,57 +57,35 @@ <h2 class="section-header">
</section>
{% endif %}

<section>
<h2 class="section-header">
{% trans "Your active submissions" %}
</h2>
{% for submission in my_submissions %}
<div class="wrapper wrapper--status-bar-outer">
<div class="wrapper wrapper--status-bar-inner">
<div class="flex flex-col gap-2 max-w-sm sm:max-w-lg md:flex-row md:justify-between md:w-full md:max-w-none lg:flex-col lg:justify-start lg:w-auto lg:max-w-sm">
<div>
<h3 class="text-base font-bold">
<a class="{% if not submission.is_active %} text-slate-500 {% endif %} hover:underline" href="{% url 'funds:submissions:detail' submission.id %}">
{{ submission.title }}
<span class="text-fg-muted">#{{ submission.application_id }}</span>
</a>
</h3>
<p class="text-sm heading text-fg-muted">
{% trans "Submitted" %}: {{ submission.submit_time.date }} {% trans "by" %} {{ submission.user.get_full_name }}
</p>
{% if my_submissions_exists %}
<section>
<h2 class="section-header">{% trans "My submissions" %}</h2>
<div class="overflow-hidden border border-base-200 rounded-box shadow-xs">
<div
hx-get="{% url 'dashboard:applicant_submissions' %}"
hx-trigger="load"
id="submissions_list"
class="list"
>
{% for dummy_item in per_section_items %}
<div class="animate-pulse list-row min-h-40">
<div class="mt-5 ms-4 lg:max-w-[30%] h-9 bg-base-300 "></div>
</div>
{% if request.user|has_edit_perm:submission %}
<div>
<a class="btn btn-primary" href="{% url 'funds:submissions:edit' submission.id %}">
{% if submission.status == 'draft_proposal' %}
{% trans "Start your" %} {{ submission.stage }} {% trans "application" %}
{% else %}
<span class="whitespace-nowrap">
{% heroicon_mini "pencil-square" size=18 class="inline align-text-bottom me-1" aria_hidden=true %}
{% trans "Edit" %}
</span>
{% endif %}
</a>
</div>
{% endif %}
</div>

{% status_bar submission.workflow submission.phase request.user css_class="status-bar--small" %}
{% endfor %}
</div>
</div>
{% empty %}
{% trans "No active submissions" %}
{% endfor %}
</section>
</section>
{% endif %}

{% if my_inactive_submissions.data %}
<section>
{% if historical_submissions.count %}
<section id="submission-history">
<h2 class="section-header">
{% trans "Submission history" %}
</h2>
{% render_table my_inactive_submissions %}
<div class="overflow-x-auto border border-base-200 rounded-box shadow-xs">
{% render_table historical_submissions.table %}
</div>
</section>
{% endif %}
</div>

{% endblock %}
44 changes: 19 additions & 25 deletions hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,34 @@ <h2 class="section-header">
</section>
{% endif %}

{% if my_submissions %}
{% if my_submissions_exists %}
<section>
<h2 class="section-header">
{% trans "Your active submissions" %}
</h2>
{% for submission in my_submissions %}
<div class="wrapper wrapper--status-bar-outer">
<div class="wrapper wrapper--status-bar-inner">
<div>
<h5 class="m-0 heading"><a class="underline" href="{% url 'funds:submissions:detail' submission.id %}">{{ submission.title }}</a></h5>
<h6 class="m-0 heading"><span>{% trans "Submitted" %}:</span> {{ submission.submit_time.date }} {% trans "by" %} {{ submission.user.get_full_name }}</h6>
<h2 class="section-header">{% trans "My submissions" %}</h2>
<div class="overflow-hidden border border-base-200 rounded-box shadow-xs">
<div
hx-get="{% url 'dashboard:applicant_submissions' %}"
hx-trigger="load"
id="submissions_list"
class="list"
>
{% for dummy_item in per_section_items %}
<div class="animate-pulse list-row min-h-40">
<div class="mt-5 ms-4 lg:max-w-[30%] h-9 bg-base-300 "></div>
</div>
{% status_bar submission.workflow submission.phase request.user css_class="status-bar--small" %}
</div>
{% if request.user|has_edit_perm:submission %}
<a class="btn btn-primary" href="{% url 'funds:submissions:edit' submission.id %}">
{% if submission.status == 'draft_proposal' %}
{% trans "Start your" %} {{ submission.stage }} {% trans "application" %}
{% else %}
{% trans "Edit" %}
{% endif %}
</a>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</section>
{% endif %}

{% if my_inactive_submissions.data %}
<section>
{% if historical_submissions.count %}
<section id="submission-history">
<h2 class="section-header">
{% trans "Submission history" %}
</h2>
{% render_table my_inactive_submissions %}
<div class="overflow-x-auto border border-base-200 rounded-box shadow-xs">
{% render_table historical_submissions.table %}
</div>
</section>
{% endif %}
</div>
Expand Down
69 changes: 27 additions & 42 deletions hypha/apply/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,6 @@ def get_preview_context(queryset, limit=5):
}


class MySubmissionContextMixin:
def get_context_data(self, **kwargs):
submissions = ApplicationSubmission.objects.all().for_table(self.request.user)
my_submissions = (
submissions.filter(user=self.request.user)
.active()
.current()
.select_related("draft_revision")
)
my_submissions = [submission.from_draft() for submission in my_submissions]

my_inactive_submissions = (
submissions.filter(user=self.request.user).inactive().current()
)
my_inactive_submissions_table = ReviewerSubmissionsTable(
my_inactive_submissions, prefix="my-submissions-"
)

return super().get_context_data(
my_submissions=my_submissions,
my_inactive_submissions=my_inactive_submissions_table,
**kwargs,
)


class MyFlaggedMixin:
def my_flagged(self, submissions):
return get_preview_context(
Expand Down Expand Up @@ -94,6 +69,22 @@ def paf_for_review(self):
}


class HistoricalSubmissionMixin:
def historical_submission_data(self):
historical_submissions = list(
ApplicationSubmission.objects.filter(
user=self.request.user,
)
.inactive()
.current()
.for_table(self.request.user)
)
return {
"count": len(historical_submissions),
"table": SubmissionsTable(data=historical_submissions),
}


class AdminDashboardView(PAFReviewMixin, MyFlaggedMixin, TemplateView):
template_name = "dashboard/staff_dashboard.html"
paf_reviewer_role = "is_apply_staff"
Expand Down Expand Up @@ -233,7 +224,7 @@ def invoices_to_convert(self):
}


class ReviewerDashboardView(MyFlaggedMixin, MySubmissionContextMixin, TemplateView):
class ReviewerDashboardView(HistoricalSubmissionMixin, MyFlaggedMixin, TemplateView):
template_name = "dashboard/reviewer_dashboard.html"

def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -268,6 +259,10 @@ def get_context_data(self, **kwargs):

context.update(
{
"my_submissions_exists": ApplicationSubmission.objects.filter(
Q(user=self.request.user) | Q(co_applicants__user=self.request.user)
).exists(),
"historical_submissions": self.historical_submission_data(),
"awaiting_reviews": self.awaiting_reviews(submissions),
"my_reviewed": get_preview_context(
submissions.reviewed_by(self.request.user).order_by("-submit_time")
Expand Down Expand Up @@ -353,7 +348,7 @@ def projects_in_contracting(self):
}


class CommunityDashboardView(MySubmissionContextMixin, TemplateView):
class CommunityDashboardView(HistoricalSubmissionMixin, TemplateView):
template_name = "dashboard/community_dashboard.html"

def get_context_data(self, **kwargs):
Expand All @@ -366,6 +361,10 @@ def get_context_data(self, **kwargs):
)
context.update(
{
"my_submissions_exists": ApplicationSubmission.objects.filter(
Q(user=self.request.user) | Q(co_applicants__user=self.request.user)
).exists(),
"historical_submissions": self.historical_submission_data(),
"my_community_review": my_community_review_table,
"my_community_review_count": my_community_review_qs.count(),
"my_reviewed": get_preview_context(
Expand All @@ -387,7 +386,7 @@ def my_community_review(self, user, submissions):
return my_community_review, my_community_review_table


class ApplicantDashboardView(TemplateView):
class ApplicantDashboardView(HistoricalSubmissionMixin, TemplateView):
template_name = "dashboard/applicant_dashboard.html"

def get_context_data(self, **kwargs):
Expand Down Expand Up @@ -434,20 +433,6 @@ def historical_project_data(self):
),
}

def historical_submission_data(self):
historical_submissions = list(
ApplicationSubmission.objects.filter(
user=self.request.user,
)
.inactive()
.current()
.for_table(self.request.user)
)
return {
"count": len(historical_submissions),
"table": SubmissionsTable(data=historical_submissions),
}


class DashboardView(ViewDispatcher):
admin_view = AdminDashboardView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

{% block content %}
<div class="my-4 mx-auto layout layout-sidebar-end layout-flowrow-until-md layout-sidebar-flowrow-end md:[--layout-sidebar-width:20.5rem]">
<article class="layout-main">
<div class="layout-main">
{% if request.user|has_edit_perm:object and object.status == 'draft_proposal' and not request.user.is_apply_staff %}
<h4>{% trans "Congratulations!" %}</h4>
<h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} application has been accepted.{% endblocktrans %}</h5>
Expand Down Expand Up @@ -147,7 +147,7 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio

</article>
{% endif %}
</article>
</div>

<aside class="flex flex-col gap-4 layout-sidebar">
{% block sidebar_top %}
Expand Down Expand Up @@ -242,4 +242,4 @@ <h6 class="pb-2 mb-0 font-semibold uppercase border-b text-fg-muted">
{% endblock %}
</aside>
</div>
{% endblock %}
{% endblock content %}
Loading
Loading