diff --git a/hypha/apply/activity/adapters/activity_feed.py b/hypha/apply/activity/adapters/activity_feed.py index e39c079b8996fee2ecbc03b79e86e172b1446201..9a968aeea99f239da5376139b0812a0a2cd8e681 100644 --- a/hypha/apply/activity/adapters/activity_feed.py +++ b/hypha/apply/activity/adapters/activity_feed.py @@ -4,7 +4,7 @@ from django.db.models import Model as DjangoModel from django.utils import timezone from django.utils.translation import gettext as _ -from hypha.apply.activity.models import ALL, TEAM +from hypha.apply.activity.models import ALL, APPLICANT, TEAM from hypha.apply.activity.options import MESSAGES from hypha.apply.projects.utils import ( get_invoice_public_status, @@ -44,7 +44,7 @@ class ActivityAdapter(AdapterBase): MESSAGES.DELETE_REVIEW_OPINION: _( "{user} deleted the opinion for review: {review_opinion.review}" ), - MESSAGES.CREATED_PROJECT: _("Created"), + MESSAGES.CREATED_PROJECT: _("Created project"), MESSAGES.PROJECT_TRANSITION: "handle_project_transition", MESSAGES.UPDATE_PROJECT_LEAD: _( "Lead changed from {old_lead} to {source.lead}" @@ -71,6 +71,7 @@ class ActivityAdapter(AdapterBase): MESSAGES.UNARCHIVE_SUBMISSION: _( "{user} has unarchived the submission: {source.title}" ), + MESSAGES.DELETE_INVOICE: _("Deleted an invoice"), } def recipients(self, message_type, **kwargs): @@ -89,9 +90,21 @@ class ActivityAdapter(AdapterBase): MESSAGES.REQUEST_PROJECT_CHANGE, MESSAGES.SEND_FOR_APPROVAL, MESSAGES.NEW_REVIEW, + MESSAGES.UPDATE_PROJECT_LEAD, ]: return {"visibility": TEAM} + if message_type in [ + MESSAGES.CREATED_PROJECT, + MESSAGES.APPROVE_CONTRACT, + MESSAGES.UPLOAD_CONTRACT, + MESSAGES.SUBMIT_CONTRACT_DOCUMENTS, + MESSAGES.UPDATE_INVOICE_STATUS, + MESSAGES.DELETE_INVOICE, + MESSAGES.CREATE_INVOICE, + ]: + return {"visibility": APPLICANT} + source = source or sources[0] if is_transition(message_type) and not source.phase.permissions.can_view( source.user diff --git a/hypha/apply/projects/views/payment.py b/hypha/apply/projects/views/payment.py index 1a876dd47aa0ca8cf9fcd5b133efcfc6fb7e7540..a29fda24881ad69ff8d4e81031366335d8fa783b 100644 --- a/hypha/apply/projects/views/payment.py +++ b/hypha/apply/projects/views/payment.py @@ -13,7 +13,7 @@ from django_filters.views import FilterView from django_tables2 import SingleTableMixin from hypha.apply.activity.messaging import MESSAGES, messenger -from hypha.apply.activity.models import ALL, COMMENT, Activity +from hypha.apply.activity.models import APPLICANT, COMMENT, Activity from hypha.apply.users.decorators import staff_or_finance_required from hypha.apply.utils.storage import PrivateMediaView from hypha.apply.utils.views import DelegateableView, DelegatedViewMixin, ViewDispatcher @@ -73,7 +73,7 @@ class ChangeInvoiceStatusView(DelegatedViewMixin, InvoiceAccessMixin, UpdateView source=self.object.project, timestamp=timezone.now(), message=message, - visibility=ALL, + visibility=APPLICANT, related_object=self.object, ) @@ -212,7 +212,7 @@ class CreateInvoiceView(CreateView): source=self.project, timestamp=timezone.now(), message=message, - visibility=ALL, + visibility=APPLICANT, related_object=self.object, ) @@ -293,7 +293,7 @@ class EditInvoiceView(InvoiceAccessMixin, UpdateView): source=self.object.project, timestamp=timezone.now(), message=message, - visibility=ALL, + visibility=APPLICANT, related_object=self.object, ) diff --git a/hypha/apply/projects/views/project.py b/hypha/apply/projects/views/project.py index aa58efdd9705ed6f9e0b3880aa5b95bf6db95494..84d80769d512e8f6e4d4ebf7d8f0704780fe8428 100644 --- a/hypha/apply/projects/views/project.py +++ b/hypha/apply/projects/views/project.py @@ -37,7 +37,7 @@ from xhtml2pdf import pisa from hypha.apply.activity.adapters.utils import get_users_for_groups from hypha.apply.activity.messaging import MESSAGES, messenger -from hypha.apply.activity.models import ACTION, ALL, COMMENT, Activity +from hypha.apply.activity.models import ACTION, ALL, COMMENT, TEAM, Activity from hypha.apply.activity.views import ActivityContextMixin, CommentFormView from hypha.apply.stream_forms.models import BaseStreamForm from hypha.apply.users.decorators import ( @@ -535,13 +535,6 @@ class UploadContractDocumentView(DelegatedViewMixin, CreateView): form.instance.project = project response = super().form_valid(form) - messenger( - MESSAGES.UPLOAD_DOCUMENT, - request=self.request, - user=self.request.user, - source=project, - ) - messages.success( self.request, _("Contracting document has been uploaded"), @@ -610,10 +603,11 @@ class ChangePAFStatusView(DelegatedViewMixin, UpdateView): source=self.object, timestamp=timezone.now(), message=paf_status_update_message, - visibility=ALL, + visibility=TEAM, ) if paf_status == REQUEST_CHANGE: + old_stage = self.object.status self.object.status = DRAFT self.object.save(update_fields=["status"]) paf_approval.save() @@ -629,6 +623,13 @@ class ChangePAFStatusView(DelegatedViewMixin, UpdateView): source=self.object, comment=comment, ) + messenger( + MESSAGES.PROJECT_TRANSITION, + request=self.request, + user=self.request.user, + source=self.object, + related=old_stage, + ) messages.success( self.request, _("PAF status has been updated"), @@ -673,7 +674,7 @@ class ChangePAFStatusView(DelegatedViewMixin, UpdateView): source=self.object, timestamp=timezone.now(), message=message, - visibility=ALL, + visibility=TEAM, ) if self.object.is_approved_by_all_paf_reviewers: