Skip to content

Commit

Permalink
feat: incorporate additional attributes to degreed v2 (#1812)
Browse files Browse the repository at this point in the history
* feat: incorporate additional attributes to degreed v2

* fix: updated tests

* fix: lint errors

* fix: lint error

* chore: version bump
  • Loading branch information
katrinan029 committed Jul 25, 2023
1 parent aa37d50 commit abbbe5e
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 3 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.0.5]
--------
feat: incorporate additional attributes to degreed v2

[4.0.4]
--------
feat: remove content transmission audits without a catalog uuid
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Your project description goes here.
"""

__version__ = "4.0.4"
__version__ = "4.0.5"

default_app_config = "enterprise.apps.EnterpriseConfig"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blackboard', '0015_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='blackboardenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='historicalblackboardenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
23 changes: 23 additions & 0 deletions integrated_channels/canvas/migrations/0031_auto_20230719_1621.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('canvas', '0030_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='canvasenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='historicalcanvasenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cornerstone', '0027_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='cornerstoneenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='historicalcornerstoneenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
23 changes: 23 additions & 0 deletions integrated_channels/degreed/migrations/0030_auto_20230719_1621.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('degreed', '0029_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='degreedenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='historicaldegreedenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
53 changes: 52 additions & 1 deletion integrated_channels/degreed2/exporters/content_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

from logging import getLogger

from enterprise.utils import get_closest_course_run, get_course_run_duration_info
from enterprise.utils import (
get_advertised_course_run,
get_closest_course_run,
get_course_run_duration_info,
is_course_run_active,
)
from integrated_channels.integrated_channel.exporters.content_metadata import ContentMetadataExporter
from integrated_channels.utils import (
generate_formatted_log,
Expand Down Expand Up @@ -37,6 +42,10 @@ class Degreed2ContentMetadataExporter(ContentMetadataExporter):
'duration': 'duration',
'duration-type': 'duration_type',
'obsolete': 'obsolete',
'cost-units': 'price',
'cost-unit-type': 'currency',
'difficulty': 'level_type',
'video-url': 'video_url',
}

def transform_duration_type(self, content_metadata_item): # pylint: disable=unused-argument
Expand Down Expand Up @@ -153,3 +162,45 @@ def transform_obsolete(self, content_metadata_item): # pylint: disable=unused-a
Always set obsolete to false to fix externally deleted courses.
"""
return False

def transform_price(self, content_metadata_item):
"""
Return the current course run's price.
"""
price = 0

if self.enterprise_configuration.show_course_price:
advertised_course_run = get_advertised_course_run(content_metadata_item)
if advertised_course_run and 'first_enrollable_paid_seat_price' in advertised_course_run:
price = advertised_course_run.get('first_enrollable_paid_seat_price') or 0
else:
for course_run in content_metadata_item.get('course_runs', []):
if 'first_enrollable_paid_seat_price' in course_run and is_course_run_active(course_run):
price = course_run.get('first_enrollable_paid_seat_price') or 0
break

return price

def transform_currency(self, content_metadata_item): # pylint: disable=unused-argument
"""
Return the price unit type.
"""
return 'USD'

def transform_level_type(self, content_metadata_item):
"""
Return the level type of the content item.
"""
return content_metadata_item.get('level_type')

def transform_video_url(self, content_metadata_item):
"""
Return the video url of the content item.
"""
video_url = None
video = content_metadata_item.get('video')

if video:
video_url = video.get('src')

return video_url
23 changes: 23 additions & 0 deletions integrated_channels/degreed2/migrations/0022_auto_20230719_1621.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('degreed2', '0021_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='degreed2enterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='historicaldegreed2enterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('integrated_channel', '0028_alter_contentmetadataitemtransmission_unique_together'),
]

operations = [
migrations.AddField(
model_name='genericenterprisecustomerpluginconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
7 changes: 7 additions & 0 deletions integrated_channels/integrated_channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ class EnterpriseCustomerPluginConfiguration(SoftDeletionModel):
help_text=_("Is this configuration in dry-run mode? (experimental)"),
)

show_course_price = models.BooleanField(
blank=False,
null=False,
default=False,
help_text=_("Displays course price"),
)

transmission_chunk_size = models.IntegerField(
default=500,
help_text=_("The maximum number of data items to transmit to the integrated channel with each request.")
Expand Down
23 changes: 23 additions & 0 deletions integrated_channels/moodle/migrations/0026_auto_20230719_1621.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('moodle', '0025_auto_20230112_2002'),
]

operations = [
migrations.AddField(
model_name='historicalmoodleenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
migrations.AddField(
model_name='moodleenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-07-19 16:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sap_success_factors', '0013_sapsuccessfactorsenterprisecustomerconfiguration_last_modified_at'),
]

operations = [
migrations.AlterField(
model_name='sapsuccessfactorsenterprisecustomerconfiguration',
name='show_course_price',
field=models.BooleanField(default=False, help_text='Displays course price'),
),
]
1 change: 0 additions & 1 deletion integrated_channels/sap_success_factors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class SAPSuccessFactorsEnterpriseCustomerConfiguration(EnterpriseCustomerPluginC
verbose_name="Additional Locales",
help_text=_("A comma-separated list of additional locales.")
)
show_course_price = models.BooleanField(default=False)
transmit_total_hours = models.BooleanField(
default=False,
verbose_name=_("Transmit Total Hours"),
Expand Down
Loading

0 comments on commit abbbe5e

Please sign in to comment.