Skip to content

Commit

Permalink
Merge pull request #459 from openedx/ammar/add-new-and-missing-fields…
Browse files Browse the repository at this point in the history
…-in-model

feat: add new and missing fields in EnterpriseLearnerEnrollment model
  • Loading branch information
muhammad-ammar authored Jul 12, 2024
2 parents 380ad7f + 0cb0207 commit 5ef321c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 5 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 @@ Unreleased
----------

=========================
[7.0.0] - 2024-07-12
---------------------
* Add new fields in EnterpriseLearnerEnrollment model

[6.2.3] - 2024-07-01
---------------------
* Dependency updates
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__ = "6.2.3"
__version__ = "7.0.0"
2 changes: 1 addition & 1 deletion enterprise_data/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Meta:
'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'
'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
)

def get_course_api_url(self, obj):
Expand Down
45 changes: 45 additions & 0 deletions enterprise_data/migrations/0040_auto_20240712_0740.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.2.23 on 2024-07-12 07:40

from django.db import migrations, models

import enterprise_data.utils


class Migration(migrations.Migration):

dependencies = [
('enterprise_data', '0039_auto_20240212_1403'),
]

operations = [
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='enterprise_group_name',
field=models.CharField(max_length=25, null=True),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='enterprise_group_uuid',
field=models.UUIDField(null=True),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='is_included_in_utilization',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='lpr_unique_id',
field=models.PositiveBigIntegerField(default=enterprise_data.utils.get_unique_id, primary_key=True, serialize=False),
),
migrations.AddField(
model_name='enterpriselearnerenrollment',
name='subscription_license_uuid',
field=models.UUIDField(null=True),
),
migrations.AlterField(
model_name='enterpriselearnerenrollment',
name='enterprise_enrollment_id',
field=models.PositiveIntegerField(null=True),
),
]
9 changes: 8 additions & 1 deletion enterprise_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from enterprise_data.utils import get_unique_id

LOGGER = getLogger(__name__)


Expand Down Expand Up @@ -78,7 +80,7 @@ class Meta:
]),
]

enterprise_enrollment_id = models.PositiveIntegerField(primary_key=True)
enterprise_enrollment_id = models.PositiveIntegerField(null=True)
enrollment_id = models.PositiveIntegerField(null=True)
is_consent_granted = models.BooleanField(default=False)
paid_by = models.CharField(max_length=255, null=True)
Expand Down Expand Up @@ -133,6 +135,11 @@ class Meta:
is_subsidy = models.BooleanField(default=False)
course_product_line = models.CharField(max_length=64, null=True)
budget_id = models.UUIDField(db_index=True, null=True)
is_included_in_utilization = models.BooleanField(default=False)
lpr_unique_id = models.PositiveBigIntegerField(primary_key=True, default=get_unique_id)
subscription_license_uuid = models.UUIDField(null=True)
enterprise_group_name = models.CharField(max_length=25, null=True)
enterprise_group_uuid = models.UUIDField(null=True)


class EnterpriseAdminLearnerProgress(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion enterprise_data/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class EnrollmentsCSVRenderer(CSVStreamingRenderer):
'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'
'course_product_line', 'budget_id', 'enterprise_group_name', 'enterprise_group_uuid',
]
9 changes: 8 additions & 1 deletion enterprise_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Utility functions for Enterprise Data app.
"""


import hashlib
import random


def get_cache_key(**kwargs):
Expand All @@ -28,3 +28,10 @@ def get_cache_key(**kwargs):
key = '__'.join([f'{item}:{value}' for item, value in kwargs.items()])

return hashlib.md5(key.encode('utf-8')).hexdigest()


def get_unique_id():
"""
Return a unique 32 bit integer.
"""
return random.getrandbits(32)

0 comments on commit 5ef321c

Please sign in to comment.