Skip to content

Commit

Permalink
fix: setting existing user membership status (#2157)
Browse files Browse the repository at this point in the history
* fix: setting existing user membership status

* fix: add test

* fix: version bump
  • Loading branch information
kiram15 authored Jun 27, 2024
1 parent 98f2474 commit a62854f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[4.20.11]
---------
* fix: setting existing user group membership statuses

[4.20.10]
---------
* fix: fixing the status and datetime of removed group memberships
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.20.10"
__version__ = "4.20.11"
2 changes: 2 additions & 0 deletions enterprise/api/v1/views/enterprise_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,11 @@ def assign_learners(self, request, group_uuid):
user_emails_to_create.extend(set(user_email_batch).difference(set(ecu_by_email.keys())))

# Extend the list of memberships that need to be created associated with existing Users
# All existing users will have the status automatically set to accepted
ent_customer_users = [
models.EnterpriseGroupMembership(
activated_at=localized_utcnow(),
status=constants.GROUP_MEMBERSHIP_ACCEPTED_STATUS,
enterprise_customer_user=ecu,
group=group
)
Expand Down
25 changes: 13 additions & 12 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8432,18 +8432,19 @@ def test_successful_assign_learners_to_group(self, mock_send_group_membership_in
response = self.client.post(url, data=request_data)
assert response.status_code == 201
assert response.data == {'records_processed': 800, 'new_learners': 400, 'existing_learners': 400}
assert len(
EnterpriseGroupMembership.objects.filter(
group=self.group_2,
pending_enterprise_customer_user__isnull=True
)
) == 400
assert len(
EnterpriseGroupMembership.objects.filter(
group=self.group_2,
enterprise_customer_user__isnull=True
)
) == 400

pending_memberships = EnterpriseGroupMembership.objects.filter(
group=self.group_2,
enterprise_customer_user__isnull=True
)
existing_memberships = EnterpriseGroupMembership.objects.filter(
group=self.group_2,
pending_enterprise_customer_user__isnull=True
)
assert len(pending_memberships) == 400
assert len(existing_memberships) == 400
assert existing_memberships.first().status == GROUP_MEMBERSHIP_ACCEPTED_STATUS
assert pending_memberships.first().status == GROUP_MEMBERSHIP_PENDING_STATUS

# Batch size for sending membership invitation notifications is 200, 800 total records means 4 iterations
group_uuids = list(
Expand Down

0 comments on commit a62854f

Please sign in to comment.