-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kiram15/ENT-9670
- Loading branch information
Showing
16 changed files
with
542 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file records information about this repo. Its use is described in OEP-55: | ||
# https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html | ||
|
||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: 'edx-enterprise' | ||
description: "The Open edx Enterprise Service app provides enterprise features to the Open edX platform" | ||
tags: | ||
- enterprise | ||
- ent | ||
- library | ||
spec: | ||
owner: group:openedx-unmaintained | ||
type: 'library' | ||
lifecycle: 'production' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Your project description goes here. | ||
""" | ||
|
||
__version__ = "4.28.3" | ||
__version__ = "4.29.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Utils for interacting with cache interfaces. | ||
""" | ||
import hashlib | ||
|
||
from django.conf import settings | ||
|
||
from enterprise import __version__ as code_version | ||
|
||
CACHE_KEY_SEP = ':' | ||
DEFAULT_NAMESPACE = 'edx-enterprise-default' | ||
|
||
|
||
def versioned_cache_key(*args): | ||
""" | ||
Utility to produce a versioned cache key, which includes | ||
an optional settings variable and the current code version, | ||
so that we can perform key-based cache invalidation. | ||
""" | ||
components = [str(arg) for arg in args] | ||
components.append(code_version) | ||
if stamp_from_settings := getattr(settings, 'CACHE_KEY_VERSION_STAMP', None): | ||
components.append(stamp_from_settings) | ||
decoded_cache_key = CACHE_KEY_SEP.join(components) | ||
return hashlib.sha512(decoded_cache_key.encode()).hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Python API for interacting with content metadata. | ||
""" | ||
import logging | ||
|
||
from edx_django_utils.cache import TieredCache | ||
from requests.exceptions import HTTPError | ||
|
||
from django.conf import settings | ||
|
||
from enterprise.api_client.enterprise_catalog import EnterpriseCatalogApiClient | ||
from enterprise.cache_utils import versioned_cache_key | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
DEFAULT_CACHE_TIMEOUT = getattr(settings, 'CONTENT_METADATA_CACHE_TIMEOUT', 60 * 5) | ||
|
||
|
||
def get_and_cache_customer_content_metadata(enterprise_customer_uuid, content_key, timeout=None): | ||
""" | ||
Returns the metadata corresponding to the requested | ||
``content_key`` within catalogs associated to the provided ``enterprise_customer``. | ||
The response is cached in a ``TieredCache`` (meaning in both the RequestCache, | ||
_and_ the django cache for the configured expiration period). | ||
Returns: A dict with content metadata for the given key. | ||
Raises: An HTTPError if there's a problem getting the content metadata | ||
via the enterprise-catalog service. | ||
""" | ||
cache_key = versioned_cache_key('get_content_metadata_content_identifier', enterprise_customer_uuid, content_key) | ||
cached_response = TieredCache.get_cached_response(cache_key) | ||
if cached_response.is_found: | ||
logger.info(f'cache hit for enterprise customer {enterprise_customer_uuid} and content {content_key}') | ||
return cached_response.value | ||
|
||
try: | ||
result = EnterpriseCatalogApiClient().get_content_metadata_content_identifier( | ||
enterprise_uuid=enterprise_customer_uuid, | ||
content_id=content_key, | ||
) | ||
except HTTPError as exc: | ||
raise exc | ||
|
||
if not result: | ||
logger.warning( | ||
'No content found for customer %s and content_key %s', | ||
enterprise_customer_uuid, | ||
content_key, | ||
) | ||
return {} | ||
|
||
logger.info( | ||
'Fetched catalog for customer %s and content_key %s. Result = %s', | ||
enterprise_customer_uuid, | ||
content_key, | ||
result, | ||
) | ||
TieredCache.set_all_tiers(cache_key, result, timeout or DEFAULT_CACHE_TIMEOUT) | ||
return result |
31 changes: 31 additions & 0 deletions
31
enterprise/migrations/0225_remove_enterprisegroup_applies_to_all_contexts_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 4.2.16 on 2024-10-23 22:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('enterprise', '0224_alter_enterprisegroup_applies_to_all_contexts_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='enterprisegroup', | ||
name='applies_to_all_contexts', | ||
), | ||
migrations.RemoveField( | ||
model_name='historicalenterprisegroup', | ||
name='applies_to_all_contexts', | ||
), | ||
migrations.AlterField( | ||
model_name='enterprisegroup', | ||
name='name', | ||
field=models.CharField(help_text='Specifies enterprise group name.', max_length=250), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalenterprisegroup', | ||
name='name', | ||
field=models.CharField(help_text='Specifies enterprise group name.', max_length=250), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
enterprise/migrations/0226_alter_enterprisegroup_name_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.16 on 2024-10-23 22:59 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('enterprise', '0225_remove_enterprisegroup_applies_to_all_contexts_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='enterprisegroup', | ||
name='name', | ||
field=models.CharField(help_text='Specifies enterprise group name.', max_length=255), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalenterprisegroup', | ||
name='name', | ||
field=models.CharField(help_text='Specifies enterprise group name.', max_length=255), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
...prise/migrations/0227_alter_defaultenterpriseenrollmentintention_content_type_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.16 on 2024-10-24 15:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('enterprise', '0226_alter_enterprisegroup_name_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='defaultenterpriseenrollmentintention', | ||
name='content_type', | ||
field=models.CharField(blank=True, choices=[('course', 'Course'), ('course_run', 'Course Run')], help_text='The type of content (e.g. a course vs. a course run).', max_length=127, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicaldefaultenterpriseenrollmentintention', | ||
name='content_type', | ||
field=models.CharField(blank=True, choices=[('course', 'Course'), ('course_run', 'Course Run')], help_text='The type of content (e.g. a course vs. a course run).', max_length=127, null=True), | ||
), | ||
migrations.AddConstraint( | ||
model_name='defaultenterpriseenrollmentintention', | ||
constraint=models.UniqueConstraint(fields=('enterprise_customer', 'content_key'), name='unique_default_enrollment_intention'), | ||
), | ||
] |
Oops, something went wrong.