Skip to content

Commit cfc6e1e

Browse files
Merge pull request #1681 from IFRCGo/fix/frontend-2641-ongoing-deployments-by-event
Adding start_date check. Using all email addresses in all envs
2 parents d1530ae + 77412cc commit cfc6e1e

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def get_organizations_from(obj):
652652
deployments = [d for d in obj.personneldeployment_set.all()]
653653
personnels = []
654654
for d in deployments:
655-
for p in d.personnel_set.filter(end_date__gte=timezone.now(), is_active=True):
655+
for p in d.personnel_set.filter(end_date__gte=timezone.now(), start_date__lte=timezone.now(), is_active=True):
656656
personnels.append(p)
657657
return list(set([p.country_from.society_name for p in personnels if p.country_from and p.country_from.society_name != '']))
658658

notifications/notification.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,25 @@ def send_notification(subject, recipients, html, mailtype='', files=None):
8585
print(f'\n{html}\n')
8686
print('-' * 22, 'EMAIL END -', '-' * 22)
8787

88-
# If it's not PROD only able to use test e-mail addresses which are set in the env var
8988
to_addresses = recipients if isinstance(recipients, list) else [recipients]
9089

91-
if not IS_PROD:
92-
logger.info('Using test email addresses...')
93-
to_addresses = []
94-
logger.info(to_addresses)
95-
for eml in settings.TEST_EMAILS:
96-
97-
# It is possible to filter test addressees to domain name only – not used.
98-
is_dom = True if '@' not in eml else False
99-
if is_dom:
100-
for rec in recipients:
101-
try:
102-
if eml == rec.split('@')[1]:
103-
to_addresses.append(rec)
104-
except Exception:
105-
logger.info('Could not extract domain from: {}'.format(rec))
106-
elif eml and (eml in recipients):
107-
to_addresses.append(eml)
90+
# if not IS_PROD:
91+
# logger.info('Using test email addresses...')
92+
# to_addresses = []
93+
# logger.info(to_addresses)
94+
# for eml in settings.TEST_EMAILS:
95+
#
96+
# # It is possible to filter test addressees to domain name only – not used.
97+
# is_dom = True if '@' not in eml else False
98+
# if is_dom:
99+
# for rec in recipients:
100+
# try:
101+
# if eml == rec.split('@')[1]:
102+
# to_addresses.append(rec)
103+
# except Exception:
104+
# logger.info('Could not extract domain from: {}'.format(rec))
105+
# elif eml and (eml in recipients):
106+
# to_addresses.append(eml)
108107

109108
recipients_as_string = ','.join(to_addresses)
110109
if not recipients_as_string:

0 commit comments

Comments
 (0)