From 60484d9de80bf20bdc40d8ab8b45cf6e13372e08 Mon Sep 17 00:00:00 2001 From: Sandeep Chauhan Date: Fri, 1 Nov 2024 00:30:58 +0530 Subject: [PATCH] Remove Fancybox modal for PAF workflow (#4160) Fixes #4124 - [ ] Use htmx/alpine for supporting documents upload/remove - [ ] Use htmx/alpine for Send for approval modal - [ ] Use htmx/alpine for Assign paf approvers modal - [ ] Use htmx/alpine for Change paf approvers modal - [ ] Use htmx/alpine for View/Update paf approvers modal - [ ] Use htmx/alpine for Update Paf status modal - [ ] Use htmx/alpine for Skip paf approval modal --- hypha/apply/projects/forms/__init__.py | 2 - hypha/apply/projects/forms/project.py | 20 +- hypha/apply/projects/models/project.py | 13 - .../includes/project_documents.html | 161 +++ .../includes/supporting_documents.html | 308 ----- .../modals/assign_pafapprovers.html | 13 + .../modals/pafstatus_update.html | 7 + .../modals/send_for_approval.html | 38 + .../modals/supporting_documents_upload.html | 14 + .../modals/update_pafapprovers.html | 15 + .../partials/supporting_documents.html | 82 ++ .../project_admin_detail.html | 14 +- .../project_approval_detail.html | 45 +- .../application_projects/project_detail.html | 2 +- hypha/apply/projects/tests/test_views.py | 32 +- hypha/apply/projects/urls.py | 46 + hypha/apply/projects/views/__init__.py | 10 + hypha/apply/projects/views/project.py | 1102 ++++++++++------- .../apply/projects/views/project_partials.py | 18 +- 19 files changed, 1084 insertions(+), 858 deletions(-) create mode 100644 hypha/apply/projects/templates/application_projects/includes/project_documents.html delete mode 100644 hypha/apply/projects/templates/application_projects/includes/supporting_documents.html create mode 100644 hypha/apply/projects/templates/application_projects/modals/assign_pafapprovers.html create mode 100644 hypha/apply/projects/templates/application_projects/modals/pafstatus_update.html create mode 100644 hypha/apply/projects/templates/application_projects/modals/send_for_approval.html create mode 100644 hypha/apply/projects/templates/application_projects/modals/supporting_documents_upload.html create mode 100644 hypha/apply/projects/templates/application_projects/modals/update_pafapprovers.html create mode 100644 hypha/apply/projects/templates/application_projects/partials/supporting_documents.html diff --git a/hypha/apply/projects/forms/__init__.py b/hypha/apply/projects/forms/__init__.py index cd9736dc6d..239b1fa12c 100644 --- a/hypha/apply/projects/forms/__init__.py +++ b/hypha/apply/projects/forms/__init__.py @@ -15,7 +15,6 @@ ProjectForm, ProjectSOWForm, RemoveContractDocumentForm, - RemoveDocumentForm, SetPendingForm, SkipPAFApprovalProcessForm, StaffUploadContractForm, @@ -42,7 +41,6 @@ "ProjectCreateForm", "ProjectForm", "ProjectSOWForm", - "RemoveDocumentForm", "RemoveContractDocumentForm", "SetPendingForm", "UploadContractForm", diff --git a/hypha/apply/projects/forms/project.py b/hypha/apply/projects/forms/project.py index e67b602a72..eb3da00094 100644 --- a/hypha/apply/projects/forms/project.py +++ b/hypha/apply/projects/forms/project.py @@ -193,7 +193,7 @@ class Meta: fields = ["paf_status", "comment"] model = Project - def __init__(self, instance, user, *args, **kwargs): + def __init__(self, *args, user=None, instance=None, **kwargs): super().__init__(*args, **kwargs, instance=instance) self.fields["paf_status"].widget.attrs["class"] = "grid--status-update" @@ -217,17 +217,6 @@ def __init__(self, instance, user, *args, **kwargs): status_field.choices = possible_status_transitions.get(instance.status, []) -class RemoveDocumentForm(forms.ModelForm): - id = forms.IntegerField(widget=forms.HiddenInput()) - - class Meta: - fields = ["id"] - model = PacketFile - - def __init__(self, user=None, *args, **kwargs): - super().__init__(*args, **kwargs) - - class RemoveContractDocumentForm(forms.ModelForm): id = forms.IntegerField(widget=forms.HiddenInput()) @@ -245,7 +234,7 @@ class Meta: model = Project widgets = {"id": forms.HiddenInput()} - def __init__(self, user=None, *args, **kwargs): + def __init__(self, *args, user=None, **kwargs): from hypha.apply.activity.adapters.utils import get_users_for_groups super().__init__(*args, **kwargs) @@ -308,7 +297,7 @@ class Meta: model = Project widgets = {"id": forms.HiddenInput()} - def __init__(self, user=None, *args, **kwargs): + def __init__(self, *args, user=None, **kwargs): from hypha.apply.activity.adapters.utils import get_users_for_groups super().__init__(*args, **kwargs) @@ -400,8 +389,9 @@ class UploadDocumentForm(FileFormMixin, forms.ModelForm): class Meta: fields = ["category", "document"] model = PacketFile + widgets = {"category": forms.HiddenInput()} - def __init__(self, user=None, instance=None, *args, **kwargs): + def __init__(self, *args, user=None, instance=None, **kwargs): super().__init__(*args, **kwargs) def save(self, commit=True): diff --git a/hypha/apply/projects/models/project.py b/hypha/apply/projects/models/project.py index 6c99e6ea95..f525056b4e 100644 --- a/hypha/apply/projects/models/project.py +++ b/hypha/apply/projects/models/project.py @@ -623,19 +623,6 @@ def __str__(self): class Meta: ordering = ("-created_at",) - def get_remove_form(self): - """ - Get an instantiated RemoveDocumentForm with this class as `instance`. - - This allows us to build instances of the RemoveDocumentForm for each - instance of PacketFile in the supporting documents template. The - standard Delegated View flow makes it difficult to create these forms - in the view or template. - """ - from ..forms import RemoveDocumentForm - - return RemoveDocumentForm(instance=self) - @receiver(post_delete, sender=PacketFile) def delete_packetfile_file(sender, instance, **kwargs): diff --git a/hypha/apply/projects/templates/application_projects/includes/project_documents.html b/hypha/apply/projects/templates/application_projects/includes/project_documents.html new file mode 100644 index 0000000000..5596e16766 --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/includes/project_documents.html @@ -0,0 +1,161 @@ +{% load i18n approval_tools project_tags heroicons %} +{% allow_collapsible_header object header_type='project_documents' as collapsible_header %} + +
+
+
+

+ {% trans "Project documents" %} +

+ + {% if collapsible_header %} + + {% endif %} +
+
+ {% user_can_send_for_approval object user as can_send_to_approve %} + {% if can_send_to_approve %} + + {% if object.paf_approvals.exists %} + {% trans "Resubmit for approval" %} + {% else %} + {% trans "Submit for approval" %} + {% endif %} + + {% endif %} + {% user_can_update_paf_approvers object user request as can_update_paf_approvers %} + {% user_can_assign_approvers_to_project object user request as can_assign_paf_approvers %} + {% if can_update_paf_approvers %} + {% if user == project.lead %} + + {% trans "View/Update Approvers" %} + + {% else %} + + {% trans "Change approver" %} + + {% endif %} + {% endif %} + {% if can_assign_paf_approvers %} + + {% trans "Assign approver" %} + + {% endif %} + {% user_can_update_paf_status object user request=request as can_update_paf_status %} + {% if object.can_make_approval and can_update_paf_status %} + + {% trans "Update Status" %} + + {% endif %} +
+
+ +
+ + +{% if can_update_paf_status %} + +{% endif %} diff --git a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html b/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html deleted file mode 100644 index fb8fee5058..0000000000 --- a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html +++ /dev/null @@ -1,308 +0,0 @@ -{% load i18n approval_tools project_tags heroicons %} -{% allow_collapsible_header object header_type='project_documents' as collapsible_header %} - -
-
-
-

- {% trans "Project documents" %} -

- - {% if collapsible_header %} - - {% endif %} -
-
- {% user_can_send_for_approval object user as can_send_to_approve %} - {% if can_send_to_approve %} - - {% if object.paf_approvals.exists %} - {% trans "Resubmit for approval" %} - {% else %} - {% trans "Submit for approval" %} - {% endif %} - - {% endif %} - {% user_can_update_paf_approvers object user request as can_update_paf_approvers %} - {% user_can_assign_approvers_to_project object user request as can_assign_paf_approvers %} - {% if can_update_paf_approvers %} - {% if user == project.lead %} - - {% trans "View/Update Approvers" %} - - {% else %} - - {% trans "Change approver" %} - - {% endif %} - {% endif %} - {% if can_assign_paf_approvers %} - - {% trans "Assign approver" %} - - {% endif %} - {% user_can_update_paf_status object user request=request as can_update_paf_status %} - {% if object.can_make_approval and can_update_paf_status %} - - {% trans "Update Status" %} - - {% endif %} -
-
- -
- -{% if user.is_apply_staff %} - -{% endif %} - -{% if can_send_to_approve %} - -{% endif %} - -{% if can_update_paf_approvers %} - - - - -{% endif %} - -{% if can_assign_paf_approvers %} - -{% endif %} - -{% if can_update_paf_status %} - -{% endif %} diff --git a/hypha/apply/projects/templates/application_projects/modals/assign_pafapprovers.html b/hypha/apply/projects/templates/application_projects/modals/assign_pafapprovers.html new file mode 100644 index 0000000000..35b83fbecd --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/modals/assign_pafapprovers.html @@ -0,0 +1,13 @@ +{% load i18n %} +{% if pafapprover_exists %} + {% modal_title %}{% trans "Assign Approver" %}{% endmodal_title %} +{% else %} + {% modal_title %}{% trans "Change Approver" %}{% endmodal_title %} +{% endif %} + +
+

{% trans "Selected approver will be notified. On unselecting, every listed member here will be notified." %}

+ + {% url 'apply:projects:assign_pafapprovers' pk=object.id as url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=url %} +
diff --git a/hypha/apply/projects/templates/application_projects/modals/pafstatus_update.html b/hypha/apply/projects/templates/application_projects/modals/pafstatus_update.html new file mode 100644 index 0000000000..3283c5325a --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/modals/pafstatus_update.html @@ -0,0 +1,7 @@ +{% load i18n project_tags %} +{% modal_title %}{% trans "Update Project Form Status" %}{% endmodal_title %} + +
+ {% url 'apply:projects:update_pafapprovers' pk=object.id as url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=url %} +
diff --git a/hypha/apply/projects/templates/application_projects/modals/send_for_approval.html b/hypha/apply/projects/templates/application_projects/modals/send_for_approval.html new file mode 100644 index 0000000000..624e3c1e64 --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/modals/send_for_approval.html @@ -0,0 +1,38 @@ +{% load i18n approval_tools project_tags heroicons %} +{% modal_title %}{% trans "Submit for Approval" %}{% endmodal_title %} + +
+ {% if remaining_document_categories %} +
{% trans "Are you sure you're ready to submit the project documents to be approved in" %} + {% if project_settings.paf_approval_sequential %}{% trans "sequential order?" %}{% else %}{% trans "parallel order?" %}{% endif %}
+ +

{% trans "This project is missing the following documents" %}:

+ + + {% trans "Submit anyway" as submit %} + {% else %} +
{% trans "Are you ready to submit the project documents to be approved in" %} + {% if project_settings.paf_approval_sequential %}{% trans "sequential order?" %}{% else %}{% trans "parallel order?" %}{% endif %}
+ {% trans "Submit" as submit %} + {% endif %} + {% if project_settings.paf_reviewers_roles.all %} + +

{% trans "By default all the members are notified when an approver is not selected. Optionally, you may select specific approvers to assign and notify them." %}

+
+

{% trans "Optional" %}

+

+
+ +

{% trans "Please note that in "%}{% if project_settings.paf_approval_sequential %}{%trans "sequential order, approvers will approve PAF one after the other."%}{% else %}{% trans "parallel order, approvers can approve PAF anytime." %}{% endif %}

+ {% url 'apply:projects:submit_project_for_approval' pk=object.id as document_submit_url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=submit url=document_submit_url %} + {% else %} +

{% trans "No PAF Reviewer Roles created yet, please create these in " %} + {% trans " project settings" %} +

+ {% endif %} +
diff --git a/hypha/apply/projects/templates/application_projects/modals/supporting_documents_upload.html b/hypha/apply/projects/templates/application_projects/modals/supporting_documents_upload.html new file mode 100644 index 0000000000..b57a09d96c --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/modals/supporting_documents_upload.html @@ -0,0 +1,14 @@ +{% load i18n %} +{% modal_title %}{% trans "Upload Supporting Documents" %}{% endmodal_title %} + +
+
+
+
{% trans "Category" %}
+
{{ category }}
+
+
+ + {% url 'apply:projects:supporting_doc_upload' pk=object.id category_pk=category.id as document_upload_url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=document_upload_url %} +
diff --git a/hypha/apply/projects/templates/application_projects/modals/update_pafapprovers.html b/hypha/apply/projects/templates/application_projects/modals/update_pafapprovers.html new file mode 100644 index 0000000000..efc515a4e9 --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/modals/update_pafapprovers.html @@ -0,0 +1,15 @@ +{% load i18n project_tags %} +{% modal_title %}{% trans "View/Update Approvers" %}{% endmodal_title %} + +
+ {% if project_settings.paf_reviewers_roles.all %} +

{% trans "Are you sure you want to update the approvers?" %} {% if project_settings.paf_approval_sequential %} {% trans "The uppermost active approver will be notified via email." %} {% else %}{% trans "All approvers will be notified via email." %}{% endif %}

+
+ {% url 'apply:projects:update_pafapprovers' pk=object.id as url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=url %} + {% else %} +

{% trans "No PAF Reviewer Roles created yet, please create these in " %} + {% trans " project settings" %} +

+ {% endif %} +
diff --git a/hypha/apply/projects/templates/application_projects/partials/supporting_documents.html b/hypha/apply/projects/templates/application_projects/partials/supporting_documents.html new file mode 100644 index 0000000000..b639d6026b --- /dev/null +++ b/hypha/apply/projects/templates/application_projects/partials/supporting_documents.html @@ -0,0 +1,82 @@ +{% load i18n approval_tools project_tags heroicons %} + +
  • +
    + {% if remaining_document_categories %} + {% heroicon_outline "check-circle" class="stroke-gray-400 me-1" aria_hidden=true %} + {% else %} + {% heroicon_outline "check-circle" class="stroke-light-blue me-1" aria_hidden=true %} + {% endif %} +

    {% trans "Supporting documents" %}

    +
    + + {% if all_document_categories %} + +
    +

    + +
    + {% endif %} + +
  • diff --git a/hypha/apply/projects/templates/application_projects/project_admin_detail.html b/hypha/apply/projects/templates/application_projects/project_admin_detail.html index 66d4f9ab26..d0dbaa6396 100644 --- a/hypha/apply/projects/templates/application_projects/project_admin_detail.html +++ b/hypha/apply/projects/templates/application_projects/project_admin_detail.html @@ -12,14 +12,12 @@
    {% trans "Actions to take" %}
    {% user_can_skip_pafapproval_process project user as can_skip_paf %} {% if can_skip_paf %} - {% trans "Continue to next status" %} - - + + {% trans "Continue to next status" %} + {% else %}
    diff --git a/hypha/apply/projects/templates/application_projects/project_approval_detail.html b/hypha/apply/projects/templates/application_projects/project_approval_detail.html index 64d785f888..27ee4d2505 100644 --- a/hypha/apply/projects/templates/application_projects/project_approval_detail.html +++ b/hypha/apply/projects/templates/application_projects/project_approval_detail.html @@ -104,8 +104,8 @@
    {% trans "Actions to take" %}
    {% if can_edit_paf %} {% trans "Edit PAF" %} {% endif %} -