Skip to content

Commit ae5dbf8

Browse files
authored
Update public facing id of project to be the id of the submission (#3944)
Update the project urls to use it's submission id instead of the project's db id The reason for the update is that there are two main entities in the system, one submission and other project. The ids of the submission is linkable in the communiction and also used for referencing at different places. Considering a project is an extension of application submission, if we have the project publically available id same as that of it's submission it always to link and reference the project by the same id. ## Test Steps <!-- If step does not require manual testing, skip/remove this section. Give a brief overview of the steps required for a user/dev to test this contribution. Important things to include: - Required user roles for where necessary (ie. "As a Staff Admin...") - Clear & validatable expected results (ie. "Confirm the submit button is now not clickable") - Language that can be understood by non-technical testers if being tested by users --> - [ ] General regression test and make sure all the urls in the project section resolve and link to the right pages
1 parent 94ce314 commit ae5dbf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+393
-345
lines changed

hypha/apply/activity/templates/messages/email/assign_paf_approvers.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% trans "Project documents are ready to be assigned for approval." %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.submission.pk %}
1111

1212
{% blocktrans with lead=source.lead email=source.lead.email %}Please contact {{ lead }} - {{ email }} if you have any questions.{% endblocktrans %}
1313
{% endblock %}{# fmt:on #}

hypha/apply/activity/templates/messages/email/paf_for_approval.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% trans "A Project is awaiting your review." %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.submission.pk %}
1111

1212
{% blocktrans with lead=source.lead email=source.lead.email %}Please contact {{ lead }} - {{ email }} if you have any questions.{% endblocktrans %}
1313
{% endblock %}{# fmt:on #}

hypha/apply/activity/templates/messages/email/project_final_approval.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% trans "A Project is awaiting final approval." %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.submission.pk %}
1111

1212
{% blocktrans with lead=source.lead email=source.lead.email %}Please contact {{ lead }} - {{ email }} if you have any questions.{% endblocktrans %}
1313
{% endblock %}{# fmt:on #}

hypha/apply/activity/templates/messages/email/project_request_change.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
{% trans "A Project has been rejected by project form reviewers, please update it accordingly and resubmit it to the reviewers." %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:detail' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{{ source.get_absolute_url }}
1111
{% endblock %}{# fmt:on #}

hypha/apply/activity/templates/messages/email/ready_for_contracting.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{% trans "A Project is waiting for contract" %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:detail' pk=source.pk %}
11-
{% trans "Project Form" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{{ source.get_absolute_url }}
11+
{% trans "Project Form" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.submission.pk %}
1212

1313
{% blocktrans with lead=source.lead email=source.lead.email %}Please contact {{ lead }} - {{ email }} if you have any questions.{% endblocktrans %}
1414
{% endblock %}{# fmt:on #}

hypha/apply/activity/templates/messages/email/sent_to_compliance.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% trans "A Project is awaiting your review." %}
88

99
{% trans "Title" %}: {{ source.title }}
10-
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
10+
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.submission.pk %}
1111

1212
{% blocktrans with lead=source.lead email=source.lead.email %}Please contact {{ lead }} - {{ email }} if you have any questions.{% endblocktrans %}
1313
{% endblock %}{# fmt:on #}

hypha/apply/dashboard/templates/dashboard/partials/applicant_projects.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="wrapper wrapper--status-bar-outer">
55
<div class="wrapper wrapper--status-bar-inner ms-4">
66
<div class="mt-5 lg:max-w-[30%]">
7-
<h4 class="mb-0 font-bold heading line-clamp-3 hover:line-clamp-none"><a class="link" href="{% url 'apply:projects:detail' project.id %}">{{ project.title }}</a></h4>
7+
<h4 class="mb-0 font-bold heading line-clamp-3 hover:line-clamp-none"><a class="link" href="{{ project.get_absolute_url }}">{{ project.title }}</a></h4>
88
<p class="m-0 text-sm text-fg-muted">{% trans "Project start date: " %} {{ project.created_at.date }}</p>
99
</div>
1010
{% project_status_bar project.status request.user css_class="status-bar--small" %}

hypha/apply/funds/templates/funds/applicationsubmission_detail.html

+21-48
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,14 @@
99
{% block content %}
1010
<div class="admin-bar">
1111
<div class="admin-bar__inner">
12-
{% if request.GET.ref == 'all-alt' %}
13-
<a class="admin-bar__back-link"
14-
hx-boost="true"
15-
href="{% url "funds:submissions:list" %}"
16-
>
17-
{% trans "Back to submissions" %}
18-
</a>
12+
13+
{% if object.project %}
14+
{% include "application_projects/includes/project_header.html" with object=object.project %}
15+
{% else %}
16+
{% include "funds/includes/application_header.html" %}
1917
{% endif %}
20-
<h1 class="mb-0 font-medium">
21-
<span id="app-title">{{ object.title }}</span><span class="text-gray-400"> #{{ object.public_id|default:object.id }}</span>
22-
</h1>
23-
<div class="mt-1 text-sm font-medium heading heading--meta">
24-
<span>{{ object.stage }}</span>
25-
<span>{{ object.page }}</span>
26-
{% if object.round %}
27-
{% if request.user.is_apply_staff %}
28-
<span>
29-
<a class="text-white underline"
30-
href="{% url 'apply:submissions:list' %}?round={{ object.round.pk }}"
31-
>{{ object.round }}</a>
32-
</span>
33-
{% else %}
34-
<span>{{ object.round }}</span>
35-
{% endif %}
36-
{% endif %}
3718

38-
<span
39-
hx-get="{% url "apply:submissions:partial-get-lead" object.id %}"
40-
hx-trigger="load, leadUpdated from:body"
41-
>
42-
<span class="inline-block w-24 bg-gray-600 rounded-md animate-pulse"></span>
43-
</span>
44-
</div>
4519

46-
{% status_bar object.workflow object.phase request.user author=object.user same_stage=True %}
4720

4821
<div class="tabs js-tabs">
4922
<div class="tabs__container">
@@ -62,7 +35,7 @@ <h1 class="mb-0 font-medium">
6235

6336
{% if object.project and PROJECTS_ENABLED %}
6437
<a class="tab__item js-tabs-off"
65-
href="{% url 'apply:projects:detail' pk=object.project.id %}"
38+
href="{% url 'apply:projects:detail' pk=object.id %}"
6639
>
6740
{% trans "Project" %}
6841
</a>
@@ -78,20 +51,6 @@ <h1 class="mb-0 font-medium">
7851
</div>
7952
</div>
8053

81-
{% if object.is_archive %}
82-
<div class="py-2 font-bold text-center text-white bg-red-600">
83-
{% heroicon_outline "lock-closed" aria_hidden="true" size=16 stroke_width=2 class="inline align-baseline me-1" %}
84-
{% trans "This submission has been archived. This is visible to the roles " %} {{ archive_access_groups|join_with_commas }}
85-
</div>
86-
{% endif %}
87-
88-
{% if object.round.specific.is_sealed %}
89-
<div class="py-2 font-bold text-center text-white bg-red-600">
90-
{% heroicon_outline "clock" aria_hidden="true" size=16 stroke_width=2 class="inline align-baseline me-1" %}
91-
{% trans "This submission is sealed" %}
92-
</div>
93-
{% endif %}
94-
9554
<div class="wrapper wrapper--large wrapper--tabs js-tabs-content">
9655
{# Tab 1 #}
9756
<div class="tabs__content" id="tab-1">
@@ -104,6 +63,20 @@ <h5>{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
10463
</div>
10564
{% else %}
10665
<article class="wrapper--sidebar--inner">
66+
{% if object.is_archive %}
67+
<div class="flex gap-2 justify-center items-center py-2 mb-4 font-semibold text-center text-white bg-red-600 rounded-sm">
68+
{% heroicon_outline "lock-closed" aria_hidden="true" size=16 stroke_width=2 class="inline align-baseline me-1" %}
69+
{% trans "This application has been archived. This is visible to the roles " %} {{ archive_access_groups|join_with_commas }}.
70+
</div>
71+
{% endif %}
72+
73+
{% if object.round.specific.is_sealed %}
74+
<div class="flex gap-2 justify-center items-center py-2 mb-4 font-semibold text-center text-white bg-red-600 rounded-sm">
75+
{% heroicon_outline "clock" aria_hidden="true" size=16 stroke_width=2 class="inline align-baseline me-1" %}
76+
{% trans "This application is sealed." %}
77+
</div>
78+
{% endif %}
79+
10780
<header class="heading heading--submission-meta heading-text zeta">
10881
<span>
10982
{% if object.is_draft %}
@@ -232,7 +205,7 @@ <h6 class="pb-2 mb-0 font-semibold uppercase border-b text-fg-muted">
232205
{# Tab 2 #}
233206
<div class="tabs__content" id="tab-2">
234207
<div class="feed">
235-
{% if not object.is_archive %}
208+
{% if not object.is_archive or object.project %}
236209
<h4 class="m-0 sr-only">{% trans "Add communication" %}</h4>
237210
{% include "activity/include/comment_form.html" %}
238211
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% load i18n statusbar_tags %}
2+
3+
<h1 class="mb-0 font-medium">
4+
<span id="app-title">{{ object.title }}</span><span class="text-gray-400"> #{{ object.public_id|default:object.id }}</span>
5+
</h1>
6+
7+
<div class="mt-1 text-sm font-medium heading heading--meta">
8+
<span>{{ object.stage }}</span>
9+
<span>{{ object.page }}</span>
10+
{% if object.round %}
11+
{% if request.user.is_apply_staff %}
12+
<span>
13+
<a class="text-white underline"
14+
href="{% url 'apply:submissions:list' %}?round={{ object.round.pk }}"
15+
>{{ object.round }}</a>
16+
</span>
17+
{% else %}
18+
<span>{{ object.round }}</span>
19+
{% endif %}
20+
{% endif %}
21+
22+
<span
23+
hx-get="{% url "apply:submissions:partial-get-lead" object.id %}"
24+
hx-trigger="load, leadUpdated from:body"
25+
>
26+
<span class="inline-block w-24 bg-gray-600 rounded-md animate-pulse"></span>
27+
</span>
28+
</div>
29+
30+
{% status_bar object.workflow object.phase request.user author=object.user same_stage=True %}

hypha/apply/funds/templates/funds/includes/submission-list-row.html

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
{{ s.page }}</a>
120120
{% endif %}
121121
{% endif %}
122+
123+
{% if s.project %}
124+
<a href="{% url "apply:projects:detail" s.id %}" class="hover:underline text-inherit">{% trans "Project" %}</a>
125+
{% endif %}
122126
</p>
123127
</div>
124128
</div>

hypha/apply/funds/templates/funds/includes/submission-table-row.html

+4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@
4949
#{{ s.public_id|default:s.id }}
5050
submitted <relative-time datetime="{{ s.submit_time|date:"c" }}">{{ s.submit_time|date:"SHORT_DATE_FORMAT" }}</relative-time>
5151
• {{ s.stage }}
52+
{% if s.project %}
53+
<a href="{% url "apply:projects:detail" s.id %}" class="hover:underline text-inherit">{% trans "Project" %}</a>
54+
{% endif %}
5255
</div>
5356
</td>
5457

5558
<td class="p-2 text-center align-top">
59+
5660
<a
5761
hx-target="#main"
5862
hx-push-url="true"

hypha/apply/projects/models/payment.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def value(self):
227227
def get_absolute_url(self):
228228
return reverse(
229229
"apply:projects:invoice-detail",
230-
kwargs={"pk": self.project.pk, "invoice_pk": self.pk},
230+
kwargs={"pk": self.project.submission.id, "invoice_pk": self.pk},
231231
)
232232

233233
@property
@@ -253,3 +253,13 @@ def __str__(self):
253253
@property
254254
def filename(self):
255255
return os.path.basename(self.document.name)
256+
257+
def get_absolute_url(self):
258+
return reverse(
259+
"apply:projects:invoice-supporting-document",
260+
kwargs={
261+
"pk": self.invoice.project.submission.id,
262+
"invoice_pk": self.invoice.pk,
263+
"file_pk": self.pk,
264+
},
265+
)

hypha/apply/projects/models/project.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def editable(self):
445445
return False
446446

447447
def get_absolute_url(self):
448-
return reverse("apply:projects:detail", args=[self.id])
448+
return reverse("apply:projects:detail", args=[self.submission.id])
449449

450450
@property
451451
def can_make_approval(self):
@@ -693,7 +693,9 @@ def __str__(self):
693693
)
694694

695695
def get_absolute_url(self):
696-
return reverse("apply:projects:contract", args=[self.project.pk, self.pk])
696+
return reverse(
697+
"apply:projects:contract", args=[self.project.submission.id, self.pk]
698+
)
697699

698700

699701
class PacketFile(models.Model):

hypha/apply/projects/permissions.py

+5
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ def can_access_project(user, project):
383383

384384

385385
def can_view_contract_category_documents(user, project, **kwargs):
386+
if user.is_superuser:
387+
return True, "Superuser can view all documents"
388+
if user == project.user:
389+
return True, "Vendor can view all documents"
390+
386391
contract_category = kwargs.get("contract_category")
387392
if not contract_category:
388393
return False, "Contract Category is required"

hypha/apply/projects/tables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BaseInvoiceTable(tables.Table):
2525
invoice_number = tables.LinkColumn(
2626
"funds:projects:invoice-detail",
2727
verbose_name=_("Invoice Number"),
28-
args=[tables.utils.A("project__pk"), tables.utils.A("pk")],
28+
args=[tables.utils.A("project__submission__pk"), tables.utils.A("pk")],
2929
attrs={
3030
"td": {
3131
"class": "js-title", # using title as class because of batch-actions.js
@@ -163,7 +163,7 @@ class BaseProjectsTable(tables.Table):
163163
title = tables.LinkColumn(
164164
"funds:projects:detail",
165165
text=lambda r: textwrap.shorten(r.title, width=30, placeholder="..."),
166-
args=[tables.utils.A("pk")],
166+
args=[tables.utils.A("submission__pk")],
167167
)
168168
status = tables.Column(
169169
verbose_name=_("Status"), accessor="get_status_display", order_by=("status",)

hypha/apply/projects/templates/application_projects/includes/contracting_documents.html

+14-10
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ <h2 class="m-0 text-lg font-semibold">
2222
{% if can_submit_contract %}
2323
<a class="button button--project-action {% if required_remaining_contract_document_categories or not contract.signed_by_applicant %}is-disabled{% endif %}"
2424
id="submit_contract_document"
25-
hx-get="{% url 'apply:projects:contract_documents_submit' object.id %}"
26-
href="{% url 'apply:projects:contract_documents_submit' object.id %}"
25+
hx-get="{% url 'apply:projects:contract_documents_submit' object.submission.id %}"
26+
href="{% url 'apply:projects:contract_documents_submit' object.submission.id %}"
2727
hx-target="#htmx-modal"
2828
>
2929
{% trans "Submit contract documents" %}
@@ -32,8 +32,8 @@ <h2 class="m-0 text-lg font-semibold">
3232
{% user_can_approve_contract request.user object as can_approve_contract %}
3333
{% if contract_to_approve and can_approve_contract %}
3434
<a class="button button--project-action"
35-
hx-get="{% url 'apply:projects:contract_approve' object.id %}"
36-
href="{% url 'apply:projects:contract_approve' object.id %}"
35+
hx-get="{% url 'apply:projects:contract_approve' object.submission.id %}"
36+
href="{% url 'apply:projects:contract_approve' object.submission.id %}"
3737
hx-target="#htmx-modal"
3838
>
3939
{% trans "Approve contract documents" %}
@@ -58,7 +58,11 @@ <h2 class="m-0 text-lg font-semibold">
5858
</div>
5959
{% if contract_uploaded %}
6060
<div class="docs-block__row-inner">
61-
<a class="flex items-center p-2.5 mb-1 w-auto font-bold bg-white border border-solid hover:text-white text-start text-light-blue me-0 border-light-blue hover:bg-light-blue focus:text-light-blue" href="{% url 'apply:projects:contract' pk=project.pk file_pk=contract.pk %}" target="_blank">
61+
<a
62+
class="flex items-center p-2.5 mb-1 w-auto font-bold bg-white border border-solid hover:text-white text-start text-light-blue me-0 border-light-blue hover:bg-light-blue focus:text-light-blue"
63+
href="{{ contract.get_absolute_url }}"
64+
target="_blank"
65+
>
6266
{% heroicon_micro "eye" class="inline w-4 h-4 me-1" aria_hidden=true %}
6367
{% trans "View" %}
6468
</a>
@@ -93,8 +97,8 @@ <h2 class="m-0 text-lg font-semibold">
9397
{% if can_upload_contract and can_initiate_contract %}
9498
<div class="docs-block__row-inner docs-block__row-inner__contract-upload-row">
9599
<a class="flex items-center p-2.5 w-auto font-bold text-white border-none text-start bg-light-blue me-0"
96-
hx-get="{% url 'apply:projects:contract_upload' object.id %}"
97-
href="{% url 'apply:projects:contract_upload' object.id %}"
100+
hx-get="{% url 'apply:projects:contract_upload' object.submission.id %}"
101+
href="{% url 'apply:projects:contract_upload' object.submission.id %}"
98102
hx-target="#htmx-modal"
99103
>
100104
{% heroicon_micro "arrow-up-tray" size=18 class="inline me-1" aria_hidden="true" %}
@@ -116,8 +120,8 @@ <h2 class="m-0 text-lg font-semibold">
116120
{% if can_upload_contract and user.is_applicant %}
117121
<div class="docs-block__row-inner docs-block__row-inner__contract-upload-row">
118122
<a class="flex items-center p-2.5 w-auto font-bold text-white border-none text-start bg-light-blue me-0"
119-
hx-get="{% url 'apply:projects:contract_upload' object.id %}"
120-
href="{% url 'apply:projects:contract_upload' object.id %}"
123+
hx-get="{% url 'apply:projects:contract_upload' object.submission.id %}"
124+
href="{% url 'apply:projects:contract_upload' object.submission.id %}"
121125
hx-target="#htmx-modal"
122126
>
123127
{% heroicon_mini "arrow-up-tray" size=18 class="inline me-1" aria_hidden="true" %}
@@ -137,7 +141,7 @@ <h2 class="m-0 text-lg font-semibold">
137141
{% if contracting_documents_configured and contract_uploaded %}
138142
<div
139143
hx-trigger="load, contractingDocumentUpload from:body, contractingDocumentRemove from:body"
140-
hx-get="{% url "apply:projects:contract_documents" object.id %}"
144+
hx-get="{% url "apply:projects:contract_documents" object.submission.id %}"
141145
hx-target="this">
142146
{% heroicon_outline "check-circle" class="stroke-gray-400 me-1" aria_hidden=true %}
143147
<p class="docs-block__title">{% trans "Contracting documents" %}</p>

hypha/apply/projects/templates/application_projects/includes/invoice_block.html

-15
This file was deleted.

0 commit comments

Comments
 (0)