Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update public facing id of project to be the id of the submission #3944

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
{% trans "A Project has been rejected by PAF reviewers, please update it accordingly and resubmit it to the reviewers." %}

{% trans "Title" %}: {{ source.title }}
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:detail' pk=source.pk %}
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{{ source.get_absolute_url }}
{% endblock %}{# fmt:on #}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% trans "A Project is waiting for contract" %}

{% trans "Title" %}: {{ source.title }}
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:detail' pk=source.pk %}
{% trans "Link" %}: {{ request.scheme }}://{{ request.get_host }}{{ source.get_absolute_url }}
{% trans "Project Form" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:projects:approval' pk=source.pk %}
{% trans "Original Submission" %}: {{ request.scheme }}://{{ request.get_host }}{% url 'apply:submissions:simplified' pk=source.submission.pk %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="wrapper wrapper--status-bar-outer">
<div class="wrapper wrapper--status-bar-inner ms-4">
<div class="mt-5 lg:max-w-[30%]">
<h4 class="heading mb-0 font-bold line-clamp-3 hover:line-clamp-none"><a class="link" href="{% url 'apply:projects:detail' project.id %}">{{ project.title }}</a></h4>
<h4 class="heading mb-0 font-bold line-clamp-3 hover:line-clamp-none"><a class="link" href="{{ project.get_absolute_url }}">{{ project.title }}</a></h4>
<p class="m-0 text-fg-muted text-sm">{% trans "Project start date: " %} {{ project.created_at.date }}</p>
</div>
{% project_status_bar project.status request.user css_class="status-bar--small" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<div class="sidebar__inner">
<h5>{% trans "Project" %}</h5>
<p>
<a href="{% url 'apply:projects:detail' pk=object.project.id %}">{{ object.project.title }}</a>
<a href="{{ project.get_absolute_url }}">{{ object.project.title }}</a>
</p>
</div>
12 changes: 11 additions & 1 deletion hypha/apply/projects/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def value(self):
def get_absolute_url(self):
return reverse(
"apply:projects:invoice-detail",
kwargs={"pk": self.project.pk, "invoice_pk": self.pk},
kwargs={"pk": self.project.public_id, "invoice_pk": self.pk},
)

@property
Expand Down Expand Up @@ -354,3 +354,13 @@ def __str__(self):
@property
def filename(self):
return os.path.basename(self.document.name)

def get_absolute_url(self):
return reverse(
"apply:projects:invoice-supporting-document",
kwargs={
"pk": self.invoice.project.public_id,
"invoice_pk": self.invoice.pk,
"file_pk": self.pk,
},
)
11 changes: 9 additions & 2 deletions hypha/apply/projects/models/project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import decimal
import json
import logging
from functools import cached_property

from django import forms
from django.apps import apps
Expand Down Expand Up @@ -381,6 +382,10 @@ def editable_by(self, user):
return True
return False

@cached_property
def public_id(self):
return self.submission.id

@property
def editable(self):
if self.is_locked:
Expand All @@ -392,7 +397,7 @@ def editable(self):
return False

def get_absolute_url(self):
return reverse("apply:projects:detail", args=[self.id])
return reverse("apply:projects:detail", args=[self.public_id])

@property
def can_make_approval(self):
Expand Down Expand Up @@ -619,7 +624,9 @@ def __str__(self):
)

def get_absolute_url(self):
return reverse("apply:projects:contract", args=[self.project.pk, self.pk])
return reverse(
"apply:projects:contract", args=[self.project.public_id, self.pk]
)


class PacketFile(models.Model):
Expand Down
6 changes: 3 additions & 3 deletions hypha/apply/projects/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseInvoiceTable(tables.Table):
invoice_number = tables.LinkColumn(
"funds:projects:invoice-detail",
verbose_name=_("Invoice Number"),
args=[tables.utils.A("project__pk"), tables.utils.A("pk")],
args=[tables.utils.A("project__submission__pk"), tables.utils.A("pk")],
attrs={
"td": {
"class": "js-title", # using title as class because of batch-actions.js
Expand Down Expand Up @@ -114,7 +114,7 @@ class BaseProjectsTable(tables.Table):
title = tables.LinkColumn(
"funds:projects:detail",
text=lambda r: textwrap.shorten(r.title, width=30, placeholder="..."),
args=[tables.utils.A("pk")],
args=[tables.utils.A("submission__pk")],
)
status = tables.Column(
verbose_name=_("Status"), accessor="get_status_display", order_by=("status",)
Expand Down Expand Up @@ -250,7 +250,7 @@ class ReportListTable(tables.Table):
project = tables.LinkColumn(
"funds:projects:reports:detail",
text=lambda r: textwrap.shorten(r.project.title, width=30, placeholder="..."),
args=[tables.utils.A("pk")],
args=[tables.utils.A("submission__pk")],
)
report_period = tables.Column(accessor="pk")
submitted = tables.DateColumn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
</div>
{% if contract_uploaded %}
<div class="docs-block__row-inner">
<a class="font-bold flex items-center w-auto text-start bg-white text-light-blue me-0 mb-1 p-2.5 border-solid border border-light-blue focus:text-light-blue hover:bg-light-blue hover:text-white" href="{% url 'apply:projects:contract' pk=project.pk file_pk=contract.pk %}" target="_blank">
<a class="font-bold flex items-center w-auto text-start bg-white text-light-blue me-0 mb-1 px-3 py-1 border-solid border border-light-blue hover:bg-light-blue hover:text-white focus:ring transition-colors"
href="{{ contract.get_absolute_url }}" target="_blank">
{% heroicon_micro "eye" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "View" %}
</a>
Expand Down Expand Up @@ -159,7 +160,13 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
{% if document_category.required %}<span class="text-red-700">*</span>{% endif %}
{% if document_category.template %}
{% heroicon_mini "information-circle" class="fill-light-blue inline align-middle" aria_hidden=true %}
<a class="font-bold border-b-2 border-dashed" href="{% url 'apply:projects:category_template' pk=object.pk type='contract_document' category_pk=document_category.pk %}" target="_blank">{% trans "View template" %}</a>
<a
class="font-bold border-b-2 border-dashed"
href="{% url 'apply:projects:category_template' pk=object.public_id type='contract_document' category_pk=document_category.pk %}"
target="_blank"
>
{% trans "View template" %}
</a>
{% endif %}
</p>
{% if document_category not in remaining_contract_document_categories %}
Expand All @@ -178,7 +185,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
{% contract_category_latest_file project document_category as latest_file %}
{% if latest_file %}
<div class="docs-block__row-inner">
<a class="docs-block__icon-link" href="{% url 'apply:projects:contract_document' pk=object.pk file_pk=latest_file.pk %}" target="_blank">
<a class="docs-block__icon-link" href="{% url 'apply:projects:contract_document' pk=object.public_id file_pk=latest_file.pk %}" target="_blank">
{% heroicon_micro "eye" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "View" %}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h5>{% trans "Deliverables" %}</h5>
<div id="list-deliverables">
<div class="deliverables">
{% for deliverable in invoice.deliverables.all %}
<b>{{ deliverable.deliverable.name }} ({{ deliverable.quantity }} {{ deliverable.deliverable.unit_price|format_number_as_currency }})</b>{% if user_can_edit_deliverables %}<a href="{% url "api:v1:remove-deliverables" pk=deliverable.pk invoice_pk=invoice.pk project_pk=project.pk %}"> {% trans "Remove" %}</a>{% endif %}<br>
<b>{{ deliverable.deliverable.name }} ({{ deliverable.quantity }} {{ deliverable.deliverable.unit_price|format_number_as_currency }})</b>{% if user_can_edit_deliverables %}<a href="{% url "api:v1:remove-deliverables" pk=deliverable.pk invoice_pk=invoice.pk project_pk=project.public_id %}"> {% trans "Remove" %}</a>{% endif %}<br>
{% endfor %}
</div>
{% if invoice.deliverables_total_amount.total %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% user_can_add_invoices object user as can_add_invoice %}
{% if can_add_invoice %}
<a class="button button--project-action button--project-action--white" target="_blank"
href="{% url "apply:projects:invoice" pk=object.pk %}">
href="{% url "apply:projects:invoice" pk=object.submission.pk %}">
{% trans "Add Invoice" %}
</a>
{% endif %}
Expand Down Expand Up @@ -36,15 +36,15 @@
</a>
{% can_edit invoice user as user_can_edit_request %}
{% if user_can_edit_request %}
<a class="data-block__action-icon-link" href="{% url "apply:projects:invoice-edit" pk=invoice.project.pk invoice_pk=invoice.pk %}">
<a class="data-block__action-icon-link" href="{% url "apply:projects:invoice-edit" pk=invoice.project.public_id invoice_pk=invoice.pk %}">
{% heroicon_micro "pencil-square" aria_hidden=true class="me-1" %}
{% trans "Edit" %}
</a>
{% endif %}

{% can_delete invoice user as user_can_delete_request %}
{% if user.is_applicant and user_can_delete_request %}
<a class="data-block__action-icon-link text-red-500" href="{% url 'apply:projects:invoice-delete' pk=invoice.project.pk invoice_pk=invoice.pk %}">
<a class="data-block__action-icon-link text-red-500" href="{% url 'apply:projects:invoice-delete' pk=invoice.project.public_id invoice_pk=invoice.pk %}">
{% heroicon_micro "trash" aria_hidden=true class="me-1" %}
{% trans "Delete" %}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h2 class="text-lg font-semibold m-0">
</div>
<div class="docs-block__row-inner">
{% if editable %}
<a class="{% if not project.vendor.user_has_updated_details %}button button--project-action{% else %}docs-block__icon-link{% endif %}" href="{% url 'apply:projects:vendor' pk=project.pk %}">
<a class="{% if not project.vendor.user_has_updated_details %}button button--project-action{% else %}docs-block__icon-link{% endif %}" href="{% url 'apply:projects:vendor' pk=project.public_id %}">
{% if project.vendor.user_has_updated_details %}
{% heroicon_micro "pencil-square" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "Edit" %}
Expand All @@ -107,7 +107,7 @@ <h2 class="text-lg font-semibold m-0">
</a>
{% endif %}
{% if project.vendor.user_has_updated_details %}
<a class="docs-block__icon-link" href="{% url 'apply:projects:vendor-detail' pk=project.pk vendor_pk=project.vendor.pk %}">
<a class="docs-block__icon-link" href="{% url 'apply:projects:vendor-detail' pk=project.public_id vendor_pk=project.vendor.pk %}">
{% heroicon_micro "eye" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "View" %}
</a>
Expand All @@ -127,7 +127,10 @@ <h2 class="text-lg font-semibold m-0">
</div>
<div class="docs-block__row-inner">
{% if editable and not user.is_applicant %}
<a class="{% if not object.user_has_updated_details %}button button--project-action{% else %}docs-block__icon-link{% endif %}" href="{% url 'apply:projects:edit' pk=object.pk %}">
<a
class="{% if not object.user_has_updated_details %}button button--project-action{% else %}docs-block__icon-link{% endif %}"
href="{% url 'apply:projects:edit' pk=object.public_id %}"
>
{% if object.user_has_updated_details %}
{% heroicon_micro "pencil-square" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "Edit" %}
Expand All @@ -137,7 +140,7 @@ <h2 class="text-lg font-semibold m-0">
</a>
{% endif %}
{% if object.user_has_updated_details and not user.is_applicant %}
<a class="docs-block__icon-link" href="{% url 'apply:projects:approval' pk=project.pk %}">
<a class="docs-block__icon-link" href="{% url 'apply:projects:approval' pk=project.public_id %}">
{% heroicon_micro "eye" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "View" %}
</a>
Expand All @@ -151,7 +154,7 @@ <h2 class="text-lg font-semibold m-0">
<p class="docs-block__document-info">{% trans "Scope of work (SOW)" %}</p>
</div>
<div class="docs-block__document-inner__actions">
<a class="docs-block__icon-link" href="{% url 'apply:projects:sow' pk=project.pk %}">
<a class="docs-block__icon-link" href="{% url 'apply:projects:sow' pk=project.public_id %}">
{% heroicon_micro "eye" class="inline me-1 w-4 h-4" aria_hidden=true %}
{% trans "View" %}
</a>
Expand Down Expand Up @@ -184,7 +187,7 @@ <h2 class="text-lg font-semibold m-0">
{% if document_category.required %}<span class="text-red-700">*</span>{% endif %}
{% if document_category.template %}
<a class="font-bold hover:opacity-70 transition-opacity"
href="{% url 'apply:projects:category_template' pk=object.pk type='project_document' category_pk=document_category.pk %}"
href="{% url 'apply:projects:category_template' pk=object.public_id type='project_document' category_pk=document_category.pk %}"
target="_blank"
>
<span class="border-b-2 border-dashed">
Expand Down Expand Up @@ -214,7 +217,7 @@ <h2 class="text-lg font-semibold m-0">
{% category_latest_file project document_category as latest_file %}
{% if latest_file %}
<div class="docs-block__row-inner">
<a class="docs-block__icon-link" href="{% url 'apply:projects:document' pk=object.pk file_pk=latest_file.pk %}" target="_blank">
<a class="docs-block__icon-link" href="{% url 'apply:projects:document' pk=object.public_id file_pk=latest_file.pk %}" target="_blank">
{% heroicon_micro "eye" class="inline me-1" aria_hidden=true %}
{% trans "View" %}
</a>
Expand Down
Loading
Loading