Skip to content

Commit

Permalink
feat: Added user's first and last name in the enterprise enrollments …
Browse files Browse the repository at this point in the history
…API and related DB table.
  • Loading branch information
saleem-latif committed Dec 30, 2024
1 parent ab7f8b6 commit 7537994
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Unreleased

=========================

[10.7.0] - 2024-12-24
---------------------
* feat: Added user's first and last name in the enterprise enrollments API and related DB table.

[10.6.1] - 2024-12-10
---------------------
* feat: add course_title in top courses in enrollments csv
Expand Down
2 changes: 1 addition & 1 deletion enterprise_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Enterprise data api application. This Django app exposes API endpoints used by enterprises.
"""

__version__ = "10.6.1"
__version__ = "10.7.0"
6 changes: 3 additions & 3 deletions enterprise_data/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Meta:
'course_primary_program', 'primary_program_type', 'course_primary_subject', 'has_passed',
'last_activity_date', 'progress_status', 'passed_date', 'current_grade',
'letter_grade', 'enterprise_user_id', 'user_email', 'user_account_creation_date',
'user_country_code', 'user_username', 'enterprise_name', 'enterprise_customer_uuid',
'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours', 'is_subsidy',
'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
'user_country_code', 'user_username', 'user_first_name', 'user_last_name', 'enterprise_name',
'enterprise_customer_uuid', 'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours',
'is_subsidy', 'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
)

def get_course_api_url(self, obj):
Expand Down
6 changes: 3 additions & 3 deletions enterprise_data/api/v1/views/enterprise_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class EnterpriseLearnerEnrollmentViewSet(EnterpriseViewSetMixin, viewsets.ReadOn
'course_primary_program', 'primary_program_type', 'course_primary_subject', 'has_passed',
'last_activity_date', 'progress_status', 'passed_date', 'current_grade',
'letter_grade', 'enterprise_user_id', 'user_email', 'user_account_creation_date',
'user_country_code', 'user_username', 'enterprise_name', 'enterprise_customer_uuid',
'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours', 'is_subsidy',
'course_product_line', 'budget_id'
'user_country_code', 'user_username', 'user_first_name', 'user_last_name', 'enterprise_name',
'enterprise_customer_uuid', 'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours',
'is_subsidy', 'course_product_line', 'budget_id',
]

# TODO: Remove after we release the streaming csv changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def test_create_enterprise_learner_enrollment_lpr_v1_with_dsc_disabled(self):
assert enterprise_learner_enrollment[0].letter_grade is None
assert enterprise_learner_enrollment[0].enterprise_user_id is None
assert enterprise_learner_enrollment[0].user_username is None
assert enterprise_learner_enrollment[0].user_first_name is None
assert enterprise_learner_enrollment[0].user_last_name is None
assert enterprise_learner_enrollment[0].user_email is None
assert enterprise_learner_enrollment[0].enterprise_user is None

Expand All @@ -62,6 +64,8 @@ def test_create_enterprise_learner_enrollment_lpr_v1_with_dsc_enabled(self):
assert enterprise_learner_enrollment[0].progress_status is not None
assert enterprise_learner_enrollment[0].enterprise_user_id is not None
assert enterprise_learner_enrollment[0].user_username is not None
assert enterprise_learner_enrollment[0].user_first_name is not None
assert enterprise_learner_enrollment[0].user_last_name is not None
assert enterprise_learner_enrollment[0].enterprise_user is not None
assert enterprise_learner_enrollment[0].user_email is not None
assert EnterpriseLearner.objects.count() == 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.15 on 2024-12-23 12:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('enterprise_data', '0044_enterpriseexecedlcmoduleperformance'),
]

operations = [
migrations.AlterModelOptions(
name='enterpriseexecedlcmoduleperformance',
options={'verbose_name': 'Exec Ed LC Module Performance', 'verbose_name_plural': 'Exec Ed LC Module Performance'},
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='user_first_name',
field=models.CharField(max_length=255, null=True),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='user_last_name',
field=models.CharField(max_length=255, null=True),
),
]
2 changes: 2 additions & 0 deletions enterprise_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class Meta:
user_account_creation_date = models.DateTimeField(null=True)
user_country_code = models.CharField(max_length=2, null=True)
user_username = models.CharField(max_length=255, null=True)
user_first_name = models.CharField(max_length=255, null=True)
user_last_name = models.CharField(max_length=255, null=True)
enterprise_name = models.CharField(max_length=255, db_index=True, null=False)
enterprise_customer_uuid = models.UUIDField(db_index=True, null=False)
enterprise_sso_uid = models.CharField(max_length=255, null=True)
Expand Down
6 changes: 3 additions & 3 deletions enterprise_data/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class EnrollmentsCSVRenderer(CSVStreamingRenderer):
'course_primary_program', 'primary_program_type', 'course_primary_subject', 'has_passed',
'last_activity_date', 'progress_status', 'passed_date', 'current_grade',
'letter_grade', 'enterprise_user_id', 'user_email', 'user_account_creation_date',
'user_country_code', 'user_username', 'enterprise_name', 'enterprise_customer_uuid',
'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours', 'is_subsidy',
'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
'user_country_code', 'user_username', 'user_first_name', 'user_last_name', 'enterprise_name',
'enterprise_customer_uuid', 'enterprise_sso_uid', 'created', 'course_api_url', 'total_learning_time_hours',
'is_subsidy', 'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
]


Expand Down
4 changes: 4 additions & 0 deletions enterprise_data/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class Meta:
enterprise_user_id = factory.Sequence(lambda n: n)
user_email = factory.lazy_attribute(lambda x: FAKER.email()) # pylint: disable=no-member
user_username = factory.Sequence('robot{}'.format)
user_first_name = factory.Sequence('Robot First {}'.format)
user_last_name = factory.Sequence('Robot Last {}'.format)
user_account_creation_date = factory.lazy_attribute(lambda x: '2018-01-01')
user_country_code = factory.lazy_attribute(lambda x: FAKER.country_code())
is_subsidy = factory.lazy_attribute(lambda x: FAKER.boolean()) # pylint: disable=no-member
Expand Down Expand Up @@ -230,6 +232,8 @@ def set_fields_according_to_consent(
'user_account_creation_date',
'user_country_code',
'user_username',
'user_first_name',
'user_last_name',
]
if create and not obj.is_consent_granted:
for field in dsc_dependent_fields:
Expand Down

0 comments on commit 7537994

Please sign in to comment.