From 7537994012e705a4b0ef9cd25dd0951eb057a635 Mon Sep 17 00:00:00 2001 From: Saleem Latif Date: Tue, 24 Dec 2024 14:51:22 +0500 Subject: [PATCH] feat: Added user's first and last name in the enterprise enrollments API and related DB table. --- CHANGELOG.rst | 4 +++ enterprise_data/__init__.py | 2 +- enterprise_data/api/v1/serializers.py | 6 ++--- .../api/v1/views/enterprise_learner.py | 6 ++--- ...te_enterprise_learner_enrollment_lpr_v1.py | 4 +++ ...cedlcmoduleperformance_options_and_more.py | 27 +++++++++++++++++++ enterprise_data/models.py | 2 ++ enterprise_data/renderers.py | 6 ++--- enterprise_data/tests/test_utils.py | 4 +++ 9 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 enterprise_data/migrations/0045_alter_enterpriseexecedlcmoduleperformance_options_and_more.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3070867d..116c4774 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/enterprise_data/__init__.py b/enterprise_data/__init__.py index 5ae8681a..749b7430 100644 --- a/enterprise_data/__init__.py +++ b/enterprise_data/__init__.py @@ -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" diff --git a/enterprise_data/api/v1/serializers.py b/enterprise_data/api/v1/serializers.py index 9f14db90..a0468051 100644 --- a/enterprise_data/api/v1/serializers.py +++ b/enterprise_data/api/v1/serializers.py @@ -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): diff --git a/enterprise_data/api/v1/views/enterprise_learner.py b/enterprise_data/api/v1/views/enterprise_learner.py index d36ec7af..43c4c4e0 100644 --- a/enterprise_data/api/v1/views/enterprise_learner.py +++ b/enterprise_data/api/v1/views/enterprise_learner.py @@ -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 diff --git a/enterprise_data/management/commands/tests/test_create_enterprise_learner_enrollment_lpr_v1.py b/enterprise_data/management/commands/tests/test_create_enterprise_learner_enrollment_lpr_v1.py index c9744377..a5642876 100644 --- a/enterprise_data/management/commands/tests/test_create_enterprise_learner_enrollment_lpr_v1.py +++ b/enterprise_data/management/commands/tests/test_create_enterprise_learner_enrollment_lpr_v1.py @@ -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 @@ -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 diff --git a/enterprise_data/migrations/0045_alter_enterpriseexecedlcmoduleperformance_options_and_more.py b/enterprise_data/migrations/0045_alter_enterpriseexecedlcmoduleperformance_options_and_more.py new file mode 100644 index 00000000..b5f5fc59 --- /dev/null +++ b/enterprise_data/migrations/0045_alter_enterpriseexecedlcmoduleperformance_options_and_more.py @@ -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), + ), + ] diff --git a/enterprise_data/models.py b/enterprise_data/models.py index 72e9d0b6..c968ca61 100644 --- a/enterprise_data/models.py +++ b/enterprise_data/models.py @@ -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) diff --git a/enterprise_data/renderers.py b/enterprise_data/renderers.py index 56ef1d01..6ba0ba89 100644 --- a/enterprise_data/renderers.py +++ b/enterprise_data/renderers.py @@ -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', ] diff --git a/enterprise_data/tests/test_utils.py b/enterprise_data/tests/test_utils.py index 2c1b41aa..70c2e823 100644 --- a/enterprise_data/tests/test_utils.py +++ b/enterprise_data/tests/test_utils.py @@ -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 @@ -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: