From 1aceeac59566dfa0f70013f27991fb17a8cba91e Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 10 Jul 2024 15:57:30 +0530 Subject: [PATCH 01/34] Remove assigned task --- .../todo/templates/todo/todolist_item.html | 34 +++++++++++++++++++ hypha/templates/base.html | 1 + 2 files changed, 35 insertions(+) diff --git a/hypha/apply/todo/templates/todo/todolist_item.html b/hypha/apply/todo/templates/todo/todolist_item.html index 7806701479..f6fbe68eac 100644 --- a/hypha/apply/todo/templates/todo/todolist_item.html +++ b/hypha/apply/todo/templates/todo/todolist_item.html @@ -16,4 +16,38 @@ {% endif %} {% trans "View" %} + {% if task.user %} + + {% else %} + + {% endif %} + +
+ {% trans "Remove Task" %} +
+
+ {% if task.user %} +

{% trans "Are you sure you want to remove this task? It'll remove this task from your task list." %}

+ {% else %} +

{% trans "It'll remove this task from whole team's task list. Are you sure you want to remove this task for whole team?" %}

+ {% endif %} +
+ + +
+
+
diff --git a/hypha/templates/base.html b/hypha/templates/base.html index 189de7ad51..a88697734d 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,6 +65,7 @@ + From 52ea82ad82a9f1ca9f8a2555cacb0d1f9eddd804 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 10 Jul 2024 17:42:51 +0530 Subject: [PATCH 02/34] Added migration --- .../migrations/0082_alter_event_type.py | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 hypha/apply/activity/migrations/0082_alter_event_type.py diff --git a/hypha/apply/activity/migrations/0082_alter_event_type.py b/hypha/apply/activity/migrations/0082_alter_event_type.py new file mode 100644 index 0000000000..30c3d58644 --- /dev/null +++ b/hypha/apply/activity/migrations/0082_alter_event_type.py @@ -0,0 +1,86 @@ +# Generated by Django 4.2.11 on 2024-07-10 12:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("activity", "0081_alter_event_type"), + ] + + operations = [ + migrations.AlterField( + model_name="event", + name="type", + field=models.CharField( + choices=[ + ("UPDATE_LEAD", "updated lead"), + ("BATCH_UPDATE_LEAD", "batch updated lead"), + ("EDIT_SUBMISSION", "edited submission"), + ("APPLICANT_EDIT", "edited applicant"), + ("NEW_SUBMISSION", "submitted new submission"), + ("DRAFT_SUBMISSION", "submitted new draft submission"), + ("SCREENING", "screened"), + ("TRANSITION", "transitioned"), + ("BATCH_TRANSITION", "batch transitioned"), + ("DETERMINATION_OUTCOME", "sent determination outcome"), + ("BATCH_DETERMINATION_OUTCOME", "sent batch determination outcome"), + ("INVITED_TO_PROPOSAL", "invited to proposal"), + ("REVIEWERS_UPDATED", "updated reviewers"), + ("BATCH_REVIEWERS_UPDATED", "batch updated reviewers"), + ("PARTNERS_UPDATED", "updated partners"), + ("PARTNERS_UPDATED_PARTNER", "partners updated partner"), + ("READY_FOR_REVIEW", "marked ready for review"), + ("BATCH_READY_FOR_REVIEW", "marked batch ready for review"), + ("NEW_REVIEW", "added new review"), + ("COMMENT", "added comment"), + ("PROPOSAL_SUBMITTED", "submitted proposal"), + ("OPENED_SEALED", "opened sealed submission"), + ("REVIEW_OPINION", "reviewed opinion"), + ("DELETE_SUBMISSION", "deleted submission"), + ("DELETE_REVIEW", "deleted review"), + ("DELETE_REVIEW_OPINION", "deleted review opinion"), + ("CREATED_PROJECT", "created project"), + ("UPDATED_VENDOR", "updated contracting information"), + ("UPDATE_PROJECT_LEAD", "updated project lead"), + ("UPDATE_PROJECT_TITLE", "updated project title"), + ("EDIT_REVIEW", "edited review"), + ("SEND_FOR_APPROVAL", "sent for approval"), + ("APPROVE_PROJECT", "approved project"), + ("ASSIGN_PAF_APPROVER", "assign paf approver"), + ("APPROVE_PAF", "approved paf"), + ("PROJECT_TRANSITION", "transitioned project"), + ("REQUEST_PROJECT_CHANGE", "requested project change"), + ("SUBMIT_CONTRACT_DOCUMENTS", "submitted contract documents"), + ("UPLOAD_DOCUMENT", "uploaded document to project"), + ("REMOVE_DOCUMENT", "removed document from project"), + ("UPLOAD_CONTRACT", "uploaded contract to project"), + ("APPROVE_CONTRACT", "approved contract"), + ("CREATE_INVOICE", "created invoice for project"), + ("UPDATE_INVOICE_STATUS", "updated invoice status"), + ("APPROVE_INVOICE", "approve invoice"), + ("DELETE_INVOICE", "deleted invoice"), + ("SENT_TO_COMPLIANCE", "sent project to compliance"), + ("UPDATE_INVOICE", "updated invoice"), + ("SUBMIT_REPORT", "submitted report"), + ("SKIPPED_REPORT", "skipped report"), + ("REPORT_FREQUENCY_CHANGED", "changed report frequency"), + ("DISABLED_REPORTING", "disabled reporting"), + ("REPORT_NOTIFY", "notified report"), + ("CREATE_REMINDER", "created reminder"), + ("DELETE_REMINDER", "deleted reminder"), + ("REVIEW_REMINDER", "reminder to review"), + ("BATCH_DELETE_SUBMISSION", "batch deleted submissions"), + ("BATCH_ARCHIVE_SUBMISSION", "batch archive submissions"), + ("BATCH_INVOICE_STATUS_UPDATE", "batch update invoice status"), + ("STAFF_ACCOUNT_CREATED", "created new account"), + ("STAFF_ACCOUNT_EDITED", "edited account"), + ("ARCHIVE_SUBMISSION", "archived submission"), + ("UNARCHIVE_SUBMISSION", "unarchived submission"), + ("REMOVE_TASK", "remove task"), + ], + max_length=50, + verbose_name="verb", + ), + ), + ] From 7d5f9d1669ba41fbcaec103e23347d1fbf1b9bfc Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sun, 21 Jul 2024 17:31:10 +0530 Subject: [PATCH 03/34] Replace confirm dialog box by hx-confirm --- .../todo/templates/todo/todolist_item.html | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/hypha/apply/todo/templates/todo/todolist_item.html b/hypha/apply/todo/templates/todo/todolist_item.html index f6fbe68eac..9075d5b199 100644 --- a/hypha/apply/todo/templates/todo/todolist_item.html +++ b/hypha/apply/todo/templates/todo/todolist_item.html @@ -17,37 +17,8 @@ {% endif %} {% trans "View" %} {% if task.user %} - + {% else %} - + {% endif %} - -
- {% trans "Remove Task" %} -
-
- {% if task.user %} -

{% trans "Are you sure you want to remove this task? It'll remove this task from your task list." %}

- {% else %} -

{% trans "It'll remove this task from whole team's task list. Are you sure you want to remove this task for whole team?" %}

- {% endif %} -
- - -
-
-
From f01b744c0051ccdd627812eac1d2eb08ff076d08 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sun, 21 Jul 2024 17:39:24 +0530 Subject: [PATCH 04/34] Remove dialog package --- hypha/templates/base.html | 1 - 1 file changed, 1 deletion(-) diff --git a/hypha/templates/base.html b/hypha/templates/base.html index a88697734d..189de7ad51 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,7 +65,6 @@ - From 2039e33669af0ee88886f3b43d0acd19db2e08ae Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 25 Jul 2024 11:19:21 +0530 Subject: [PATCH 05/34] Remove tasks form task lists without reloading the page --- hypha/apply/todo/templates/todo/todolist_item.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypha/apply/todo/templates/todo/todolist_item.html b/hypha/apply/todo/templates/todo/todolist_item.html index 9075d5b199..93cac8b9ea 100644 --- a/hypha/apply/todo/templates/todo/todolist_item.html +++ b/hypha/apply/todo/templates/todo/todolist_item.html @@ -17,8 +17,8 @@ {% endif %} {% trans "View" %} {% if task.user %} - + {% else %} - + {% endif %} From a8824e0f1780234008b9f33d512ae71b80056af6 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 25 Jul 2024 11:40:19 +0530 Subject: [PATCH 06/34] Resolve migrations conflicts --- .../migrations/0082_alter_event_type.py | 86 ------------------- 1 file changed, 86 deletions(-) delete mode 100644 hypha/apply/activity/migrations/0082_alter_event_type.py diff --git a/hypha/apply/activity/migrations/0082_alter_event_type.py b/hypha/apply/activity/migrations/0082_alter_event_type.py deleted file mode 100644 index 30c3d58644..0000000000 --- a/hypha/apply/activity/migrations/0082_alter_event_type.py +++ /dev/null @@ -1,86 +0,0 @@ -# Generated by Django 4.2.11 on 2024-07-10 12:12 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("activity", "0081_alter_event_type"), - ] - - operations = [ - migrations.AlterField( - model_name="event", - name="type", - field=models.CharField( - choices=[ - ("UPDATE_LEAD", "updated lead"), - ("BATCH_UPDATE_LEAD", "batch updated lead"), - ("EDIT_SUBMISSION", "edited submission"), - ("APPLICANT_EDIT", "edited applicant"), - ("NEW_SUBMISSION", "submitted new submission"), - ("DRAFT_SUBMISSION", "submitted new draft submission"), - ("SCREENING", "screened"), - ("TRANSITION", "transitioned"), - ("BATCH_TRANSITION", "batch transitioned"), - ("DETERMINATION_OUTCOME", "sent determination outcome"), - ("BATCH_DETERMINATION_OUTCOME", "sent batch determination outcome"), - ("INVITED_TO_PROPOSAL", "invited to proposal"), - ("REVIEWERS_UPDATED", "updated reviewers"), - ("BATCH_REVIEWERS_UPDATED", "batch updated reviewers"), - ("PARTNERS_UPDATED", "updated partners"), - ("PARTNERS_UPDATED_PARTNER", "partners updated partner"), - ("READY_FOR_REVIEW", "marked ready for review"), - ("BATCH_READY_FOR_REVIEW", "marked batch ready for review"), - ("NEW_REVIEW", "added new review"), - ("COMMENT", "added comment"), - ("PROPOSAL_SUBMITTED", "submitted proposal"), - ("OPENED_SEALED", "opened sealed submission"), - ("REVIEW_OPINION", "reviewed opinion"), - ("DELETE_SUBMISSION", "deleted submission"), - ("DELETE_REVIEW", "deleted review"), - ("DELETE_REVIEW_OPINION", "deleted review opinion"), - ("CREATED_PROJECT", "created project"), - ("UPDATED_VENDOR", "updated contracting information"), - ("UPDATE_PROJECT_LEAD", "updated project lead"), - ("UPDATE_PROJECT_TITLE", "updated project title"), - ("EDIT_REVIEW", "edited review"), - ("SEND_FOR_APPROVAL", "sent for approval"), - ("APPROVE_PROJECT", "approved project"), - ("ASSIGN_PAF_APPROVER", "assign paf approver"), - ("APPROVE_PAF", "approved paf"), - ("PROJECT_TRANSITION", "transitioned project"), - ("REQUEST_PROJECT_CHANGE", "requested project change"), - ("SUBMIT_CONTRACT_DOCUMENTS", "submitted contract documents"), - ("UPLOAD_DOCUMENT", "uploaded document to project"), - ("REMOVE_DOCUMENT", "removed document from project"), - ("UPLOAD_CONTRACT", "uploaded contract to project"), - ("APPROVE_CONTRACT", "approved contract"), - ("CREATE_INVOICE", "created invoice for project"), - ("UPDATE_INVOICE_STATUS", "updated invoice status"), - ("APPROVE_INVOICE", "approve invoice"), - ("DELETE_INVOICE", "deleted invoice"), - ("SENT_TO_COMPLIANCE", "sent project to compliance"), - ("UPDATE_INVOICE", "updated invoice"), - ("SUBMIT_REPORT", "submitted report"), - ("SKIPPED_REPORT", "skipped report"), - ("REPORT_FREQUENCY_CHANGED", "changed report frequency"), - ("DISABLED_REPORTING", "disabled reporting"), - ("REPORT_NOTIFY", "notified report"), - ("CREATE_REMINDER", "created reminder"), - ("DELETE_REMINDER", "deleted reminder"), - ("REVIEW_REMINDER", "reminder to review"), - ("BATCH_DELETE_SUBMISSION", "batch deleted submissions"), - ("BATCH_ARCHIVE_SUBMISSION", "batch archive submissions"), - ("BATCH_INVOICE_STATUS_UPDATE", "batch update invoice status"), - ("STAFF_ACCOUNT_CREATED", "created new account"), - ("STAFF_ACCOUNT_EDITED", "edited account"), - ("ARCHIVE_SUBMISSION", "archived submission"), - ("UNARCHIVE_SUBMISSION", "unarchived submission"), - ("REMOVE_TASK", "remove task"), - ], - max_length=50, - verbose_name="verb", - ), - ), - ] From f947a841e5dd56f69c3111b71fbce0c4ae153ad4 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 25 Jul 2024 18:37:01 +0530 Subject: [PATCH 07/34] Show trash icon on hover and remove it for user group tasks --- hypha/apply/todo/templates/todo/todolist_item.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hypha/apply/todo/templates/todo/todolist_item.html b/hypha/apply/todo/templates/todo/todolist_item.html index 93cac8b9ea..7806701479 100644 --- a/hypha/apply/todo/templates/todo/todolist_item.html +++ b/hypha/apply/todo/templates/todo/todolist_item.html @@ -16,9 +16,4 @@ {% endif %} {% trans "View" %} - {% if task.user %} - - {% else %} - - {% endif %} From 64dd5c1d68c14da09674fac7b22718562f492687 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 6 Jun 2024 18:31:35 +0530 Subject: [PATCH 08/34] Use Dialog box inplace of fancybox modal, with htmx and alpine(only for lead update yet) --- hypha/templates/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/hypha/templates/base.html b/hypha/templates/base.html index 189de7ad51..d2859a0042 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,6 +65,7 @@ + From 248dc80cc81619509eb035a26ac7a514cae00a3d Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 12 Jun 2024 16:29:54 +0530 Subject: [PATCH 09/34] Use htmx and dialog for project creation --- .../funds/templates/funds/includes/create_project_form.html | 1 + 1 file changed, 1 insertion(+) diff --git a/hypha/apply/funds/templates/funds/includes/create_project_form.html b/hypha/apply/funds/templates/funds/includes/create_project_form.html index 5aceac9cc7..8432e5dbf0 100644 --- a/hypha/apply/funds/templates/funds/includes/create_project_form.html +++ b/hypha/apply/funds/templates/funds/includes/create_project_form.html @@ -1,4 +1,5 @@ {% load i18n %} +<<<<<<< HEAD {% modal_title %}Create Project{% endmodal_title %} From 2f226a022e8596e3f574225cfc2b4e7abfe1d1da Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 12 Jun 2024 17:54:49 +0530 Subject: [PATCH 10/34] Use htmx and dialog for create reminder form --- hypha/apply/funds/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 73cc6be9e3..12e0f71ee4 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1087,7 +1087,11 @@ def get(self, *args, **kwargs): "funds/includes/create_reminder_form.html", context={ "form": reminder_form, +<<<<<<< HEAD "value": _("Create Reminder"), +======= + "value": _("Create"), +>>>>>>> 331f5b0a2 (Use htmx and dialog for create reminder form) "object": self.submission, }, ) @@ -1105,6 +1109,7 @@ def post(self, *args, **kwargs): source=self.submission, related=reminder, ) +<<<<<<< HEAD return HttpResponse( status=204, headers={ @@ -1113,6 +1118,9 @@ def post(self, *args, **kwargs): ), }, ) +======= + return HttpResponseClientRefresh() +>>>>>>> 331f5b0a2 (Use htmx and dialog for create reminder form) return render( self.request, "funds/includes/create_reminder_form.html", From 67bc9040817ddb3741dd592d38e6126bb4ac50d3 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 12 Jun 2024 19:48:38 +0530 Subject: [PATCH 11/34] Use htmx and dialog for submission progress/status update --- hypha/apply/funds/views.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 12e0f71ee4..73cc6be9e3 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1087,11 +1087,7 @@ def get(self, *args, **kwargs): "funds/includes/create_reminder_form.html", context={ "form": reminder_form, -<<<<<<< HEAD "value": _("Create Reminder"), -======= - "value": _("Create"), ->>>>>>> 331f5b0a2 (Use htmx and dialog for create reminder form) "object": self.submission, }, ) @@ -1109,7 +1105,6 @@ def post(self, *args, **kwargs): source=self.submission, related=reminder, ) -<<<<<<< HEAD return HttpResponse( status=204, headers={ @@ -1118,9 +1113,6 @@ def post(self, *args, **kwargs): ), }, ) -======= - return HttpResponseClientRefresh() ->>>>>>> 331f5b0a2 (Use htmx and dialog for create reminder form) return render( self.request, "funds/includes/create_reminder_form.html", From 2d94490d3fbe7caee4e20f54d7105f81c0f40b9a Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 13 Jun 2024 11:13:41 +0530 Subject: [PATCH 12/34] Fix requirements and progress button code --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d349e3104c..25ed25a665 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,6 +30,7 @@ django-storages==1.14.2 django-tables2==2.7.0 django-tinymce==4.1.0 django-two-factor-auth==1.16.0 +django-user-agents==0.4.0 django-web-components==0.2.0 django==4.2.15 djangorestframework-api-key==3.0.0 From ba175cbd94f421a07fdebed452cd77f37b9608f3 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Mon, 17 Jun 2024 10:13:48 +0530 Subject: [PATCH 13/34] Use htmx and dialog box for meta terms --- hypha/static_src/javascript/vendor/alpine-dialog.min.js | 1 + hypha/templates/base.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 hypha/static_src/javascript/vendor/alpine-dialog.min.js diff --git a/hypha/static_src/javascript/vendor/alpine-dialog.min.js b/hypha/static_src/javascript/vendor/alpine-dialog.min.js new file mode 100644 index 0000000000..5d18604eca --- /dev/null +++ b/hypha/static_src/javascript/vendor/alpine-dialog.min.js @@ -0,0 +1 @@ +(()=>{function d(s){s.directive("htmldialog",a);function a(e,{expression:l,modifiers:u},{evaluateLater:f,cleanup:g}){let r=l.length?f(l):()=>{},p=u.includes("noscroll");e.style.display=null,e.hidden=!1,e.style.length===0&&e.removeAttribute("style");function i(t=!0){document.body.style.overflow=t?"hidden":""}function o(t){t.key==="Escape"&&(t.preventDefault(),r())}function c(t){let n=e.getBoundingClientRect();n.top<=t.clientY&&t.clientY<=n.top+n.height&&n.left<=t.clientX&&t.clientX<=n.left+n.width||r()}e._x_doShow=()=>{e.hasAttribute("open")||(e.showModal(),document.addEventListener("keydown",o),e.addEventListener("click",c),i(p))},e._x_doHide=()=>{!e.hasAttribute("open")||(e.close(),document.removeEventListener("keydown",o),e.removeEventListener("click",c),i(!1))},g(()=>{document.removeEventListener("keydown",o),e.removeEventListener("click",c),i(!1)})}}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(d)});})(); diff --git a/hypha/templates/base.html b/hypha/templates/base.html index d2859a0042..da50bb936c 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,7 +65,7 @@ - + From 1b11c743611c1f150cb4ecdcc317feb66d3fc67d Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 20 Jun 2024 12:34:01 +0530 Subject: [PATCH 14/34] Remove Select2Widget for reviewers and partners, add defer to alpine dialog --- hypha/templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypha/templates/base.html b/hypha/templates/base.html index da50bb936c..96d22a4da8 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,7 +65,7 @@ - + From 9f8f0bf16f7d8787d3047398e0a067148d411286 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 26 Jun 2024 09:55:00 +0530 Subject: [PATCH 15/34] Use dialog modal for all other dialogs to avoid UI shift and closing issue --- .../funds/templates/funds/includes/create_project_form.html | 1 - 1 file changed, 1 deletion(-) diff --git a/hypha/apply/funds/templates/funds/includes/create_project_form.html b/hypha/apply/funds/templates/funds/includes/create_project_form.html index 8432e5dbf0..5aceac9cc7 100644 --- a/hypha/apply/funds/templates/funds/includes/create_project_form.html +++ b/hypha/apply/funds/templates/funds/includes/create_project_form.html @@ -1,5 +1,4 @@ {% load i18n %} -<<<<<<< HEAD {% modal_title %}Create Project{% endmodal_title %} From d663244b28e1172a18059c4f17c4eb99e4a4a0c3 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Fri, 5 Jul 2024 19:59:02 +0530 Subject: [PATCH 16/34] Add @fylgja/alpinejs-dialog as npm package --- Makefile | 1 + package-lock.json | 7 +++++++ package.json | 1 + 3 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 1f6342c06e..2ff97fab51 100644 --- a/Makefile +++ b/Makefile @@ -109,5 +109,6 @@ copy-npm-scripts: cp node_modules/htmx.org/dist/ext/multi-swap.js $(JS_VENDOR_DIR)/htmx-ext-multi-swap.min.js cp node_modules/alpinejs/dist/cdn.min.js $(JS_VENDOR_DIR)/alpine.min.js cp node_modules/@alpinejs/focus/dist/cdn.min.js $(JS_VENDOR_DIR)/alpine-focus.min.js + cp node_modules/@fylgja/alpinejs-dialog/dist/index.min.js $(JS_VENDOR_DIR)/alpine-dialog.min.js cp node_modules/daterangepicker/moment.min.js $(JS_VENDOR_DIR)/moment.min.js cp node_modules/daterangepicker/daterangepicker.js $(JS_VENDOR_DIR)/daterangepicker.min.js diff --git a/package-lock.json b/package-lock.json index 83e007fe1e..0002ed4e44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@babel/cli": "^7.24.7", "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", + "@fylgja/alpinejs-dialog": "^2.0.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", "alpinejs": "^3.14.1", @@ -1923,6 +1924,12 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fylgja/alpinejs-dialog": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@fylgja/alpinejs-dialog/-/alpinejs-dialog-2.0.1.tgz", + "integrity": "sha512-OjKhKNEn6MhXGB95YrNk+0fzIg8zRrhyB5V4+l9DlVz+my1LEQG6EKvOmUGl5vv3B64R470odZM9VmPPJU5ijQ==", + "dev": true + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", diff --git a/package.json b/package.json index a735ecd757..9f82e4b9db 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@babel/cli": "^7.24.7", "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", + "@fylgja/alpinejs-dialog": "^2.0.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", "alpinejs": "^3.14.1", From 0c20039d5165667e8b6c94353e1a46fae97a92df Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sun, 7 Jul 2024 23:57:06 +0530 Subject: [PATCH 17/34] New dialog implementation --- Makefile | 1 - hypha/static_src/javascript/toasts.js | 37 +++++++++++++++ .../javascript/vendor/alpine-dialog.min.js | 1 - .../includes/_dialog-placeholder.html | 47 +++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 hypha/static_src/javascript/toasts.js delete mode 100644 hypha/static_src/javascript/vendor/alpine-dialog.min.js create mode 100644 hypha/templates/includes/_dialog-placeholder.html diff --git a/Makefile b/Makefile index 2ff97fab51..1f6342c06e 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,5 @@ copy-npm-scripts: cp node_modules/htmx.org/dist/ext/multi-swap.js $(JS_VENDOR_DIR)/htmx-ext-multi-swap.min.js cp node_modules/alpinejs/dist/cdn.min.js $(JS_VENDOR_DIR)/alpine.min.js cp node_modules/@alpinejs/focus/dist/cdn.min.js $(JS_VENDOR_DIR)/alpine-focus.min.js - cp node_modules/@fylgja/alpinejs-dialog/dist/index.min.js $(JS_VENDOR_DIR)/alpine-dialog.min.js cp node_modules/daterangepicker/moment.min.js $(JS_VENDOR_DIR)/moment.min.js cp node_modules/daterangepicker/daterangepicker.js $(JS_VENDOR_DIR)/daterangepicker.min.js diff --git a/hypha/static_src/javascript/toasts.js b/hypha/static_src/javascript/toasts.js new file mode 100644 index 0000000000..d1f9606ba9 --- /dev/null +++ b/hypha/static_src/javascript/toasts.js @@ -0,0 +1,37 @@ +function toastHandler() { + return { + toasts: [], + visible: [], + add(toast) { + toast.id = Date.now(); + this.toasts.push(toast); + this.fire(toast.id); + }, + fire(id) { + this.visible.push(this.toasts.find((toast) => toast.id == id)); + const timeShown = 2000 * this.visible.length; + setTimeout(() => { + this.remove(id); + }, timeShown); + }, + remove(id) { + const toast = this.visible.find((toast) => toast.id == id); + const index = this.visible.indexOf(toast); + this.visible.splice(index, 1); + }, + }; +} + +(function () { + htmx.on("showMessage", (e) => { + let message_detail = { type: "info", text: "🎬 " + e.detail.value }; + dispatchEvent( + new CustomEvent("notice", { + detail: message_detail, + bubbles: true, + cancelable: true, + composed: true, + }) + ); + }); +})(); diff --git a/hypha/static_src/javascript/vendor/alpine-dialog.min.js b/hypha/static_src/javascript/vendor/alpine-dialog.min.js deleted file mode 100644 index 5d18604eca..0000000000 --- a/hypha/static_src/javascript/vendor/alpine-dialog.min.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{function d(s){s.directive("htmldialog",a);function a(e,{expression:l,modifiers:u},{evaluateLater:f,cleanup:g}){let r=l.length?f(l):()=>{},p=u.includes("noscroll");e.style.display=null,e.hidden=!1,e.style.length===0&&e.removeAttribute("style");function i(t=!0){document.body.style.overflow=t?"hidden":""}function o(t){t.key==="Escape"&&(t.preventDefault(),r())}function c(t){let n=e.getBoundingClientRect();n.top<=t.clientY&&t.clientY<=n.top+n.height&&n.left<=t.clientX&&t.clientX<=n.left+n.width||r()}e._x_doShow=()=>{e.hasAttribute("open")||(e.showModal(),document.addEventListener("keydown",o),e.addEventListener("click",c),i(p))},e._x_doHide=()=>{!e.hasAttribute("open")||(e.close(),document.removeEventListener("keydown",o),e.removeEventListener("click",c),i(!1))},g(()=>{document.removeEventListener("keydown",o),e.removeEventListener("click",c),i(!1)})}}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(d)});})(); diff --git a/hypha/templates/includes/_dialog-placeholder.html b/hypha/templates/includes/_dialog-placeholder.html new file mode 100644 index 0000000000..79b42d0cee --- /dev/null +++ b/hypha/templates/includes/_dialog-placeholder.html @@ -0,0 +1,47 @@ +
+ + + + +
+
+
+
+
+
+
From 21ae3578cccba23c2bb217e783b88fdef5f77278 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 8 Jul 2024 02:00:18 +0530 Subject: [PATCH 18/34] Delete modal --- .../includes/_dialog-placeholder.html | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 hypha/templates/includes/_dialog-placeholder.html diff --git a/hypha/templates/includes/_dialog-placeholder.html b/hypha/templates/includes/_dialog-placeholder.html deleted file mode 100644 index 79b42d0cee..0000000000 --- a/hypha/templates/includes/_dialog-placeholder.html +++ /dev/null @@ -1,47 +0,0 @@ -
- - - - -
-
-
-
-
-
-
From b662b37e7e249f29eee5dd83a288857d7949e383 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sat, 13 Jul 2024 15:22:16 +0530 Subject: [PATCH 19/34] Create reminder modal --- hypha/static_src/javascript/toasts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypha/static_src/javascript/toasts.js b/hypha/static_src/javascript/toasts.js index d1f9606ba9..97cbcb31e9 100644 --- a/hypha/static_src/javascript/toasts.js +++ b/hypha/static_src/javascript/toasts.js @@ -24,7 +24,7 @@ function toastHandler() { (function () { htmx.on("showMessage", (e) => { - let message_detail = { type: "info", text: "🎬 " + e.detail.value }; + let message_detail = { type: "info", text: "ℹ️ " + e.detail.value }; dispatchEvent( new CustomEvent("notice", { detail: message_detail, From 7f0baffde73b71a9462ac9180c65f08a00e8f81a Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sun, 14 Jul 2024 11:09:36 +0530 Subject: [PATCH 20/34] Django messages as toast for htmx request --- hypha/static_src/javascript/toasts.js | 37 --------------------------- 1 file changed, 37 deletions(-) delete mode 100644 hypha/static_src/javascript/toasts.js diff --git a/hypha/static_src/javascript/toasts.js b/hypha/static_src/javascript/toasts.js deleted file mode 100644 index 97cbcb31e9..0000000000 --- a/hypha/static_src/javascript/toasts.js +++ /dev/null @@ -1,37 +0,0 @@ -function toastHandler() { - return { - toasts: [], - visible: [], - add(toast) { - toast.id = Date.now(); - this.toasts.push(toast); - this.fire(toast.id); - }, - fire(id) { - this.visible.push(this.toasts.find((toast) => toast.id == id)); - const timeShown = 2000 * this.visible.length; - setTimeout(() => { - this.remove(id); - }, timeShown); - }, - remove(id) { - const toast = this.visible.find((toast) => toast.id == id); - const index = this.visible.indexOf(toast); - this.visible.splice(index, 1); - }, - }; -} - -(function () { - htmx.on("showMessage", (e) => { - let message_detail = { type: "info", text: "ℹ️ " + e.detail.value }; - dispatchEvent( - new CustomEvent("notice", { - detail: message_detail, - bubbles: true, - cancelable: true, - composed: true, - }) - ); - }); -})(); From d1b066ecc92be946109def3219d3a1a515a3f627 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 15 Jul 2024 12:53:45 +0530 Subject: [PATCH 21/34] remove dependencies --- package-lock.json | 7 ------- package.json | 1 - requirements.txt | 1 - 3 files changed, 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0002ed4e44..83e007fe1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@babel/cli": "^7.24.7", "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", - "@fylgja/alpinejs-dialog": "^2.0.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", "alpinejs": "^3.14.1", @@ -1924,12 +1923,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@fylgja/alpinejs-dialog": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@fylgja/alpinejs-dialog/-/alpinejs-dialog-2.0.1.tgz", - "integrity": "sha512-OjKhKNEn6MhXGB95YrNk+0fzIg8zRrhyB5V4+l9DlVz+my1LEQG6EKvOmUGl5vv3B64R470odZM9VmPPJU5ijQ==", - "dev": true - }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", diff --git a/package.json b/package.json index 9f82e4b9db..a735ecd757 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "@babel/cli": "^7.24.7", "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", - "@fylgja/alpinejs-dialog": "^2.0.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", "alpinejs": "^3.14.1", diff --git a/requirements.txt b/requirements.txt index 25ed25a665..d349e3104c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,6 @@ django-storages==1.14.2 django-tables2==2.7.0 django-tinymce==4.1.0 django-two-factor-auth==1.16.0 -django-user-agents==0.4.0 django-web-components==0.2.0 django==4.2.15 djangorestframework-api-key==3.0.0 From 3688cea9b283efa2f5907fc4e1cc346cec55fde8 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Thu, 18 Jul 2024 11:35:31 +0530 Subject: [PATCH 22/34] Finish lead update form --- .../templates/funds/modals/update_lead_form.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hypha/apply/funds/templates/funds/modals/update_lead_form.html b/hypha/apply/funds/templates/funds/modals/update_lead_form.html index dae8688b6d..50e8097a58 100644 --- a/hypha/apply/funds/templates/funds/modals/update_lead_form.html +++ b/hypha/apply/funds/templates/funds/modals/update_lead_form.html @@ -1,10 +1,21 @@ {% load i18n %} +<<<<<<< HEAD {% modal_title %}{% trans "Update Lead" %}{% endmodal_title %}
{% trans "Current Lead" %}
+======= +{% modal_title %}Update Lead{% endmodal_title %} + +
+ {% csrf_token %} + +
+
+
Current Lead
+>>>>>>> 04827cde4 (Finish lead update form)
{{ object.lead }} <{{object.lead.email}}>
From 8da5eab41f6fa2297f5bc58d4cf1c5449da0c12b Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 22 Jul 2024 01:32:21 +0530 Subject: [PATCH 23/34] update meta terms modal and remove mobile actions --- .../submissions/partials/meta-terms-card.html | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html index 180360bb4e..046e91aff7 100644 --- a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html +++ b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html @@ -9,7 +9,11 @@
{% trans "Meta Terms" %}
role="button" {% if meta_terms %} aria-label="{% trans "Update Meta Terms" %}" +<<<<<<< HEAD title="{% trans "Update Meta Terms" %}" +======= + title="Update meta terms" +>>>>>>> 52c26299a (update meta terms modal and remove mobile actions) {% else %} aria-label="{% trans "Add Meta Terms" %}" {% endif %} @@ -27,6 +31,7 @@
{% trans "Meta Terms" %}
{% regroup meta_terms by get_parent as meta_term_groups %}
{% for group in meta_term_groups %} +<<<<<<< HEAD

{{ group.grouper }}:

@@ -41,7 +46,27 @@

{{ group.gro {% endfor %}

+======= +

{{ group.grouper }}

+
    + {% for meta_term in group.list %} +
  • {{ meta_term.name }}
  • + {% endfor %} +
+>>>>>>> 52c26299a (update meta terms modal and remove mobile actions) {% empty %} {% trans "--" %} {% endfor %}
+<<<<<<< HEAD +======= +{% comment %} +
    + {% for meta_term in meta_terms %} +
    {{ meta_term.get_parent }}
    +
  • {{ meta_term.name }}
  • + {% empty %} + {% trans "--" %} + {% endfor %} +
{% endcomment %} +>>>>>>> 52c26299a (update meta terms modal and remove mobile actions) From dec05e48d6e5413f34664a89f9fbb898d070f4e2 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 22 Jul 2024 13:17:06 +0530 Subject: [PATCH 24/34] update how meta terms are rendered in submission detail --- .../funds/modals/update_lead_form.html | 11 -------- .../submissions/partials/meta-terms-card.html | 25 ------------------- 2 files changed, 36 deletions(-) diff --git a/hypha/apply/funds/templates/funds/modals/update_lead_form.html b/hypha/apply/funds/templates/funds/modals/update_lead_form.html index 50e8097a58..dae8688b6d 100644 --- a/hypha/apply/funds/templates/funds/modals/update_lead_form.html +++ b/hypha/apply/funds/templates/funds/modals/update_lead_form.html @@ -1,21 +1,10 @@ {% load i18n %} -<<<<<<< HEAD {% modal_title %}{% trans "Update Lead" %}{% endmodal_title %}
{% trans "Current Lead" %}
-======= -{% modal_title %}Update Lead{% endmodal_title %} - -
- {% csrf_token %} - -
-
-
Current Lead
->>>>>>> 04827cde4 (Finish lead update form)
{{ object.lead }} <{{object.lead.email}}>
diff --git a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html index 046e91aff7..180360bb4e 100644 --- a/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html +++ b/hypha/apply/funds/templates/submissions/partials/meta-terms-card.html @@ -9,11 +9,7 @@
{% trans "Meta Terms" %}
role="button" {% if meta_terms %} aria-label="{% trans "Update Meta Terms" %}" -<<<<<<< HEAD title="{% trans "Update Meta Terms" %}" -======= - title="Update meta terms" ->>>>>>> 52c26299a (update meta terms modal and remove mobile actions) {% else %} aria-label="{% trans "Add Meta Terms" %}" {% endif %} @@ -31,7 +27,6 @@
{% trans "Meta Terms" %}
{% regroup meta_terms by get_parent as meta_term_groups %}
{% for group in meta_term_groups %} -<<<<<<< HEAD

{{ group.grouper }}:

@@ -46,27 +41,7 @@

{{ group.gro {% endfor %}

-======= -

{{ group.grouper }}

-
    - {% for meta_term in group.list %} -
  • {{ meta_term.name }}
  • - {% endfor %} -
->>>>>>> 52c26299a (update meta terms modal and remove mobile actions) {% empty %} {% trans "--" %} {% endfor %}
-<<<<<<< HEAD -======= -{% comment %} -
    - {% for meta_term in meta_terms %} -
    {{ meta_term.get_parent }}
    -
  • {{ meta_term.name }}
  • - {% empty %} - {% trans "--" %} - {% endfor %} -
{% endcomment %} ->>>>>>> 52c26299a (update meta terms modal and remove mobile actions) From 17d8f0527d4cb0e14a4a4f4cb6ace5b0b5678432 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sun, 21 Jul 2024 17:58:40 +0530 Subject: [PATCH 25/34] Add task button to bell icon dropdown --- hypha/apply/todo/forms.py | 13 +++++++++++++ hypha/apply/todo/urls.py | 3 ++- hypha/apply/todo/views.py | 9 ++++++++- .../templates/includes/menu-notifications.html | 17 ++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 hypha/apply/todo/forms.py diff --git a/hypha/apply/todo/forms.py b/hypha/apply/todo/forms.py new file mode 100644 index 0000000000..9dc51bff86 --- /dev/null +++ b/hypha/apply/todo/forms.py @@ -0,0 +1,13 @@ +from django import forms + +from .models import Task + + +class TaskCreateForm(forms.ModelForm): + class Meta: + model = Task + fields = ( + "code", + "user", + "user_group", + ) diff --git a/hypha/apply/todo/urls.py b/hypha/apply/todo/urls.py index b011facd44..babaabe42a 100644 --- a/hypha/apply/todo/urls.py +++ b/hypha/apply/todo/urls.py @@ -1,11 +1,12 @@ from django.urls import path -from .views import TaskRemovalView, TodoListView +from .views import TaskCreationView, TaskRemovalView, TodoListView app_name = "hypha.apply.todo" urlpatterns = [ path("todo/list/", TodoListView.as_view(), name="list"), + path("todo/add/", TaskCreationView.as_view(), name="add"), path("todo//delete/", TaskRemovalView.as_view(), name="delete"), ] diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index d89c5d31e0..bf9c9b951f 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -4,12 +4,13 @@ from django.db.models import Count from django.shortcuts import get_object_or_404, render from django.utils.decorators import method_decorator -from django.views.generic import ListView, View +from django.views.generic import CreateView, ListView, View from django_htmx.http import trigger_client_event from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.users.decorators import staff_required +from .forms import TaskCreateForm from .models import Task from .options import get_task_template from .services import validate_user_groups_uniqueness, validate_user_uniquness @@ -30,6 +31,12 @@ def get_context_data(self, **kwargs): return ctx +@method_decorator(staff_required, name="dispatch") +class TaskCreationView(CreateView): + form_class = TaskCreateForm + model = Task + + @method_decorator(staff_required, name="dispatch") class TaskRemovalView(View): def dispatch(self, request, *args, **kwargs): diff --git a/hypha/templates/includes/menu-notifications.html b/hypha/templates/includes/menu-notifications.html index f1db5e7812..88d943b79f 100644 --- a/hypha/templates/includes/menu-notifications.html +++ b/hypha/templates/includes/menu-notifications.html @@ -2,7 +2,7 @@
@@ -35,9 +35,20 @@ {% trans "Your Tasks" %} - + +
+ {% trans "Add Task" %} + X +
+
+ {% trans "Add" as add %} + {% include 'funds/includes/delegated_form_base.html' with form=add_manual_task value=add %} +
+
+
Date: Wed, 24 Jul 2024 18:40:41 +0530 Subject: [PATCH 26/34] Add raw form --- hypha/apply/todo/forms.py | 11 +++++ .../todo/includes/add_task_form.html | 9 ++++ hypha/apply/todo/views.py | 44 +++++++++++++++++-- .../includes/menu-notifications.html | 14 +----- 4 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 hypha/apply/todo/templates/todo/includes/add_task_form.html diff --git a/hypha/apply/todo/forms.py b/hypha/apply/todo/forms.py index 9dc51bff86..396a013c64 100644 --- a/hypha/apply/todo/forms.py +++ b/hypha/apply/todo/forms.py @@ -4,10 +4,21 @@ class TaskCreateForm(forms.ModelForm): + assigned_to = forms.ChoiceField( + choices=(("user", "Single User"), ("user_group", "User Groups")) + ) + msg = forms.CharField(max_length=120) + related_obj = forms.ChoiceField(choices=()) + type = forms.CharField(empty_value="manual", widget=forms.HiddenInput()) + class Meta: model = Task fields = ( "code", + "assigned_to", "user", "user_group", + "msg", + "related_obj", + "type", ) diff --git a/hypha/apply/todo/templates/todo/includes/add_task_form.html b/hypha/apply/todo/templates/todo/includes/add_task_form.html new file mode 100644 index 0000000000..ad160564d8 --- /dev/null +++ b/hypha/apply/todo/templates/todo/includes/add_task_form.html @@ -0,0 +1,9 @@ +{% load i18n %} +{% modal_title %}Add Task{% endmodal_title %} + +
+ {% csrf_token %} + + {% url 'todo:add' pk=object.pk as task_add_url %} + {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=task_add_url %} +
diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index bf9c9b951f..a6839b4c1f 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -1,10 +1,14 @@ +import json + from django.contrib.auth.models import Group from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.db.models import Count +from django.http import HttpResponse from django.shortcuts import get_object_or_404, render from django.utils.decorators import method_decorator -from django.views.generic import CreateView, ListView, View +from django.utils.translation import gettext as _ +from django.views.generic import ListView, View from django_htmx.http import trigger_client_event from hypha.apply.activity.messaging import MESSAGES, messenger @@ -32,9 +36,41 @@ def get_context_data(self, **kwargs): @method_decorator(staff_required, name="dispatch") -class TaskCreationView(CreateView): - form_class = TaskCreateForm - model = Task +class TaskCreationView(View): + def dispatch(self, request, *args, **kwargs): + return super().dispatch(request, *args, **kwargs) + + def get(self, *args, **kwargs): + task_form = TaskCreateForm() + return render( + self.request, + "todo/includes/add_task_form.html", + context={ + "form": task_form, + "value": _("Update"), + }, + ) + + def post(self, *args, **kwargs): + form = TaskCreateForm( + self.request.POST, user=self.request.user, instance=self.submission + ) + if form.is_valid(): + form.save() + return HttpResponse( + status=204, + headers={ + "HX-Trigger": json.dumps( + {"taskAdded": None, "showMessage": "Task Added."} + ), + }, + ) + + return render( + self.request, + "todo/includes/add_task_form.html", + context={"form": form, "value": _("Update"), "object": self.task}, + ) @method_decorator(staff_required, name="dispatch") diff --git a/hypha/templates/includes/menu-notifications.html b/hypha/templates/includes/menu-notifications.html index 88d943b79f..a0e6d43f14 100644 --- a/hypha/templates/includes/menu-notifications.html +++ b/hypha/templates/includes/menu-notifications.html @@ -2,7 +2,7 @@
@@ -35,19 +35,9 @@ {% trans "Your Tasks" %} - - -
- {% trans "Add Task" %} - X -
-
- {% trans "Add" as add %} - {% include 'funds/includes/delegated_form_base.html' with form=add_manual_task value=add %} -
-
From bb2e2b70806a106e4231bcdfb9c604d59fda12d4 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Mon, 29 Jul 2024 18:55:03 +0530 Subject: [PATCH 27/34] Add comments as task feature --- hypha/apply/activity/forms.py | 28 ++++++++++- .../0005_task_message_alter_task_code.py | 49 +++++++++++++++++++ hypha/apply/todo/models.py | 2 + hypha/apply/todo/options.py | 12 ++++- hypha/apply/todo/views.py | 15 ++++++ hypha/static_src/sass/components/_form.scss | 10 ++++ hypha/templates/includes/sprites.html | 4 ++ 7 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 hypha/apply/todo/migrations/0005_task_message_alter_task_code.py diff --git a/hypha/apply/activity/forms.py b/hypha/apply/activity/forms.py index 606c34c38e..0b44702d73 100644 --- a/hypha/apply/activity/forms.py +++ b/hypha/apply/activity/forms.py @@ -5,16 +5,31 @@ from pagedown.widgets import PagedownWidget from hypha.apply.stream_forms.fields import MultiFileField +from hypha.apply.todo.options import COMMENT_TASK +from hypha.apply.todo.views import add_manual_task_to_user +from hypha.apply.users.models import STAFF_GROUP_NAME, User from .models import Activity, ActivityAttachment class CommentForm(FileFormMixin, forms.ModelForm): attachments = MultiFileField(label=_("Attachments"), required=False) + assigned_to = forms.ModelChoiceField( + queryset=User.objects.filter(groups__name=STAFF_GROUP_NAME), + required=False, + label=_("Add as task to(optional)"), + help_text=_( + "It will assign comment as task to assigned user. Leave it blank if you don't want to create any task" + ), + ) class Meta: model = Activity - fields = ("message", "visibility") + fields = ( + "message", + "visibility", + "assigned_to", + ) labels = { "visibility": "Visible to", "message": "Message", @@ -47,10 +62,21 @@ def __init__(self, *args, user=None, **kwargs): visibility.choices = self.visibility_choices visibility.initial = visibility.initial[0] visibility.widget = forms.HiddenInput() + if not user.is_apply_staff: + self.fields["assigned_to"].widget = forms.HiddenInput() @transaction.atomic def save(self, commit=True): instance = super().save(commit=True) + assigned_user = self.cleaned_data["assigned_to"] + if assigned_user: + # add task to assigned user + add_manual_task_to_user( + code=COMMENT_TASK, + message=instance.message, + user=assigned_user, + related_obj=instance.source, + ) added_files = self.cleaned_data["attachments"] if added_files: ActivityAttachment.objects.bulk_create( diff --git a/hypha/apply/todo/migrations/0005_task_message_alter_task_code.py b/hypha/apply/todo/migrations/0005_task_message_alter_task_code.py new file mode 100644 index 0000000000..9aa8eb64f1 --- /dev/null +++ b/hypha/apply/todo/migrations/0005_task_message_alter_task_code.py @@ -0,0 +1,49 @@ +# Generated by Django 4.2.11 on 2024-07-29 11:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("todo", "0004_alter_task_code"), + ] + + operations = [ + migrations.AddField( + model_name="task", + name="message", + field=models.CharField(blank=True, max_length=250, null=True), + ), + migrations.AlterField( + model_name="task", + name="code", + field=models.CharField( + choices=[ + ("comment_task", "Comment Task"), + ("submission_draft", "Submission Draft"), + ("determination_draft", "Determination draft"), + ("review_draft", "Review Draft"), + ("project_waiting_paf", "Project waiting PAF"), + ("project_submit_paf", "Project submit PAF"), + ("paf_required_changes", "PAF required changes"), + ("paf_waiting_assignee", "PAF waiting assignee"), + ("paf_waiting_approval", "PAF waiting approval"), + ("project_waiting_contract", "Project waiting contract"), + ( + "project_waiting_contract_document", + "Project waiting contract document", + ), + ( + "project_waiting_contract_review", + "Project waiting contract review", + ), + ("project_waiting_invoice", "Project waiting invoice"), + ("invoice_required_changes", "Invoice required changes"), + ("invoice_waiting_approval", "Invoice waiting approval"), + ("invoice_waiting_paid", "Invoice waiting paid"), + ("report_due", "Report due"), + ], + max_length=50, + ), + ), + ] diff --git a/hypha/apply/todo/models.py b/hypha/apply/todo/models.py index f9dab5ded9..0f94f1193b 100644 --- a/hypha/apply/todo/models.py +++ b/hypha/apply/todo/models.py @@ -28,6 +28,8 @@ class Task(models.Model): ) related_object_id = models.PositiveIntegerField(blank=True, null=True) related_object = GenericForeignKey("related_content_type", "related_object_id") + # for manually added tasks + message = models.CharField(max_length=250, null=True, blank=True) class Meta: ordering = ("-created_at",) diff --git a/hypha/apply/todo/options.py b/hypha/apply/todo/options.py index d67cb9c74d..311748322b 100644 --- a/hypha/apply/todo/options.py +++ b/hypha/apply/todo/options.py @@ -20,8 +20,10 @@ INVOICE_WAITING_APPROVAL = "invoice_waiting_approval" INVOICE_WAITING_PAID = "invoice_waiting_paid" REPORT_DUE = "report_due" +COMMENT_TASK = "comment_task" TASKS_CODE_CHOICES = ( + (COMMENT_TASK, "Comment Task"), (SUBMISSION_DRAFT, "Submission Draft"), (DETERMINATION_DRAFT, "Determination draft"), (REVIEW_DRAFT, "Review Draft"), @@ -42,13 +44,20 @@ template_map = { + # ADD Manual Task + COMMENT_TASK: { + "text": _("{msg}"), + "icon": "comment", + "url": "{link}#communications", + "type": _("Comment"), + }, # SUBMISSIONS ACTIONS # :todo: actions for mupltiple stages of submission SUBMISSION_DRAFT: { "text": _( 'A Submission draft [{related.title}]({link} "{related.title}") is waiting to be submitted' ), - "icon": "edit-draft", + "icon": "comment", "url": "{link}", "type": _("Draft"), }, @@ -194,6 +203,7 @@ def get_task_template(request, task, **kwargs): template_kwargs = { "related": related_obj, "link": link_to(related_obj, request), + "msg": task.message if task.message else "", } template["text"] = template["text"].format(**template_kwargs) template["url"] = template["url"].format(**template_kwargs) diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index a6839b4c1f..39c3ca9fe0 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -131,6 +131,21 @@ def add_task_to_user(code, user, related_obj): return None +def add_manual_task_to_user(code, message, user, related_obj): + """ + Add task for a user + input: + message: message + user: User object + related_obj: Object - Submission, Project, Invoice, Report + output: task - Task object / None in case of no creation + """ + task = Task.objects.create( + code=code, user=user, related_object=related_obj, message=message + ) + return task + + def add_task_to_user_group(code, user_group, related_obj): """ Add task for user_groups diff --git a/hypha/static_src/sass/components/_form.scss b/hypha/static_src/sass/components/_form.scss index 89ca82eb64..ed014755f6 100644 --- a/hypha/static_src/sass/components/_form.scss +++ b/hypha/static_src/sass/components/_form.scss @@ -466,6 +466,10 @@ } } + .form__group { + margin-block-end: 0; + } + // stylelint-disable-next-line selector-class-pattern .id_attachments { grid-area: attachments; @@ -484,6 +488,12 @@ .id_visibility_0 { grid-area: visibility; } + + .id_assigned_to { + display: flex; + align-items: center; + gap: 1rem; + } } } diff --git a/hypha/templates/includes/sprites.html b/hypha/templates/includes/sprites.html index 4d610aa3e4..e817ee12ec 100644 --- a/hypha/templates/includes/sprites.html +++ b/hypha/templates/includes/sprites.html @@ -29,4 +29,8 @@ + + + + From b27afa1b37e1dc95b9d3017dcebb72fabab418de Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Tue, 30 Jul 2024 17:17:54 +0530 Subject: [PATCH 28/34] Show assigned user in comment for staff, link activity directly with task instead of its source --- hypha/apply/activity/forms.py | 2 +- hypha/apply/activity/models.py | 11 +++++++++ .../activity/include/listing_base.html | 3 +++ .../activity/partials/assigned_activity.html | 5 ++++ hypha/apply/activity/urls.py | 3 ++- hypha/apply/activity/views.py | 23 +++++++++++++++++-- hypha/apply/todo/options.py | 2 +- hypha/apply/todo/views.py | 3 +++ 8 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 hypha/apply/activity/templates/activity/partials/assigned_activity.html diff --git a/hypha/apply/activity/forms.py b/hypha/apply/activity/forms.py index 0b44702d73..6fe9c5e0b7 100644 --- a/hypha/apply/activity/forms.py +++ b/hypha/apply/activity/forms.py @@ -75,7 +75,7 @@ def save(self, commit=True): code=COMMENT_TASK, message=instance.message, user=assigned_user, - related_obj=instance.source, + related_obj=instance, ) added_files = self.cleaned_data["attachments"] if added_files: diff --git a/hypha/apply/activity/models.py b/hypha/apply/activity/models.py index 06f8b9edac..75ecf3be94 100644 --- a/hypha/apply/activity/models.py +++ b/hypha/apply/activity/models.py @@ -245,6 +245,17 @@ def priviledged(self): # Not visible to applicant return self.visibility not in [APPLICANT, PARTNER, APPLICANT_PARTNERS, ALL] + # @property + def get_absolute_url(self): + if self.type == COMMENT: + return "{source_link}#communications".format( + source_link=self.source.get_absolute_url() + ) + else: + return "{source_link}#activity_feed".format( + source_link=self.source.get_absolute_url() + ) + @property def private(self): # not visible to all diff --git a/hypha/apply/activity/templates/activity/include/listing_base.html b/hypha/apply/activity/templates/activity/include/listing_base.html index 0179a6d8f0..2eabe360bf 100644 --- a/hypha/apply/activity/templates/activity/include/listing_base.html +++ b/hypha/apply/activity/templates/activity/include/listing_base.html @@ -20,6 +20,9 @@ {% trans "edited" %} {% endif %}

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

+ {% endif %} {% if editable and activity.user == request.user %}

diff --git a/hypha/apply/activity/templates/activity/partials/assigned_activity.html b/hypha/apply/activity/templates/activity/partials/assigned_activity.html new file mode 100644 index 0000000000..892fcbb3e9 --- /dev/null +++ b/hypha/apply/activity/templates/activity/partials/assigned_activity.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% if assigned_to %} +

{% trans "Assigned as task to: " %} {{ assigned_to }}

+{% endif %} diff --git a/hypha/apply/activity/urls.py b/hypha/apply/activity/urls.py index 4ec8389522..b51dc9dbbd 100644 --- a/hypha/apply/activity/urls.py +++ b/hypha/apply/activity/urls.py @@ -1,6 +1,6 @@ from django.urls import include, path -from .views import AttachmentView, NotificationsView +from .views import AttachmentView, NotificationsView, get_activity_assgined_user app_name = "activity" @@ -13,4 +13,5 @@ AttachmentView.as_view(), name="attachment", ), + path("activity//assigned/", get_activity_assgined_user, name="assigned"), ] diff --git a/hypha/apply/activity/views.py b/hypha/apply/activity/views.py index 6f14dad786..58722fc4e7 100644 --- a/hypha/apply/activity/views.py +++ b/hypha/apply/activity/views.py @@ -1,12 +1,15 @@ from django.conf import settings -from django.shortcuts import get_object_or_404 +from django.contrib.auth.decorators import login_required, user_passes_test +from django.contrib.contenttypes.models import ContentType +from django.shortcuts import get_object_or_404, render from django.utils import timezone from django.utils.decorators import method_decorator from django.views.generic import CreateView, ListView from django_ratelimit.decorators import ratelimit from hypha.apply.funds.models.submissions import ApplicationSubmission -from hypha.apply.users.decorators import staff_required +from hypha.apply.todo.models import Task +from hypha.apply.users.decorators import is_apply_staff, staff_required from hypha.apply.utils.storage import PrivateMediaView from hypha.apply.utils.views import DelegatedViewMixin @@ -108,3 +111,19 @@ def get_context_data(self, *, object_list=None, **kwargs): context = super(NotificationsView, self).get_context_data() context["filter"] = self.filterset return context + + +@login_required +@user_passes_test(is_apply_staff) +def get_activity_assgined_user(request, *args, **kwargs): + activity = get_object_or_404(Activity, pk=kwargs.get("pk")) + task = Task.objects.filter( + related_content_type=ContentType.objects.get_for_model(activity).id, + related_object_id=activity.id, + ).first() + assigned_to = task.user if task else None + return render( + request, + "activity/partials/assigned_activity.html", + context={"assigned_to": assigned_to}, + ) diff --git a/hypha/apply/todo/options.py b/hypha/apply/todo/options.py index 311748322b..185fcf1793 100644 --- a/hypha/apply/todo/options.py +++ b/hypha/apply/todo/options.py @@ -48,7 +48,7 @@ COMMENT_TASK: { "text": _("{msg}"), "icon": "comment", - "url": "{link}#communications", + "url": "{link}", "type": _("Comment"), }, # SUBMISSIONS ACTIONS diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index 39c3ca9fe0..cd813aee63 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -85,6 +85,7 @@ def dispatch(self, request, *args, **kwargs): def delete(self, *args, **kwargs): source = self.task.related_object + from hypha.apply.activity.models import Activity from hypha.apply.determinations.models import Determination from hypha.apply.projects.models import Invoice from hypha.apply.review.models import Review @@ -95,6 +96,8 @@ def delete(self, *args, **kwargs): self.task.related_object, Review ): source = self.task.related_object.submission + elif isinstance(self.task.related_object, Activity): + source = self.task.related_object.source messenger( MESSAGES.REMOVE_TASK, user=self.request.user, From 15409f9cb680e6fa7438082b9b64ae173508861a Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 7 Aug 2024 18:21:54 +0530 Subject: [PATCH 29/34] Move assigned to below visibile to, update label and margins --- hypha/apply/activity/forms.py | 6 +----- .../activity/templates/activity/include/listing_base.html | 2 +- .../templates/activity/partials/assigned_activity.html | 2 +- hypha/static_src/sass/components/_form.scss | 4 ++-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hypha/apply/activity/forms.py b/hypha/apply/activity/forms.py index 6fe9c5e0b7..b313315774 100644 --- a/hypha/apply/activity/forms.py +++ b/hypha/apply/activity/forms.py @@ -17,10 +17,7 @@ class CommentForm(FileFormMixin, forms.ModelForm): assigned_to = forms.ModelChoiceField( queryset=User.objects.filter(groups__name=STAFF_GROUP_NAME), required=False, - label=_("Add as task to(optional)"), - help_text=_( - "It will assign comment as task to assigned user. Leave it blank if you don't want to create any task" - ), + label=_("Assign task(optional)"), ) class Meta: @@ -38,7 +35,6 @@ class Meta: "visibility": "Select a relevant user role. Staff can view every comment." } widgets = { - "visibility": forms.RadioSelect(), "message": PagedownWidget(), } diff --git a/hypha/apply/activity/templates/activity/include/listing_base.html b/hypha/apply/activity/templates/activity/include/listing_base.html index 2eabe360bf..1dbd2610a8 100644 --- a/hypha/apply/activity/templates/activity/include/listing_base.html +++ b/hypha/apply/activity/templates/activity/include/listing_base.html @@ -21,7 +21,7 @@ {% endif %}

{% if request.user.is_apply_staff %} -

+

{% endif %} {% if editable and activity.user == request.user %} diff --git a/hypha/apply/activity/templates/activity/partials/assigned_activity.html b/hypha/apply/activity/templates/activity/partials/assigned_activity.html index 892fcbb3e9..0e25f7008e 100644 --- a/hypha/apply/activity/templates/activity/partials/assigned_activity.html +++ b/hypha/apply/activity/templates/activity/partials/assigned_activity.html @@ -1,5 +1,5 @@ {% load i18n %} {% if assigned_to %} -

{% trans "Assigned as task to: " %} {{ assigned_to }}

+ {% trans "Assigned to: " %} {{ assigned_to }} {% endif %} diff --git a/hypha/static_src/sass/components/_form.scss b/hypha/static_src/sass/components/_form.scss index ed014755f6..29a4a8a56d 100644 --- a/hypha/static_src/sass/components/_form.scss +++ b/hypha/static_src/sass/components/_form.scss @@ -454,7 +454,7 @@ grid-template-columns: 1fr; @include media-query(lg) { - grid-template-areas: "message attachments" "message visibility"; + grid-template-areas: "message attachments" "message visibility" "message assigned_to"; grid-template-rows: auto auto; grid-template-columns: 2fr 1fr; column-gap: 2rem; @@ -467,7 +467,7 @@ } .form__group { - margin-block-end: 0; + margin-block-end: 0.5rem; } // stylelint-disable-next-line selector-class-pattern From 7e618956af8e0d946c784a611a8b9e9898823895 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sat, 10 Aug 2024 18:24:36 +0530 Subject: [PATCH 30/34] Remove old form related things --- hypha/apply/todo/forms.py | 24 ----------- .../todo/includes/add_task_form.html | 9 ---- hypha/apply/todo/urls.py | 3 +- hypha/apply/todo/views.py | 43 ------------------- hypha/templates/base.html | 1 - .../includes/menu-notifications.html | 4 +- 6 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 hypha/apply/todo/forms.py delete mode 100644 hypha/apply/todo/templates/todo/includes/add_task_form.html diff --git a/hypha/apply/todo/forms.py b/hypha/apply/todo/forms.py deleted file mode 100644 index 396a013c64..0000000000 --- a/hypha/apply/todo/forms.py +++ /dev/null @@ -1,24 +0,0 @@ -from django import forms - -from .models import Task - - -class TaskCreateForm(forms.ModelForm): - assigned_to = forms.ChoiceField( - choices=(("user", "Single User"), ("user_group", "User Groups")) - ) - msg = forms.CharField(max_length=120) - related_obj = forms.ChoiceField(choices=()) - type = forms.CharField(empty_value="manual", widget=forms.HiddenInput()) - - class Meta: - model = Task - fields = ( - "code", - "assigned_to", - "user", - "user_group", - "msg", - "related_obj", - "type", - ) diff --git a/hypha/apply/todo/templates/todo/includes/add_task_form.html b/hypha/apply/todo/templates/todo/includes/add_task_form.html deleted file mode 100644 index ad160564d8..0000000000 --- a/hypha/apply/todo/templates/todo/includes/add_task_form.html +++ /dev/null @@ -1,9 +0,0 @@ -{% load i18n %} -{% modal_title %}Add Task{% endmodal_title %} - -
- {% csrf_token %} - - {% url 'todo:add' pk=object.pk as task_add_url %} - {% include 'funds/includes/dialog_form_base.html' with form=form value=value url=task_add_url %} -
diff --git a/hypha/apply/todo/urls.py b/hypha/apply/todo/urls.py index babaabe42a..b011facd44 100644 --- a/hypha/apply/todo/urls.py +++ b/hypha/apply/todo/urls.py @@ -1,12 +1,11 @@ from django.urls import path -from .views import TaskCreationView, TaskRemovalView, TodoListView +from .views import TaskRemovalView, TodoListView app_name = "hypha.apply.todo" urlpatterns = [ path("todo/list/", TodoListView.as_view(), name="list"), - path("todo/add/", TaskCreationView.as_view(), name="add"), path("todo//delete/", TaskRemovalView.as_view(), name="delete"), ] diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index cd813aee63..6f68f64e3a 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -1,20 +1,15 @@ -import json - from django.contrib.auth.models import Group from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.db.models import Count -from django.http import HttpResponse from django.shortcuts import get_object_or_404, render from django.utils.decorators import method_decorator -from django.utils.translation import gettext as _ from django.views.generic import ListView, View from django_htmx.http import trigger_client_event from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.users.decorators import staff_required -from .forms import TaskCreateForm from .models import Task from .options import get_task_template from .services import validate_user_groups_uniqueness, validate_user_uniquness @@ -35,44 +30,6 @@ def get_context_data(self, **kwargs): return ctx -@method_decorator(staff_required, name="dispatch") -class TaskCreationView(View): - def dispatch(self, request, *args, **kwargs): - return super().dispatch(request, *args, **kwargs) - - def get(self, *args, **kwargs): - task_form = TaskCreateForm() - return render( - self.request, - "todo/includes/add_task_form.html", - context={ - "form": task_form, - "value": _("Update"), - }, - ) - - def post(self, *args, **kwargs): - form = TaskCreateForm( - self.request.POST, user=self.request.user, instance=self.submission - ) - if form.is_valid(): - form.save() - return HttpResponse( - status=204, - headers={ - "HX-Trigger": json.dumps( - {"taskAdded": None, "showMessage": "Task Added."} - ), - }, - ) - - return render( - self.request, - "todo/includes/add_task_form.html", - context={"form": form, "value": _("Update"), "object": self.task}, - ) - - @method_decorator(staff_required, name="dispatch") class TaskRemovalView(View): def dispatch(self, request, *args, **kwargs): diff --git a/hypha/templates/base.html b/hypha/templates/base.html index 96d22a4da8..189de7ad51 100644 --- a/hypha/templates/base.html +++ b/hypha/templates/base.html @@ -65,7 +65,6 @@ - diff --git a/hypha/templates/includes/menu-notifications.html b/hypha/templates/includes/menu-notifications.html index a0e6d43f14..089a90ab6d 100644 --- a/hypha/templates/includes/menu-notifications.html +++ b/hypha/templates/includes/menu-notifications.html @@ -35,8 +35,8 @@ {% trans "Your Tasks" %} - From d194004857110845c98f786f3302614623504a8c Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Sat, 10 Aug 2024 18:28:10 +0530 Subject: [PATCH 31/34] Fix lint fe --- hypha/static_src/sass/components/_form.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hypha/static_src/sass/components/_form.scss b/hypha/static_src/sass/components/_form.scss index 29a4a8a56d..a56dd89d51 100644 --- a/hypha/static_src/sass/components/_form.scss +++ b/hypha/static_src/sass/components/_form.scss @@ -466,6 +466,7 @@ } } + // stylelint-disable-next-line selector-class-pattern .form__group { margin-block-end: 0.5rem; } @@ -489,6 +490,7 @@ grid-area: visibility; } + // stylelint-disable-next-line selector-class-pattern .id_assigned_to { display: flex; align-items: center; From 9d8f1213ff20868f46c2932a007b7c5dfcc0b736 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Thu, 22 Aug 2024 16:17:54 +0530 Subject: [PATCH 32/34] Update comment form Ui with assigned task --- .../activity/include/comment_form.html | 38 ++++++++++++++++++- hypha/static_src/sass/components/_form.scss | 13 +++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/hypha/apply/activity/templates/activity/include/comment_form.html b/hypha/apply/activity/templates/activity/include/comment_form.html index 3d7e8f78a2..f1061b5e6b 100644 --- a/hypha/apply/activity/templates/activity/include/comment_form.html +++ b/hypha/apply/activity/templates/activity/include/comment_form.html @@ -1,6 +1,40 @@ {% load i18n %}
- {% trans "Submit" as submit %} - {% include "funds/includes/delegated_form_base.html" with form=comment_form value=submit extra_classes="form__comments" %} + {% trans "Submit" as value %} + {% load i18n %} +
+ {% csrf_token %} + + {{ comment_form.media }} + {% for hidden in comment_form.hidden_fields %} + {{ hidden }} + {% endfor %} + +
+ {% for field in comment_form.visible_fields %} + {% if field.field %} + {% include "forms/includes/field.html" %} + {% else %} + {{ field }} + {% endif %} + {% endfor %} + + +
+ +
diff --git a/hypha/static_src/sass/components/_form.scss b/hypha/static_src/sass/components/_form.scss index a56dd89d51..11a731fa98 100644 --- a/hypha/static_src/sass/components/_form.scss +++ b/hypha/static_src/sass/components/_form.scss @@ -449,12 +449,12 @@ &__comments { .fields--visible { display: grid; - grid-template-areas: "message" "attachments" "visibility" "actions"; + grid-template-areas: "message" "attachments" "visibility" "assigned_to" "actions"; grid-template-rows: auto auto auto auto; grid-template-columns: 1fr; @include media-query(lg) { - grid-template-areas: "message attachments" "message visibility" "message assigned_to"; + grid-template-areas: "message attachments" "message visibility" "message assigned_to" "actions assigned_to"; grid-template-rows: auto auto; grid-template-columns: 2fr 1fr; column-gap: 2rem; @@ -466,6 +466,11 @@ } } + // stylelint-disable-next-line selector-class-pattern + .button { + max-width: 150px; + } + // stylelint-disable-next-line selector-class-pattern .form__group { margin-block-end: 0.5rem; @@ -492,9 +497,9 @@ // stylelint-disable-next-line selector-class-pattern .id_assigned_to { + grid-area: assigned_to; display: flex; - align-items: center; - gap: 1rem; + flex-direction: column; } } } From 64b6aa638e9bb82c8b8829d74cac4ebb632738b7 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 28 Aug 2024 12:47:59 +0530 Subject: [PATCH 33/34] Add logic for assigned to at initial load --- hypha/apply/activity/services.py | 18 ++++++++++++++++-- .../activity/include/listing_base.html | 5 +++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hypha/apply/activity/services.py b/hypha/apply/activity/services.py index 706ff718a1..7aa1c1a768 100644 --- a/hypha/apply/activity/services.py +++ b/hypha/apply/activity/services.py @@ -1,3 +1,8 @@ +from django.contrib.contenttypes.models import ContentType +from django.db.models import OuterRef, Subquery + +from hypha.apply.todo.models import Task + from .models import Activity @@ -36,8 +41,7 @@ def get_related_comments_for_user(obj, user): [`Activity`][hypha.apply.activity.models.Activity] queryset """ related_query = type(obj).activities.rel.related_query_name - - return ( + queryset = ( Activity.comments.filter(**{related_query: obj}) .select_related("user") .prefetch_related( @@ -45,3 +49,13 @@ def get_related_comments_for_user(obj, user): ) .visible_to(user) ) + + if user.is_apply_staff: + assigned_to_subquery = Task.objects.filter( + related_content_type=ContentType.objects.get_for_model(Activity), + related_object_id=OuterRef("id"), + ).values("user__full_name") + + queryset = queryset.annotate(assigned_to=Subquery(assigned_to_subquery)) + + return queryset diff --git a/hypha/apply/activity/templates/activity/include/listing_base.html b/hypha/apply/activity/templates/activity/include/listing_base.html index 1dbd2610a8..497ba3012c 100644 --- a/hypha/apply/activity/templates/activity/include/listing_base.html +++ b/hypha/apply/activity/templates/activity/include/listing_base.html @@ -20,8 +20,9 @@ {% trans "edited" %} {% endif %}

- {% if request.user.is_apply_staff %} -

+ + {% if request.user.is_apply_staff and activity.assigned_to %} +

{% trans "Assigned to: " %} {{ activity.assigned_to }}

{% endif %} {% if editable and activity.user == request.user %} From 453587fe6a5bd3921eadce93e2c67b74a0d82833 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 28 Aug 2024 17:33:38 +0530 Subject: [PATCH 34/34] Remove partial urls and view --- .../activity/partials/assigned_activity.html | 5 ---- hypha/apply/activity/urls.py | 3 +-- hypha/apply/activity/views.py | 23 ++----------------- 3 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 hypha/apply/activity/templates/activity/partials/assigned_activity.html diff --git a/hypha/apply/activity/templates/activity/partials/assigned_activity.html b/hypha/apply/activity/templates/activity/partials/assigned_activity.html deleted file mode 100644 index 0e25f7008e..0000000000 --- a/hypha/apply/activity/templates/activity/partials/assigned_activity.html +++ /dev/null @@ -1,5 +0,0 @@ -{% load i18n %} - -{% if assigned_to %} - {% trans "Assigned to: " %} {{ assigned_to }} -{% endif %} diff --git a/hypha/apply/activity/urls.py b/hypha/apply/activity/urls.py index b51dc9dbbd..4ec8389522 100644 --- a/hypha/apply/activity/urls.py +++ b/hypha/apply/activity/urls.py @@ -1,6 +1,6 @@ from django.urls import include, path -from .views import AttachmentView, NotificationsView, get_activity_assgined_user +from .views import AttachmentView, NotificationsView app_name = "activity" @@ -13,5 +13,4 @@ AttachmentView.as_view(), name="attachment", ), - path("activity//assigned/", get_activity_assgined_user, name="assigned"), ] diff --git a/hypha/apply/activity/views.py b/hypha/apply/activity/views.py index 58722fc4e7..6f14dad786 100644 --- a/hypha/apply/activity/views.py +++ b/hypha/apply/activity/views.py @@ -1,15 +1,12 @@ from django.conf import settings -from django.contrib.auth.decorators import login_required, user_passes_test -from django.contrib.contenttypes.models import ContentType -from django.shortcuts import get_object_or_404, render +from django.shortcuts import get_object_or_404 from django.utils import timezone from django.utils.decorators import method_decorator from django.views.generic import CreateView, ListView from django_ratelimit.decorators import ratelimit from hypha.apply.funds.models.submissions import ApplicationSubmission -from hypha.apply.todo.models import Task -from hypha.apply.users.decorators import is_apply_staff, staff_required +from hypha.apply.users.decorators import staff_required from hypha.apply.utils.storage import PrivateMediaView from hypha.apply.utils.views import DelegatedViewMixin @@ -111,19 +108,3 @@ def get_context_data(self, *, object_list=None, **kwargs): context = super(NotificationsView, self).get_context_data() context["filter"] = self.filterset return context - - -@login_required -@user_passes_test(is_apply_staff) -def get_activity_assgined_user(request, *args, **kwargs): - activity = get_object_or_404(Activity, pk=kwargs.get("pk")) - task = Task.objects.filter( - related_content_type=ContentType.objects.get_for_model(activity).id, - related_object_id=activity.id, - ).first() - assigned_to = task.user if task else None - return render( - request, - "activity/partials/assigned_activity.html", - context={"assigned_to": assigned_to}, - )