diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index bb31213dd5fc3479e524a3362b16f4e72487e682..015d4d55a6d3c40f3cfca37b9995a88172b11ad9 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -46,6 +46,8 @@ from hypha.apply.funds.services import ( from hypha.apply.review.options import AGREE from hypha.apply.stream_forms.files import StreamFieldDataEncoder from hypha.apply.stream_forms.models import BaseStreamForm +from hypha.apply.todo.options import SUBMISSION_DRAFT +from hypha.apply.todo.views import remove_tasks_for_user from hypha.apply.users.groups import APPLICANT_GROUP_NAME from ..blocks import NAMED_BLOCKS, ApplicationCustomFormFieldsBlock @@ -999,6 +1001,9 @@ def log_status_update(sender, **kwargs): if request and notify: if kwargs["source"] == DRAFT_STATE: + # remove task from applicant dashboard for this instance + remove_tasks_for_user(code=SUBMISSION_DRAFT, user=by, related_obj=instance) + # notify for a new submission messenger( MESSAGES.NEW_SUBMISSION, request=request, diff --git a/hypha/apply/funds/models/utils.py b/hypha/apply/funds/models/utils.py index 66f577d3012d81bd045e6bc2e165e158eb2cc799..6d8081a11ab486cf63fca18df602fba5846b9aa4 100644 --- a/hypha/apply/funds/models/utils.py +++ b/hypha/apply/funds/models/utils.py @@ -15,6 +15,8 @@ from wagtail.contrib.forms.models import AbstractEmailForm from hypha.apply.activity.messaging import messenger from hypha.apply.activity.options import MESSAGES from hypha.apply.stream_forms.models import AbstractStreamForm +from hypha.apply.todo.options import SUBMISSION_DRAFT +from hypha.apply.todo.views import add_task_to_user from hypha.apply.users.groups import ( COMMUNITY_REVIEWER_GROUP_NAME, PARTNER_GROUP_NAME, @@ -116,7 +118,7 @@ class WorkflowStreamForm(WorkflowHelpers, AbstractStreamForm): # type: ignore def render_landing_page(self, request, form_submission=None, *args, **kwargs): # We only reach this page after creation of a new submission - # Hook in to notify about new applications + # Hook in to notify about new applications and add task for draft submissions if form_submission.status == DRAFT_STATE: messenger( MESSAGES.DRAFT_SUBMISSION, @@ -124,6 +126,12 @@ class WorkflowStreamForm(WorkflowHelpers, AbstractStreamForm): # type: ignore user=form_submission.user, source=form_submission, ) + # add a task of draft submission to applicant dashboard + add_task_to_user( + code=SUBMISSION_DRAFT, + user=form_submission.user, + related_obj=form_submission, + ) else: messenger( MESSAGES.NEW_SUBMISSION, diff --git a/hypha/apply/todo/migrations/0004_alter_task_code.py b/hypha/apply/todo/migrations/0004_alter_task_code.py new file mode 100644 index 0000000000000000000000000000000000000000..b2f660d8de8f01747366940b3b1cc1b0667d6bce --- /dev/null +++ b/hypha/apply/todo/migrations/0004_alter_task_code.py @@ -0,0 +1,43 @@ +# Generated by Django 4.2.11 on 2024-05-19 09:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("todo", "0003_alter_task_code"), + ] + + operations = [ + migrations.AlterField( + model_name="task", + name="code", + field=models.CharField( + choices=[ + ("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/options.py b/hypha/apply/todo/options.py index 6d754d284acd1eb578b3dab92e3e76b08a05dffc..7544146369dd4e68d86eebaded89550f2de5b1a7 100644 --- a/hypha/apply/todo/options.py +++ b/hypha/apply/todo/options.py @@ -4,6 +4,7 @@ from django.utils.translation import gettext as _ from hypha.apply.activity.adapters.utils import link_to +SUBMISSION_DRAFT = "submission_draft" DETERMINATION_DRAFT = "determination_draft" REVIEW_DRAFT = "review_draft" PROJECT_WAITING_PAF = "project_waiting_paf" @@ -21,6 +22,7 @@ INVOICE_WAITING_PAID = "invoice_waiting_paid" REPORT_DUE = "report_due" TASKS_CODE_CHOICES = ( + (SUBMISSION_DRAFT, "Submission Draft"), (DETERMINATION_DRAFT, "Determination draft"), (REVIEW_DRAFT, "Review Draft"), (PROJECT_WAITING_PAF, "Project waiting PAF"), @@ -42,9 +44,17 @@ TASKS_CODE_CHOICES = ( template_map = { # SUBMISSIONS ACTIONS # :todo: actions for mupltiple stages of submission + SUBMISSION_DRAFT: { + "text": _( + 'A Submission draft [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting to be submitted' + ), + "icon": "edit-draft", + "url": "{link}", + "type": _("Draft"), + }, DETERMINATION_DRAFT: { "text": _( - 'Determination draft for submission [<span class=" truncate inline-block max-w-32 align-bottom ">{related.submission.title}</span>]({link} "{related.submission.title}") is waiting to be submitted', + 'Determination draft for submission [<span class="truncate inline-block max-w-32 align-bottom ">{related.submission.title}</span>]({link} "{related.submission.title}") is waiting to be submitted', ), "icon": "edit-draft", "url": "{link}", @@ -52,7 +62,7 @@ template_map = { }, REVIEW_DRAFT: { "text": _( - 'Review draft for submission [<span class=" truncate inline-block max-w-32 align-bottom ">{related.submission.title}</span>]({link} "{related.submission.title}") is waiting to be submitted' + 'Review draft for submission [<span class="truncate inline-block max-w-32 align-bottom ">{related.submission.title}</span>]({link} "{related.submission.title}") is waiting to be submitted' ), "icon": "edit-draft", "url": "{link}", @@ -61,20 +71,24 @@ template_map = { # PROJECT actions # draft state (staff action) PROJECT_WAITING_PAF: { - "text": _("Project [{related.title}]({link}) is waiting for PAF"), + "text": _( + 'Project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for PAF' + ), "icon": "dashboard-paf", "url": "{link}", "type": _("project"), }, PROJECT_SUBMIT_PAF: { - "text": _("Project [{related.title}]({link}) is waiting for PAF submission"), + "text": _( + 'Project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for PAF submission' + ), "icon": "dashboard-paf", "url": "{link}", "type": _("project"), }, PAF_REQUIRED_CHANGES: { "text": _( - "PAF for project [{related.title}]({link}) required changes or more information" + 'PAF for project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") required changes or more information' ), "icon": "dashboard-paf", "url": "{link}", @@ -82,14 +96,16 @@ template_map = { }, # internal approval state (approvers/finance... action) PAF_WAITING_ASSIGNEE: { - "text": _("PAF for project [{related.title}]({link}) is waiting for assignee"), + "text": _( + 'PAF for project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for assignee' + ), "icon": "dashboard-paf", "url": "{link}", "type": _("project"), }, PAF_WAITING_APPROVAL: { "text": _( - "PAF for project [{related.title}]({link}) is waiting for your approval" + 'PAF for project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for your approval' ), "icon": "dashboard-paf", "url": "{link}", @@ -97,14 +113,16 @@ template_map = { }, # contracting state (vendor/staff/contracting team action) PROJECT_WAITING_CONTRACT: { - "text": _("Project [{related.title}]({link}) is waiting for contract"), + "text": _( + 'Project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for contract' + ), "icon": "dashboard-contract", "url": "{link}", "type": _("project"), }, PROJECT_WAITING_CONTRACT_DOCUMENT: { "text": _( - "Project [{related.title}]({link}) is waiting for contracting documents" + 'Project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for contracting documents' ), "icon": "dashboard-document", "url": "{link}", @@ -112,7 +130,7 @@ template_map = { }, PROJECT_WAITING_CONTRACT_REVIEW: { "text": _( - "Contract for project [{related.title}]({link}) is waiting for review" + 'Contract for project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for review' ), "icon": "dashboard-contract", "url": "{link}", @@ -120,7 +138,9 @@ template_map = { }, # invoicing and reporting (vendor/staff/finance team action) PROJECT_WAITING_INVOICE: { - "text": _("Project [{related.title}]({link}) is waiting for invoice"), + "text": _( + 'Project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is waiting for invoice' + ), "icon": "dashboard-invoice", "url": "{link}", "type": _("project"), @@ -148,7 +168,9 @@ template_map = { "type": _("project"), }, REPORT_DUE: { - "text": _("Report for project [{related.title}]({link}) is due"), + "text": _( + 'Report for project [<span class="truncate inline-block max-w-32 align-bottom ">{related.title}</span>]({link} "{related.title}") is due' + ), "icon": "dashboard-report", "url": "{link}", "type": _("project"),