Skip to content

Commit

Permalink
Merge branch 'master' into hu/ent-8713
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 authored May 13, 2024
2 parents 7346f99 + cd5b8a9 commit 273ddb4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ Unreleased
[4.18.0]
--------
* feat: updates tasks usage of create_recipient to create_recipients
=======
[4.17.8]
--------
* fix: adding missing migration file

[4.17.7]
--------
* fix: update group invite and removal notification tasks

[4.17.6]
--------
* fix: allowing for search lookup of group members in django admin

[4.17.5]
--------
Expand Down
7 changes: 4 additions & 3 deletions enterprise/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,9 +1203,10 @@ class EnterpriseGroupMembershipAdmin(admin.ModelAdmin):
list_display = ('group', 'membership_user',)
search_fields = (
'uuid',
'group__enterprise_customer_user',
'enterprise_customer_user',
'pending_enterprise_customer_user',
'group__uuid',
'group__enterprise_customer__uuid',
'enterprise_customer_user__id',
'pending_enterprise_customer_user__user_email',
)
autocomplete_fields = (
'group',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.13 on 2024-05-09 18:15

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('enterprise', '0206_auto_20240408_1344'),
]

operations = [
migrations.AlterField(
model_name='enterprisegroupmembership',
name='enterprise_customer_user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='memberships', to='enterprise.enterprisecustomeruser'),
),
migrations.AlterField(
model_name='enterprisegroupmembership',
name='pending_enterprise_customer_user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='memberships', to='enterprise.pendingenterprisecustomeruser'),
),
]
11 changes: 11 additions & 0 deletions enterprise/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ def send_group_membership_invitation_notification(
recipients = []
for pecu_email in pecu_emails:
recipients.append(braze_client_instance.create_recipient_no_external_id(pecu_email))
if pecu_emails:
braze_client_instance.create_braze_alias(
pecu_emails,
ENTERPRISE_BRAZE_ALIAS_LABEL,
)
braze_client_instance.create_braze_alias(
[pecu_emails],
ENTERPRISE_BRAZE_ALIAS_LABEL,
Expand Down Expand Up @@ -357,8 +362,14 @@ def send_group_membership_removal_notification(enterprise_customer_uuid, members
] = group_membership.enterprise_customer_user.user_id

recipients = []

for pecu_email in pecu_emails:
recipients.append(braze_client_instance.create_recipient_no_external_id(pecu_email))
if pecu_emails:
braze_client_instance.create_braze_alias(
pecu_emails,
ENTERPRISE_BRAZE_ALIAS_LABEL,
)
braze_client_instance.create_braze_alias(
[pecu_emails],
ENTERPRISE_BRAZE_ALIAS_LABEL,
Expand Down
10 changes: 8 additions & 2 deletions tests/test_enterprise/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pytest import mark

from enterprise.api_client.braze import ENTERPRISE_BRAZE_ALIAS_LABEL
from enterprise.constants import SSO_BRAZE_CAMPAIGN_ID
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseEnrollmentSource, EnterpriseGroupMembership
from enterprise.settings.test import BRAZE_GROUPS_INVITATION_EMAIL_CAMPAIGN_ID, BRAZE_GROUPS_REMOVAL_EMAIL_CAMPAIGN_ID
Expand Down Expand Up @@ -203,7 +204,7 @@ def test_send_group_membership_invitation_notification(self, mock_braze_api_clie
"""
EnterpriseGroupMembershipFactory(
group=self.enterprise_group,
pending_enterprise_customer_user=PendingEnterpriseCustomerUserFactory(),
pending_enterprise_customer_user=self.pending_enterprise_customer_user,
enterprise_customer_user=None,
)
EnterpriseGroupMembershipFactory(
Expand Down Expand Up @@ -263,6 +264,8 @@ def test_send_group_membership_invitation_notification(self, mock_braze_api_clie
},
)]
mock_braze_api_client().send_campaign_message.assert_has_calls(calls)
mock_braze_api_client().create_braze_alias.assert_called_once_with(
[self.pending_enterprise_customer_user.user_email], ENTERPRISE_BRAZE_ALIAS_LABEL)

@mock.patch('enterprise.tasks.EnterpriseCatalogApiClient', return_value=mock.MagicMock())
@mock.patch('enterprise.tasks.BrazeAPIClient', return_value=mock.MagicMock())
Expand All @@ -272,7 +275,7 @@ def test_send_group_membership_removal_notification(self, mock_braze_api_client,
"""
EnterpriseGroupMembershipFactory(
group=self.enterprise_group,
pending_enterprise_customer_user=PendingEnterpriseCustomerUserFactory(),
pending_enterprise_customer_user=self.pending_enterprise_customer_user,
enterprise_customer_user=None,
)
EnterpriseGroupMembershipFactory(
Expand Down Expand Up @@ -328,6 +331,9 @@ def test_send_group_membership_removal_notification(self, mock_braze_api_client,
'catalog_content_count': mock_catalog_content_count,
},
)]

mock_braze_api_client().create_braze_alias.assert_called_once_with(
[self.pending_enterprise_customer_user.user_email], ENTERPRISE_BRAZE_ALIAS_LABEL)
mock_braze_api_client().send_campaign_message.assert_has_calls(calls)

@mock.patch('enterprise.tasks.BrazeAPIClient', return_value=mock.MagicMock())
Expand Down

0 comments on commit 273ddb4

Please sign in to comment.