Skip to content

Commit

Permalink
Merge pull request #3764 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
robertavram authored Sep 13, 2024
2 parents d10e48b + dc5150a commit c47eca3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/etools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = __version__ = '11.6'
VERSION = __version__ = '11.7'
NAME = 'eTools'
22 changes: 12 additions & 10 deletions src/etools/applications/partners/views/interventions_v3_actions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.db import connection, transaction
from django.db.models import OuterRef, Subquery
from django.http import HttpResponseForbidden
from django.urls import reverse
from django.utils import timezone
Expand Down Expand Up @@ -29,6 +29,7 @@
)
from etools.applications.partners.tasks import send_pd_to_vision
from etools.applications.partners.views.interventions_v3 import InterventionDetailAPIView, PMPInterventionMixin
from etools.applications.users.models import Realm
from etools.applications.utils.helpers import lock_request


Expand Down Expand Up @@ -337,11 +338,16 @@ def update(self, request, *args, **kwargs):
template_name = 'partners/intervention/unicef_signature'
else:
template_name = 'partners/intervention/unicef_sent_for_review'
active_prc_realm_subquery = Realm.objects.filter(
country=connection.tenant,
group__name=PRC_SECRETARY,
is_active=True,
pk=OuterRef('realms')
).values('pk')
recipients = recipients.union(set(
get_user_model().objects.filter(
profile__country=connection.tenant,
realms__group=Group.objects.get(name=PRC_SECRETARY),
).distinct().values_list('email', flat=True)
get_user_model().objects.filter(profile__country=connection.tenant,
realms__in=Subquery(active_prc_realm_subquery),
).distinct().values_list('email', flat=True)
))

self.send_notification(
Expand All @@ -362,11 +368,7 @@ def update(self, request, *args, **kwargs):
if pd.status == Intervention.CANCELLED:
raise ValidationError(_("PD has already been cancelled."))

if not get_user_model().objects.filter(
pk=request.user.pk,
realms__group__name__in=[PRC_SECRETARY],
profile__country=request.user.profile.country
).exists():
if not request.user.groups.filter(name=PRC_SECRETARY).exists():
raise ValidationError(_("Only PRC Secretary can cancel"))

request.data.update({"status": Intervention.CANCELLED})
Expand Down

0 comments on commit c47eca3

Please sign in to comment.