Skip to content

Commit

Permalink
Merge pull request #124 from Pearson-Advance/vue/PADV-1346
Browse files Browse the repository at this point in the history
PADV-1346: Backport edx-platform changes needed for Event Bus to work on our olive instance.
  • Loading branch information
Serafin-dev authored May 30, 2024
2 parents 4ed5d0e + 6a15a35 commit 60444ea
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
54 changes: 54 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@
# in the LMS and CMS.
# .. toggle_tickets: 'https://github.com/open-craft/edx-platform/pull/429'
'DISABLE_UNENROLLMENT': False,

# .. toggle_name: FEATURES['BADGES_ENABLED']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to enable the Badges feature.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2024-04-10
'BADGES_ENABLED': False,
}

# .. toggle_name: ENABLE_COPPA_COMPLIANCE
Expand Down Expand Up @@ -2696,3 +2704,49 @@

# Redirect URL for inactive user. If not set, user will be redirected to /login after the login itself (loop)
INACTIVE_USER_URL = f'http://{CMS_BASE}'

#### Event bus producing ####


def _should_send_learning_badge_events(settings):
return settings.FEATURES['BADGES_ENABLED']


# .. setting_name: EVENT_BUS_PRODUCER_CONFIG
# .. setting_default: all events disabled
# .. setting_description: Dictionary of event_types mapped to dictionaries of topic to topic-related configuration.
# Each topic configuration dictionary contains
# * `enabled`: a toggle denoting whether the event will be published to the topic. These should be annotated
# according to
# https://edx.readthedocs.io/projects/edx-toggles/en/latest/how_to/documenting_new_feature_toggles.html
# * `event_key_field` which is a period-delimited string path to event data field to use as event key.
# Note: The topic names should not include environment prefix as it will be dynamically added based on
# EVENT_BUS_TOPIC_PREFIX setting.

EVENT_BUS_PRODUCER_CONFIG = {
"org.openedx.learning.course.passing.status.updated.v1": {
"learning-badges-lifecycle": {
"event_key_field": "course_passing_status.course.course_key",
"enabled": _should_send_learning_badge_events,
},
},
"org.openedx.learning.ccx.course.passing.status.updated.v1": {
"learning-badges-lifecycle": {
"event_key_field": "course_passing_status.course.ccx_course_key",
"enabled": _should_send_learning_badge_events,
},
},
}

derived_collection_entry(
"EVENT_BUS_PRODUCER_CONFIG",
"org.openedx.learning.course.passing.status.updated.v1",
"learning-badges-lifecycle",
"enabled",
)
derived_collection_entry(
"EVENT_BUS_PRODUCER_CONFIG",
"org.openedx.learning.ccx.course.passing.status.updated.v1",
"learning-badges-lifecycle",
"enabled",
)
2 changes: 1 addition & 1 deletion cms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from edx_django_utils.plugins import add_plugins
from path import Path as path


from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType

from .common import *
Expand Down Expand Up @@ -84,6 +83,7 @@ def get_env_setting(setting):
'MKTG_URL_LINK_MAP',
'MKTG_URL_OVERRIDES',
'REST_FRAMEWORK',
'EVENT_BUS_PRODUCER_CONFIG',
]
for key in KEYS_WITH_MERGED_VALUES:
if key in __config_copy__:
Expand Down
53 changes: 53 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,15 @@
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://openedx.atlassian.net/browse/MST-1458'
'ENABLE_CERTIFICATES_IDV_REQUIREMENT': False,

# .. toggle_name: FEATURES['BADGES_ENABLED']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to enable badges functionality.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2024-04-02
# .. toggle_target_removal_date: None
'BADGES_ENABLED': False,
}

# Specifies extra XBlock fields that should available when requested via the Course Blocks API
Expand Down Expand Up @@ -3256,6 +3265,8 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring

# MFE API
'lms.djangoapps.mfe_config_api',

'openedx_events',
]

######################### CSRF #########################################
Expand Down Expand Up @@ -5259,3 +5270,45 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
'bachelors_degree': 'https://www.edx.org/bachelors',
'boot_camps': 'https://www.edx.org/boot-camps',
}

#### Event bus producing ####

def _should_send_learning_badge_events(settings):
return settings.FEATURES['BADGES_ENABLED']

# .. setting_name: EVENT_BUS_PRODUCER_CONFIG
# .. setting_default: all events disabled
# .. setting_description: Dictionary of event_types mapped to dictionaries of topic to topic-related configuration.
# Each topic configuration dictionary contains
# * `enabled`: a toggle denoting whether the event will be published to the topic. These should be annotated
# according to
# https://edx.readthedocs.io/projects/edx-toggles/en/latest/how_to/documenting_new_feature_toggles.html
# * `event_key_field` which is a period-delimited string path to event data field to use as event key.
# Note: The topic names should not include environment prefix as it will be dynamically added based on
# EVENT_BUS_TOPIC_PREFIX setting.
EVENT_BUS_PRODUCER_CONFIG = {
"org.openedx.learning.course.passing.status.updated.v1": {
"learning-badges-lifecycle": {
"event_key_field": "course_passing_status.course.course_key",
"enabled": _should_send_learning_badge_events,
},
},
"org.openedx.learning.ccx.course.passing.status.updated.v1": {
"learning-badges-lifecycle": {
"event_key_field": "course_passing_status.course.ccx_course_key",
"enabled": _should_send_learning_badge_events,
},
},
}
derived_collection_entry(
"EVENT_BUS_PRODUCER_CONFIG",
"org.openedx.learning.course.passing.status.updated.v1",
"learning-badges-lifecycle",
"enabled",
)
derived_collection_entry(
"EVENT_BUS_PRODUCER_CONFIG",
"org.openedx.learning.ccx.course.passing.status.updated.v1",
"learning-badges-lifecycle",
"enabled",
)
6 changes: 6 additions & 0 deletions lms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from corsheaders.defaults import default_headers as corsheaders_default_headers
from django.core.exceptions import ImproperlyConfigured
from edx_django_utils.plugins import add_plugins
from openedx_events.event_bus import merge_producer_configs
from path import Path as path

from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType
Expand Down Expand Up @@ -83,6 +84,7 @@ def get_env_setting(setting):
'MKTG_URL_LINK_MAP',
'MKTG_URL_OVERRIDES',
'REST_FRAMEWORK',
'EVENT_BUS_PRODUCER_CONFIG',
]
for key in KEYS_WITH_MERGED_VALUES:
if key in __config_copy__:
Expand Down Expand Up @@ -1080,3 +1082,7 @@ def get_env_setting(setting):
"SECRET": ENV_TOKENS.get('BIG_BLUE_BUTTON_GLOBAL_SECRET', None),
"URL": ENV_TOKENS.get('BIG_BLUE_BUTTON_GLOBAL_URL', None),
}

############## Event bus producer ##############
EVENT_BUS_PRODUCER_CONFIG = merge_producer_configs(EVENT_BUS_PRODUCER_CONFIG,
ENV_TOKENS.get('EVENT_BUS_PRODUCER_CONFIG', {}))

0 comments on commit 60444ea

Please sign in to comment.