Skip to content

Commit

Permalink
Merge branch 'master' of github.com:openedx/edx-enterprise into Mueez…
Browse files Browse the repository at this point in the history
…Khan/Encryption-Fields-Added-To-BlackboardGlobal
  • Loading branch information
MueezKhan246 committed Apr 30, 2024
2 parents 3d23e30 + b30264c commit fd06e4c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Change Log
Unreleased
----------
[4.16.5]
--------
* feat: splitting out group membership serializer learner id into lms user ID and ecu ID

[4.16.4]
--------
* revert: fix: set default langauge for all learners linked with an enteprise customer
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.16.4"
__version__ = "4.16.5"
14 changes: 10 additions & 4 deletions enterprise/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,13 @@ class EnterpriseGroupMembershipSerializer(serializers.ModelSerializer):
"""
Serializer for EnterpriseGroupMembership model.
"""
learner_id = serializers.IntegerField(source='enterprise_customer_user.id', allow_null=True)
pending_learner_id = serializers.IntegerField(source='pending_enterprise_customer_user.id', allow_null=True)
enterprise_customer_user_id = serializers.IntegerField(source='enterprise_customer_user.id', allow_null=True)
lms_user_id = serializers.IntegerField(source='enterprise_customer_user.user_id', allow_null=True)
pending_enterprise_customer_user_id = serializers.IntegerField(
source='pending_enterprise_customer_user.id', allow_null=True
)
enterprise_group_membership_uuid = serializers.UUIDField(source='uuid', allow_null=True, read_only=True)
activated_at = serializers.DateTimeField(required=False)

member_details = serializers.SerializerMethodField()
recent_action = serializers.SerializerMethodField()
Expand All @@ -613,12 +617,14 @@ class EnterpriseGroupMembershipSerializer(serializers.ModelSerializer):
class Meta:
model = models.EnterpriseGroupMembership
fields = (
'learner_id',
'pending_learner_id',
'enterprise_customer_user_id',
'lms_user_id',
'pending_enterprise_customer_user_id',
'enterprise_group_membership_uuid',
'member_details',
'recent_action',
'status',
'activated_at',
)

def get_member_details(self, obj):
Expand Down
4 changes: 2 additions & 2 deletions enterprise/api/v1/views/enterprise_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_learners(self, request, *args, **kwargs):
'results': [
{
'learner_id': integer or None,
'pending_learner_id': integer or None,
'pending_enterprise_customer_user_id': integer or None,
'enterprise_group_membership_uuid': UUID,
'member_details': {
'user_email': string,
Expand Down Expand Up @@ -204,7 +204,7 @@ def assign_learners(self, request, group_uuid):
# act_by_date and catalog_uuid values are needed for Braze email trigger properties
act_by_date = param_serializer.validated_data.get('act_by_date')
catalog_uuid = param_serializer.validated_data.get('catalog_uuid')
learner_emails = param_serializer.validated_data.get('learner_emails')
learner_emails = param_serializer.validated_data.get('learner_emails', [])
total_records_processed = 0
total_existing_users_processed = 0
total_new_users_processed = 0
Expand Down
40 changes: 24 additions & 16 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7587,7 +7587,7 @@ def test_list_learners_filtered(self):
response = self.client.get(url)

assert response.json().get('count') == 1
assert response.json().get('results')[0].get('pending_learner_id') == pending_user.id
assert response.json().get('results')[0].get('pending_enterprise_customer_user_id') == pending_user.id

group.applies_to_all_contexts = False
group.save()
Expand All @@ -7614,7 +7614,7 @@ def test_list_learners_filtered(self):

assert response.json().get('count') == 1
assert response.json().get('results')[0].get(
'learner_id'
'enterprise_customer_user_id'
) == existing_membership.enterprise_customer_user.id

url = settings.TEST_SERVER + reverse(
Expand All @@ -7626,7 +7626,7 @@ def test_list_learners_filtered(self):

assert response.json().get('count') == 1
assert response.json().get('results')[0].get(
'pending_learner_id'
'pending_enterprise_customer_user_id'
) == pending_membership.pending_enterprise_customer_user.id

def test_list_removed_learners(self):
Expand Down Expand Up @@ -7720,8 +7720,9 @@ def test_successful_list_learners(self):
member_user = self.enterprise_group_memberships[i].enterprise_customer_user
results_list.append(
{
'learner_id': member_user.id,
'pending_learner_id': None,
'enterprise_customer_user_id': member_user.id,
'lms_user_id': member_user.user_id,
'pending_enterprise_customer_user_id': None,
'enterprise_group_membership_uuid': str(self.enterprise_group_memberships[i].uuid),
'member_details': {
'user_email': member_user.user_email,
Expand All @@ -7739,9 +7740,11 @@ def test_successful_list_learners(self):
}
response = self.client.get(url)
for i in range(10):
assert response.json()['results'][i]['learner_id'] == expected_response['results'][i]['learner_id']
assert response.json()['results'][i]['pending_learner_id'] == (
expected_response['results'][i]['pending_learner_id'])
assert response.json()['results'][i]['enterprise_customer_user_id'] == expected_response['results'][i][
'enterprise_customer_user_id'
]
assert response.json()['results'][i]['pending_enterprise_customer_user_id'] == (
expected_response['results'][i]['pending_enterprise_customer_user_id'])
assert (response.json()['results'][i]['enterprise_group_membership_uuid']
== expected_response['results'][i]['enterprise_group_membership_uuid'])

Expand All @@ -7758,8 +7761,9 @@ def test_successful_list_learners(self):
'previous': f'http://testserver/enterprise/api/v1/enterprise-group/{self.group_1.uuid}/learners',
'results': [
{
'learner_id': user.id,
'pending_learner_id': None,
'enterprise_customer_user_id': user.id,
'lms_user_id': user.user_id,
'pending_enterprise_customer_user_id': None,
'enterprise_group_membership_uuid': str(self.enterprise_group_memberships[0].uuid),
'member_details': {
'user_email': user.user_email,
Expand All @@ -7772,10 +7776,10 @@ def test_successful_list_learners(self):
}
assert page_2_response.json()['count'] == expected_response_page_2['count']
assert page_2_response.json()['previous'] == expected_response_page_2['previous']
assert page_2_response.json()['results'][0]['learner_id'] == (
expected_response_page_2['results'][0]['learner_id'])
assert page_2_response.json()['results'][0]['pending_learner_id'] == (
expected_response_page_2['results'][0]['pending_learner_id'])
assert page_2_response.json()['results'][0]['enterprise_customer_user_id'] == (
expected_response_page_2['results'][0]['enterprise_customer_user_id'])
assert page_2_response.json()['results'][0]['pending_enterprise_customer_user_id'] == (
expected_response_page_2['results'][0]['pending_enterprise_customer_user_id'])
assert (page_2_response.json()['results'][0]['enterprise_group_membership_uuid']
== expected_response_page_2['results'][0]['enterprise_group_membership_uuid'])
self.enterprise_group_memberships[0].delete()
Expand All @@ -7801,7 +7805,7 @@ def test_successful_list_learners(self):
'results': [
{
'learner_id': self.enterprise_group_memberships[0].enterprise_customer_user.id,
'pending_learner_id': self.pending_enterprise_customer_user,
'pending_enterprise_customer_user_id': self.pending_enterprise_customer_user,
'enterprise_group_membership_uuid': str(self.enterprise_group_memberships[0].uuid),
'enterprise_customer': {
'name': self.enterprise_customer.name,
Expand Down Expand Up @@ -8142,7 +8146,11 @@ def test_group_applies_to_all_contexts_learner_list(self):
response = self.client.get(url)
results = response.json().get('results')
for result in results:
assert (result.get('pending_learner_id') == pending_user.id) or (result.get('learner_id') == new_user.id)
assert (
result.get('pending_enterprise_customer_user_id') == pending_user.id
) or (
result.get('enterprise_customer_user_id') == new_user.id
)

def test_group_assign_realized_learner_adds_activated_at(self):
"""
Expand Down

0 comments on commit fd06e4c

Please sign in to comment.