diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index 485f3f236cf7233ffaf489e4c7184a11e55f8fa2..2c7e705561bc78ce7eda510adf8c8b1ab7430845 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -10,18 +10,19 @@ from django.db import models from django.template.loader import render_to_string from django.utils import timezone from django.utils.translation import gettext as _ + from hypha.apply.projects.models.payment import ( - SUBMITTED, - RESUBMITTED, - CHANGES_REQUESTED_BY_STAFF, - CHANGES_REQUESTED_BY_FINANCE_1, - CHANGES_REQUESTED_BY_FINANCE_2, - APPROVED_BY_STAFF, APPROVED_BY_FINANCE_1, APPROVED_BY_FINANCE_2, - PAID, + APPROVED_BY_STAFF, + CHANGES_REQUESTED_BY_FINANCE_1, + CHANGES_REQUESTED_BY_FINANCE_2, + CHANGES_REQUESTED_BY_STAFF, DECLINED, + RESUBMITTED, + SUBMITTED, ) + from .models import ALL, TEAM from .options import MESSAGES from .tasks import send_mail @@ -530,7 +531,6 @@ class SlackAdapter(AdapterBase): def batch_recipients(self, message_type, sources, **kwargs): # We group the messages by lead - import ipdb; ipdb.set_trace() leads = User.objects.filter(id__in=sources.values('lead')) return [ { @@ -921,6 +921,12 @@ class EmailAdapter(AdapterBase): if message_type in {MESSAGES.REVIEW_REMINDER}: return self.reviewers(source) + if message_type == MESSAGES.UPDATE_INVOICE_STATUS: + related = kwargs.get('related', None) + if related: + if related.status in {CHANGES_REQUESTED_BY_STAFF, DECLINED}: + return [source.user.email] + return [] return [source.user.email] def batch_recipients(self, message_type, sources, **kwargs): diff --git a/hypha/apply/api/v1/permissions.py b/hypha/apply/api/v1/permissions.py index 14fc918bf4d5a6d921ca8a7449a258d69ba19b74..ac3fa7f5420c29397bc2d760413cdf0d452ce157 100644 --- a/hypha/apply/api/v1/permissions.py +++ b/hypha/apply/api/v1/permissions.py @@ -25,6 +25,7 @@ class IsFinance1User(permissions.BasePermission): def has_object_permission(self, request, view, obj): return request.user.is_finance_level_1 + class IsFinance2User(permissions.BasePermission): def has_permission(self, request, view): return request.user.is_finance_level_2 diff --git a/hypha/apply/api/v1/projects/views.py b/hypha/apply/api/v1/projects/views.py index f011ca790a3c866e3546f8280c2d851a22e785f8..e2df70ff63352f356402023eeba46834e280c99f 100644 --- a/hypha/apply/api/v1/projects/views.py +++ b/hypha/apply/api/v1/projects/views.py @@ -10,10 +10,12 @@ from hypha.apply.projects.models.project import Deliverable from ..mixin import InvoiceNestedMixin, ProjectNestedMixin from ..permissions import ( - IsApplyStaffUser, IsFinance1User, IsFinance2User, - HasDeliverableEditPermission, HasRequiredChecksPermission + HasDeliverableEditPermission, + HasRequiredChecksPermission, + IsApplyStaffUser, + IsFinance1User, + IsFinance2User, ) - from .serializers import ( DeliverableSerializer, InvoiceDeliverableListSerializer, diff --git a/hypha/apply/projects/views/project.py b/hypha/apply/projects/views/project.py index 9d9175be59a3ef5bf795e7bbaf8d7015d32acc6a..0bc20a25b5412743d83651d0da37320183d4bf33 100644 --- a/hypha/apply/projects/views/project.py +++ b/hypha/apply/projects/views/project.py @@ -119,7 +119,7 @@ class CreateApprovalView(DelegatedViewMixin, CreateView): source=project, ) - project.send_to_compliance(self.request) + # project.send_to_compliance(self.request) project.is_locked = False project.status = CONTRACTING diff --git a/hypha/apply/users/models.py b/hypha/apply/users/models.py index 4ed4890956e7e96e547d3ed61795551547c83293..f23aeab93173db51c7d1819762e70fb7e106d9fe 100644 --- a/hypha/apply/users/models.py +++ b/hypha/apply/users/models.py @@ -148,7 +148,7 @@ class User(AbstractUser): @cached_property def is_apply_staff(self): return self.groups.filter(name=STAFF_GROUP_NAME).exists() or self.is_superuser - + @cached_property def is_apply_staff_or_finance(self): return self.is_apply_staff or self.is_finance