From 200217405692408057cab951e422d263383158f9 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Tue, 3 Sep 2024 17:48:06 +0200 Subject: [PATCH 1/5] Update Django to 4.2.16. (#4123) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 011039c573..b0df8fddcb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,7 +31,7 @@ django-tables2==2.7.0 django-tinymce==4.1.0 django-two-factor-auth==1.16.0 django-web-components==0.2.0 -django==4.2.15 +django==4.2.16 djangorestframework-api-key==3.0.0 djangorestframework==3.15.2 drf-nested-routers==0.93.5 From 8341f07967dcf453b69d63fb3c9f03a513093719 Mon Sep 17 00:00:00 2001 From: Sandeep Chauhan Date: Thu, 5 Sep 2024 00:10:09 +0530 Subject: [PATCH 2/5] Set signed by applicant true when submit and approved (#4105) Fixes #4048 --- hypha/apply/projects/views/project.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hypha/apply/projects/views/project.py b/hypha/apply/projects/views/project.py index 1201717019..2b51085e4c 100644 --- a/hypha/apply/projects/views/project.py +++ b/hypha/apply/projects/views/project.py @@ -591,8 +591,14 @@ def form_valid(self, form): form.instance.approver = self.request.user form.instance.approved_at = timezone.now() form.instance.signed_and_approved = contract_signed_and_approved + form.instance.signed_by_applicant = True form.instance.save( - update_fields=["approver", "approved_at", "signed_and_approved"] + update_fields=[ + "approver", + "approved_at", + "signed_and_approved", + "signed_by_applicant", + ] ) project.status = INVOICING_AND_REPORTING From ce387f1fb97f1b47602c3f55bbeb9cfb35cd72c2 Mon Sep 17 00:00:00 2001 From: Sandeep Chauhan Date: Thu, 5 Sep 2024 00:10:34 +0530 Subject: [PATCH 3/5] Fix no report form attached to fund (#4111) Fixes #4101 --- .../application_projects/report_form.html | 111 ++++++++++-------- hypha/apply/projects/views/report.py | 5 +- 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/hypha/apply/projects/templates/application_projects/report_form.html b/hypha/apply/projects/templates/application_projects/report_form.html index cb4d4073fd..eaad0cfc2a 100644 --- a/hypha/apply/projects/templates/application_projects/report_form.html +++ b/hypha/apply/projects/templates/application_projects/report_form.html @@ -19,64 +19,83 @@ {% slot sub_heading %}{% trans "Submit a report" %}{% endslot %} {% endadminbar %} - {% include "forms/includes/form_errors.html" with form=form %} + {% if report_form %} -
-
+ {% include "forms/includes/form_errors.html" with form=form %} -
- {% heroicon_outline 'exclamation-circle' stroke_width=2 size=22 class="inline me-1 stroke-dark-blue" aria_hidden=true %} -

{% trans "You are reporting for the period running from" %} {{ report.start_date }} {% trans "to" %} {{ report.end_date }}

-
+
+
+ +
+ {% heroicon_outline 'exclamation-circle' stroke_width=2 size=22 class="inline me-1 stroke-dark-blue" aria_hidden=true %} +

{% trans "You are reporting for the period running from" %} {{ report.start_date }} {% trans "to" %} {{ report.end_date }}

+
-
- {% csrf_token %} - {{ form.media }} + + {% csrf_token %} + {{ form.media }} - {% for field in form %} - {% if field.field %} - {% if field.field.multi_input_field %} - {% include "forms/includes/multi_input_field.html" %} + {% for field in form %} + {% if field.field %} + {% if field.field.multi_input_field %} + {% include "forms/includes/multi_input_field.html" %} + {% else %} + {% include "forms/includes/field.html" %} + {% endif %} {% else %} - {% include "forms/includes/field.html" %} + {{ field.block }} {% endif %} - {% else %} - {{ field.block }} - {% endif %} - {% endfor %} + {% endfor %} - {% for hidden_field in form.hidden_fields %} - {{ hidden_field }} - {% endfor %} - - - - + {% for hidden_field in form.hidden_fields %} + {{ hidden_field }} + {% endfor %} + + + + - -
+ {% else %} +
+
+ {% if request.user.is_apply_staff %} +

+ {% trans "Project Report Form not configured. Please add a project report form in the" %} + {% trans "fund settings" %}. +

+ {% else %} +

+ {% trans "Project Report Form not configured yet. Please contact us at " %} + {{ ORG_EMAIL }}. +

+ {% endif %} +
-
+ {% endif %} {% endblock %} {% block extra_js %} diff --git a/hypha/apply/projects/views/report.py b/hypha/apply/projects/views/report.py index 2b5666590a..b653a9fced 100644 --- a/hypha/apply/projects/views/report.py +++ b/hypha/apply/projects/views/report.py @@ -74,8 +74,6 @@ def get_form_class(self, draft=False, form_data=None, user=None): """ Expects self.form_fields to have already been set. """ - if not self.form_fields: - raise RuntimeError("Expected self.form_fields to be set") # This is where the magic happens. fields = self.get_form_fields(draft, form_data, user) the_class = type( @@ -105,6 +103,9 @@ def get_context_data(self, *args, **kwargs): context_data = { "form": form, "object": self.object, + "report_form": True + if self.object.project.submission.page.specific.report_forms.first() + else False, **kwargs, } return context_data From a3bd49541e3aa63ed522804e08974c390017210d Mon Sep 17 00:00:00 2001 From: Sandeep Chauhan Date: Thu, 5 Sep 2024 00:10:51 +0530 Subject: [PATCH 4/5] Fix my tasks title issue on dismissing all tasks (#4112) Fixes #4091 --- .../templates/dashboard/includes/my-tasks.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hypha/apply/dashboard/templates/dashboard/includes/my-tasks.html b/hypha/apply/dashboard/templates/dashboard/includes/my-tasks.html index 0226885724..0b827795ac 100644 --- a/hypha/apply/dashboard/templates/dashboard/includes/my-tasks.html +++ b/hypha/apply/dashboard/templates/dashboard/includes/my-tasks.html @@ -1,11 +1,13 @@ {% load i18n %}
-

{% trans "My tasks" %}

+ {% if my_tasks.data %} +

{% trans "My tasks" %}

-
- {% for task in my_tasks.data %} - {% include "todo/todolist_item.html" with button_type_class="button--transparent" %} - {% endfor %} -
+
+ {% for task in my_tasks.data %} + {% include "todo/todolist_item.html" with button_type_class="button--transparent" %} + {% endfor %} +
+ {% endif %}
From 2fcb25d4a0479e3e8813c0666b970deaad934265 Mon Sep 17 00:00:00 2001 From: Sandeep Chauhan Date: Thu, 5 Sep 2024 00:11:15 +0530 Subject: [PATCH 5/5] Add draft submission deletion feature for applicants (#4108) Fixes #4054 --- .../partials/applicant_submissions.html | 9 ++++++++- hypha/apply/funds/permissions.py | 11 +++++++++++ .../applicationsubmission_confirm_delete.html | 17 ++++++++++++----- .../funds/applicationsubmission_detail.html | 5 +++-- .../funds/templatetags/submission_tags.py | 12 ++++++++++++ hypha/apply/funds/views.py | 18 ++++++++++++------ 6 files changed, 58 insertions(+), 14 deletions(-) diff --git a/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html b/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html index 730d4d0db4..fbc0488582 100644 --- a/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html +++ b/hypha/apply/dashboard/templates/dashboard/partials/applicant_submissions.html @@ -1,4 +1,4 @@ -{% load i18n dashboard_statusbar_tags statusbar_tags workflow_tags heroicons %} +{% load i18n dashboard_statusbar_tags statusbar_tags workflow_tags heroicons submission_tags %} {% for submission in page.object_list %}
@@ -28,6 +28,13 @@

{% endif %} {% endif %} + {% user_can_delete_submission submission request.user as can_delete_submission %} + {% if can_delete_submission %} + + {% heroicon_micro "trash" class="inline me-1 mt-1 fill-red-600" aria_hidden=true %} + {% trans "Delete" %} + + {% endif %}

{% status_bar submission.workflow submission.phase request.user css_class="status-bar--small" %}
diff --git a/hypha/apply/funds/permissions.py b/hypha/apply/funds/permissions.py index 02fcd1dacb..90bd8d8318 100644 --- a/hypha/apply/funds/permissions.py +++ b/hypha/apply/funds/permissions.py @@ -1,6 +1,8 @@ from django.conf import settings from django.core.exceptions import PermissionDenied +from hypha.apply.funds.models.submissions import DRAFT_STATE + from ..users.groups import STAFF_GROUP_NAME, SUPERADMIN, TEAMADMIN_GROUP_NAME @@ -24,6 +26,14 @@ def can_edit_submission(user, submission): return True, "" +def can_delete_submission(user, submission): + if user.has_perm("funds.delete_applicationsubmission"): + return True, "User can delete submission" + elif user == submission.user and submission.status == DRAFT_STATE: + return True, "Applicant can delete draft submissions" + return False, "Forbidden Error" + + def can_bulk_delete_submissions(user) -> bool: if user.is_apply_staff: return True @@ -164,6 +174,7 @@ def can_view_submission_screening(user, submission): permissions_map = { "submission_view": is_user_has_access_to_view_submission, "submission_edit": can_edit_submission, + "submission_delete": can_delete_submission, "can_view_submission_screening": can_view_submission_screening, "archive_alter": can_alter_archived_submissions, } diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html b/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html index bd4ee4fb9a..5a015982f2 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_confirm_delete.html @@ -13,11 +13,18 @@
-

- Are you sure you want to delete submission? All of your data - will be permanently removed from our servers forever. This - includes reviews, determinations and comments. This action cannot be undone. -

+ {% if request.user.is_applicant %} +

+ Are you sure you want to delete draft submission? All of your data for this submission + will be permanently removed from our servers forever. This action cannot be undone. +

+ {% else %} +

+ Are you sure you want to delete submission? All of your data + will be permanently removed from our servers forever. This + includes reviews, determinations and comments. This action cannot be undone. +

+ {% endif %}
diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html index d456e94c36..7f7a134f83 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html @@ -1,5 +1,5 @@ {% extends "base-apply.html" %} -{% load i18n static workflow_tags wagtailcore_tags statusbar_tags archive_tags %} +{% load i18n static workflow_tags wagtailcore_tags statusbar_tags archive_tags submission_tags %} {% load heroicons %} {% block title %}#{{ object.public_id|default_if_none:object.id}}: {{ object.title }}{% endblock %} @@ -119,7 +119,8 @@
{% blocktrans with stage=object.previous.stage %}Your {{ stage }} applicatio
- {% if perms.funds.delete_applicationsubmission %} + {% user_can_delete_submission object request.user as can_delete_submission %} + {% if can_delete_submission %}