Skip to content

Commit

Permalink
Projects Refinements (#3356)
Browse files Browse the repository at this point in the history
Fixes #3333 
Fixes #3352 
FIxes retesting issues of #3331
  • Loading branch information
sandeepsajan0 authored May 2, 2023
1 parent a8003a4 commit cf73d75
Show file tree
Hide file tree
Showing 23 changed files with 228 additions and 82 deletions.
2 changes: 1 addition & 1 deletion hypha/apply/funds/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def render_answer(self, field_id, include_question=False):
data = self.data(field_id)
# Some migrated content have empty address.
if not data:
return '-'
return field.render(context={'data': '', 'include_question': include_question})
return field.render(context={'data': data, 'include_question': include_question})

def render_answers(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<form
class="form {{ extra_classes }}"
method="post"
id="{{ form.name }}"
id="{% if form_id %}{{ form_id }}{% else %}{{ form.name }}{% endif %}"
enctype="multipart/form-data"
{% if action %}action="{{ action }}"{% endif %}
>
Expand Down Expand Up @@ -36,7 +36,7 @@
id="{{ form.name }}-submit"
name="{{ form_prefix }}{{ form.name }}"
type="submit"
form="{{ form.name }}">
form="{% if form_id %}{{ form_id }}{% else %}{{ form.name }}{% endif %}">
{{ value }}
</button>

Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/projects/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def vendor_document_number(self):
return prefix + '-'.join(wrap(f"{self.id:06}", 3))

def can_user_delete(self, user):
if user.is_applicant or user.is_apply_staff or user.is_finance_level_1 or user.is_finance_level_2 or user.is_contracting:
if user.is_applicant or user.is_apply_staff:
if self.status in (SUBMITTED):
return True

Expand Down
5 changes: 5 additions & 0 deletions hypha/apply/projects/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .models.project import (
CLOSING,
COMMITTED,
COMPLETE,
CONTRACTING,
IN_PROGRESS,
Expand Down Expand Up @@ -169,6 +170,10 @@ def can_access_project(user, project):
if user.is_applicant and user == project.user:
return True, 'Applicant(project user) can view project in all statuses'

if project.status in [COMMITTED, WAITING_FOR_APPROVAL] and project.paf_approvals.exists() and \
user.id in project.paf_approvals.all().values_list('user', flat=True):
return True, 'PAF Approvers can access the project in Committed and Approval state'

return False, 'Forbidden Error'


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% load i18n contract_tools project_tags %}
{% allow_collapsible_header object header_type='contracting_documents' as collapsible_header %}

<div class="docs-block wrapper--outer-space-large" {% if collapsible_header %} x-data="{ collapsed: false }" {% endif %}>
<div class="docs-block__header" {% if collapsible_header %} x-on:click="collapsed = ! collapsed" {% endif %}>
<div class="docs-block__heading" >{% trans "Contracting documents" %}</div>
<div class="docs-block wrapper--outer-space-large" {% if collapsible_header %} x-data="{ collapsed: true }" {% endif %}>
<div class="docs-block__header" id="contract-documents-section" {% if collapsible_header %} x-on:click="collapsed = ! collapsed" role="button" aria-label="Toggle Contract documents visibility" aria-controls="contract-documents-elements" {% endif %}>
<div class="docs-block__heading" >{% trans "Contracting documents" %}
{% if collapsible_header %}
<svg class="icon icon--caret-up" x-show="!collapsed" aria-hidden=true><use xlink:href="#caret-up"></use></svg>
<svg class="icon icon--caret-down" x-show="collapsed" aria-hidden=true><use xlink:href="#caret-down"></use></svg>
{% endif %}
</div>
{% user_can_upload_contract object request.user as can_upload_contract %}
{% user_can_submit_contract object user contract as can_submit_contract %}
{% if can_submit_contract %}
Expand Down Expand Up @@ -33,7 +38,8 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
{% endif %}
</div>

<ul class="docs-block__inner" {% if collapsible_header %} x-show="collapsed" {% endif %}>
<ul class="docs-block__inner" id="contract-documents-elements" {% if collapsible_header %} x-show="!collapsed" role="region"
aria-labelledby="contract-documents-section" {% endif %}>

{% is_project_contract_approved object as is_contract_approved %}
{% contract_uploaded_by_contracting object as contract_uploaded %}
Expand All @@ -50,7 +56,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
</a>
</div>
{% if contract.updated_at %}
<ul class="docs-block__document-list" style="margin-top:0;">
<ul class="mt-0 w-full pl-9">
<li class="docs-block__document">
<div class="docs-block__row-inner">
</div>
Expand All @@ -61,7 +67,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
</ul>
{% endif %}
{% if not is_contract_approved %}
<ul class="docs-block__document-list" style="margin-top:0;">
<ul class="mt-0 w-full pl-9">
<li class="docs-block__document">
<div class="docs-block__row-inner">
</div>
Expand All @@ -88,7 +94,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
</div>
{% if can_upload_contract and user.is_contracting %}
<div class="docs-block__row-inner docs-block__row-inner__contract-upload-row">
<a data-fancybox class="docs-block__icon-link button--project-action" style="padding:5px" href="#" data-src="#upload-contract">
<a data-fancybox class="font-bold flex items-center w-auto text-left bg-light-blue text-white mr-0 p-2.5 border-none" href="#" data-src="#upload-contract">
<svg class="icon icon--arrow-up-short-bar icon--arrow-up-short-bar--contract-upload"><use xlink:href="#arrow-up-short-bar"></use></svg>
{% if not contract %}
{% trans "Upload" %}
Expand All @@ -108,7 +114,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
</div>
{% if can_upload_contract and user.is_applicant %}
<div class="docs-block__row-inner docs-block__row-inner__contract-upload-row">
<a data-fancybox class="docs-block__icon-link button--project-action" style="padding:5px" href="#" data-src="#upload-contract">
<a data-fancybox class="font-bold flex items-center w-auto text-left bg-light-blue text-white mr-0 p-2.5 border-none" href="#" data-src="#upload-contract">
<svg class="icon icon--arrow-up-short-bar icon--arrow-up-short-bar--contract-upload"><use xlink:href="#arrow-up-short-bar"></use></svg>
{% if not contract.signed_by_applicant %}
{% trans "Upload" %}
Expand All @@ -134,7 +140,7 @@ <h5> {% trans "Are you sure you want to submit contracting documents?" %}</h5>
{% can_update_contracting_documents object user as can_update_documents %}
{% if can_update_documents %}
<div class="docs-block__row-inner">
<a data-fancybox data-src="#upload-contracting-doc" class="docs-block__icon-link" style="margin-right:0;" href="#">
<a data-fancybox data-src="#upload-contracting-doc" class="font-bold flex items-center mr-0" href="#">
<svg class="icon icon--arrow-up-short-bar"><use xlink:href="#arrow-up-short-bar"></use></svg>
{% trans "Upload new" %}
</a>
Expand All @@ -147,7 +153,7 @@ <h4 class="modal__project-header-bar">{% trans "Upload contracting documents" %}
</div>
{% endif %}
{% if remaining_contract_document_categories %}
<ul class="docs-block__document-list" style="padding-left:2.25rem;">
<ul class="mt-4 w-full pl-9">
<li class="docs-block__document">
<div class="docs-block__document-inner">
<p>
Expand All @@ -164,7 +170,7 @@ <h4 class="modal__project-header-bar">{% trans "Upload contracting documents" %}
{% endif %}

{% if object.contract_packet_files.exists %}
<ul class="docs-block__document-list" style="padding-left:2.25rem;">
<ul class="mt-4 w-full pl-9">
{% for document in object.contract_packet_files.all %}
<li class="docs-block__document">
<div class="docs-block__document-inner">
Expand All @@ -178,7 +184,7 @@ <h4 class="modal__project-header-bar">{% trans "Upload contracting documents" %}
</a>
{% if can_update_documents %}
<form method="POST" id="{{ remove_contract_document_form.name }}" class="docs-block__icon-link">
<svg class="icon icon--delete" style="margin-left:0; margin-right:2px"><use xlink:href="#delete"></use></svg>
<svg class="w-4 h-4 inline-block fill-tomato mr-0.5 ml-0"><use xlink:href="#delete"></use></svg>
{% csrf_token %}
{{ document.get_remove_form }}
<input
Expand Down Expand Up @@ -207,12 +213,13 @@ <h4 class="modal__project-header-bar">{% trans "Upload contracting documents" %}
<div class="modal" id="upload-contract">
{% if user.is_applicant %}
<h4 class="modal__project-header-bar">{% trans "Upload Countersigned Contract" %}</h4>
{% trans "Upload" as upload %}
{% else %}
<h4 class="modal__project-header-bar">{% trans "Upload Signed Contract" %}</h4>
<p><i><b>{% trans "The signed contract will be sent to Applicant once you submit." %}</b></i></p>
<br>
{% trans "Submit" as upload %}
{% endif %}
<p><i><b>{% trans "The signed contract will be uploaded once you submit." %}</b></i></p>
<br>
{% trans "Submit" as upload %}
{% include 'funds/includes/delegated_form_base.html' with form=contract_form value=upload %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p class="data-block__title">{% trans "Invoices" %}</p>
{% user_can_add_invoices object user as can_add_invoice %}
{% if can_add_invoice %}
<a class="button button--project-action"
<a class="button button--project-action button--project-action--white" target="_blank"
href="{% url "apply:projects:invoice" pk=object.pk %}">
{% trans "Add Invoice" %}
</a>
Expand All @@ -15,38 +15,58 @@
<table class="data-block__table">
<thead>
<tr>
<th class="data-block__table-amount">{% trans "Submitted" %}</th>
<th class="data-block__table-status">{% trans "Invoice Number" %}</th>
<th class="data-block__table-date">{% trans "Status" %}</th>
<th class="data-block__table-date">{% trans "Submitted" %}</th>
<th class="data-block__table-amount">{% trans "Invoice Number" %}</th>
<th class="data-block__table-status">{% trans "Status" %}</th>
<th class="data-block__table-update"></th>
</tr>
</thead>
<tbody>
{% for invoice in object.invoices.not_rejected %}
<tr>
<td><span class="data-block__mobile-label">{% trans "Submitted" %}: </span>{{ invoice.requested_at.date }}</td>
<td><span class="data-block__mobile-label">{% trans "Invoice Number" %}: </span>{{ invoice.vendor_document_number }}</td>
<td><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td>
<td style="display:flex; flex-wrap:wrap;">
<a class="data-block__action-icon-link" href="{{ invoice.get_absolute_url }}">
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Submitted" %}: </span>{{ invoice.requested_at.date }}</td>
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Invoice Number" %}: </span>{{ invoice.vendor_document_number }}</td>
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td>
<td class="flex flex-wrap justify-end py-4 px-0">
<a class="data-block__action-icon-link" href="{{ invoice.get_absolute_url }}" target="_blank">
<svg class="icon icon--project-eye"><use xlink:href="#eye"></use></svg>
{% trans "View" %}
</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" target="_blank" href="{% url "apply:projects:invoice-edit" pk=invoice.project.pk invoice_pk=invoice.pk %}">
<svg class="icon icon--project-pen"><use xlink:href="#pen"></use></svg>
{% trans "Edit" %}
</a>
{% endif %}

{% can_delete invoice user as user_can_delete_request %}
{% if user_can_delete_request %}
<a class="data-block__action-icon-link data-block__action-icon-link--remove" href="{% url 'apply:projects:invoice-delete' pk=invoice.project.pk invoice_pk=invoice.pk %}">
{% if user.is_applicant and user_can_delete_request %}
<a class="data-block__action-icon-link data-block__action-icon-link--remove" target="_blank" href="{% url 'apply:projects:invoice-delete' pk=invoice.project.pk invoice_pk=invoice.pk %}">
<svg class="icon icon--delete" style="margin-left:0; margin-right:2px"><use xlink:href="#delete"></use></svg>
{% trans "Delete" %}
</a>
{% endif %}
{% can_change_status invoice user as can_change_invoice_status %}
{% if can_change_invoice_status %}
<a
data-fancybox
data-src="#change-invoice-status-{{ invoice.id }}"
id="update_invoice_status-{{ invoice.id }}"
class="data-block__button button button--primary"
href="#"
>
{% trans "Update Status" %}
</a>
<div class="modal" id="change-invoice-status-{{ invoice.id }}">
{% get_invoice_form invoice user as invoice_form %}
{% get_invoice_form_id invoice_form invoice as invoice_form_id %}
<h4 class="modal__project-header-bar">{% trans "Update Invoice status" %}</h4>
<p>{% trans "Current status" %}: {{ invoice.get_status_display }}</p>
{% trans "Update Status" as update %}
{% include 'funds/includes/delegated_form_base.html' with form=invoice_form value=update action=invoice.get_absolute_url form_id=invoice_form_id %}
</div>
{% endif %}
</td>
</tr>
{% empty %}
Expand All @@ -65,19 +85,24 @@
<table class="data-block__table is-hidden js-payment-block-rejected-table">
<thead>
<tr>
<th class="data-block__table-amount">{% trans "Submitted" %}</th>
<th class="data-block__table-date">{% trans "Submitted" %}</th>
<th class="data-block__table-amount">{% trans "Invoice Number" %}</th>
<th class="data-block__table-status">{% trans "Status" %}</th>
<th class="data-block__table-view"></th>
<th class="data-block__table-update"></th>
</tr>
</thead>
<tbody>
{% for invoice in object.invoices.rejected %}
<tr>
<td><span class="data-block__mobile-label">{% trans "Submitted" %}: </span>{{ invoice.requested_at.date }}</td>
<td><span class="data-block__mobile-label">{% trans "Invoice Number" %}: </span>{{ invoice.vendor_document_number }}</td>
<td><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td>
<td><a href="{{ invoice.get_absolute_url }}">{% trans "View" %}</a></td>
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Submitted" %}: </span>{{ invoice.requested_at.date }}</td>
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Invoice Number" %}: </span>{{ invoice.vendor_document_number }}</td>
<td class="py-4 px-2.5"><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td>
<td class="flex justify-end py-4 px-0">
<a class="data-block__action-icon-link" href="{{ invoice.get_absolute_url }}" target="_blank">
<svg class="icon icon--project-eye"><use xlink:href="#eye"></use></svg>
{% trans "View" %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<tbody>
{% for report in object.reports.done %}
<tr {% if forloop.counter > 8 %}class="is-hidden"{% endif %}>
<td>
<td class="py-4 px-2.5">
<span class="data-block__mobile-label">{% trans "Period End" %}: </span>{{ report.end_date }}
</td>
<td>
<td class="py-4 px-2.5">
<span class="data-block__mobile-label">{% trans "Submitted" %}: </span>{{ report.submitted_date|default:"Skipped" }}
</td>
<td class="data-block__links">
Expand Down
Loading

0 comments on commit cf73d75

Please sign in to comment.