Skip to content

Commit

Permalink
Merge branch 'master' of github.com:openedx/course-discovery into ENT…
Browse files Browse the repository at this point in the history
…-9748/introduce-new-marketable-field
  • Loading branch information
hamzawaleed01 committed Nov 25, 2024
2 parents c54de1f + dce1534 commit 00cb2c8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ class Meta:
fields = ('key', 'uuid', 'title', 'external_key', 'fixed_price_usd', 'image', 'short_description',
'marketing_url', 'seats', 'start', 'end', 'go_live_date', 'enrollment_start', 'enrollment_end',
'weeks_to_complete', 'pacing_type', 'type', 'restriction_type', 'run_type', 'status', 'is_enrollable',
'is_marketable','is_marketable_for_enterprise', 'term', 'availability', 'variant_id')
'is_marketable', 'is_marketable_external', 'term', 'availability', 'variant_id')

def get_marketing_url(self, obj):
include_archived = self.context.get('include_archived')
Expand Down
10 changes: 5 additions & 5 deletions course_discovery/apps/api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def get_expected_data(cls, course_run, request):
'external_key': course_run.external_key,
'is_enrollable': course_run.is_enrollable,
'is_marketable': course_run.is_marketable,
'is_marketable_for_enterprise': course_run.is_marketable_for_enterprise,
'is_marketable_external': course_run.is_marketable_external,
'availability': course_run.availability,
'variant_id': str(course_run.variant_id),
'fixed_price_usd': str(course_run.fixed_price_usd),
Expand All @@ -656,7 +656,7 @@ def test_data(self):
serializer = self.serializer_class(course_run, context={'request': request})
expected = self.get_expected_data(course_run, request)
assert serializer.data == expected

def test_marketable_status(self):
# Test for executive education course with in-review status, not marketable, and future start date
exec_ed_type = CourseTypeFactory(slug=CourseType.EXECUTIVE_EDUCATION_2U)
Expand All @@ -666,15 +666,15 @@ def test_marketable_status(self):
start=datetime.datetime.now(tz=UTC) + datetime.timedelta(days=10) # Future start date
)
course_run_exec_ed.seats.set([]) # No seats to ensure is_marketable is False
assert course_run_exec_ed.is_marketable_for_enterprise is True

assert course_run_exec_ed.is_marketable_external is True

# Test for non-executive education course
non_exec_ed_type = CourseTypeFactory()
course_run_non_exec_ed = CourseRunFactory(
course=CourseFactory(type=non_exec_ed_type),
)
assert course_run_non_exec_ed.is_marketable_for_enterprise is False
assert course_run_non_exec_ed.is_marketable_external is False

def test_get_lms_course_url(self):
partner = PartnerFactory()
Expand Down
21 changes: 10 additions & 11 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2970,27 +2970,26 @@ def is_marketable(self):
return is_published and self.seats.exists() and bool(self.marketing_url)

@property
def is_marketable_for_enterprise(self):
def is_marketable_external(self):
"""
Determines if the course_run is suitable for enterprise marketing.
Determines if the course_run is suitable for marketing.
A course run is deemed suitable for enterprise marketing if it is an
A course run is deemed suitable for marketing if it is an
executive education (EE) course, the discovery service status is
'in-review', it is not currently marketable, and the course start date is in the future.
For non-executive education courses, the suitability for enterprise marketing
For already marketable course runs, the suitability for marketing
refers to the existing marketable flag.
"""

is_exec_ed_course = self.course.type.slug == CourseType.EXECUTIVE_EDUCATION_2U

if is_exec_ed_course:
is_in_review = self.in_review
is_not_marketable = not self.is_marketable
has_future_start_date = self.is_upcoming()
return is_in_review and is_not_marketable and has_future_start_date
else:
if self.is_marketable:
# Course run is already marketable; pass-thru regardless of course type
return self.is_marketable
if is_exec_ed_course:
# Check whether external course run is marketable
return self.in_review and self.is_upcoming()
return False

@property
def is_active(self):
Expand Down
24 changes: 12 additions & 12 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ accessible-pygments==0.0.5
# via pydata-sphinx-theme
aiohappyeyeballs==2.4.3
# via aiohttp
aiohttp==3.11.2
aiohttp==3.11.7
# via openai
aiosignal==1.3.1
# via aiohttp
Expand Down Expand Up @@ -64,9 +64,9 @@ boltons==21.0.0
# face
# glom
# semgrep
boto3==1.35.63
boto3==1.35.68
# via django-ses
botocore==1.35.63
botocore==1.35.68
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -126,7 +126,7 @@ click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
code-annotations==1.8.1
code-annotations==1.8.2
# via
# edx-lint
# edx-toggles
Expand All @@ -136,7 +136,7 @@ colorama==0.4.6
# tox
contentful==2.2.0
# via -r requirements/base.in
coverage[toml]==7.6.7
coverage[toml]==7.6.8
# via
# -r requirements/test.in
# pytest-cov
Expand Down Expand Up @@ -360,7 +360,7 @@ edx-django-release-util==1.4.0
# via -r requirements/base.in
edx-django-sites-extensions==4.2.0
# via -r requirements/base.in
edx-django-utils==7.0.0
edx-django-utils==7.0.1
# via
# -r requirements/base.in
# django-config-models
Expand Down Expand Up @@ -439,7 +439,7 @@ glom==22.1.0
# via semgrep
google-api-core==2.23.0
# via google-api-python-client
google-api-python-client==2.153.0
google-api-python-client==2.154.0
# via -r requirements/base.in
google-auth==2.36.0
# via
Expand Down Expand Up @@ -526,7 +526,7 @@ multidict==6.1.0
# yarl
mysqlclient==2.2.6
# via -r requirements/test.in
newrelic==10.2.0
newrelic==10.3.0
# via edx-django-utils
oauthlib==3.2.2
# via
Expand Down Expand Up @@ -769,7 +769,7 @@ ruamel-yaml==0.17.40
# via semgrep
ruamel-yaml-clib==0.2.12
# via ruamel-yaml
s3transfer==0.10.3
s3transfer==0.10.4
# via boto3
selenium==4.12.0
# via
Expand Down Expand Up @@ -840,7 +840,7 @@ sqlparse==0.5.2
# via
# django
# django-debug-toolbar
stevedore==5.3.0
stevedore==5.4.0
# via
# code-annotations
# edx-django-utils
Expand All @@ -861,7 +861,7 @@ tomlkit==0.13.2
# snowflake-connector-python
tox==4.0.0
# via -r requirements/test.in
tqdm==4.67.0
tqdm==4.67.1
# via
# openai
# semgrep
Expand Down Expand Up @@ -921,7 +921,7 @@ wsproto==1.2.0
# via trio-websocket
xss-utils==0.6.0
# via -r requirements/base.in
yarl==1.17.2
yarl==1.18.0
# via aiohttp
zeep==4.3.1
# via simple-salesforce
Expand Down
4 changes: 2 additions & 2 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#
# pip-compile --allow-unsafe --output-file=requirements/pip.txt requirements/pip.in
#
wheel==0.45.0
wheel==0.45.1
# via -r requirements/pip.in

# The following packages are considered to be unsafe in a requirements file:
pip==24.2
# via
# -c /home/runner/work/course-discovery/course-discovery/requirements/common_constraints.txt
# -r requirements/pip.in
setuptools==75.5.0
setuptools==75.6.0
# via -r requirements/pip.in
2 changes: 1 addition & 1 deletion requirements/pip_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pyproject-hooks==1.2.0
# via
# build
# pip-tools
wheel==0.45.0
wheel==0.45.1
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
Expand Down
22 changes: 11 additions & 11 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
aiohappyeyeballs==2.4.3
# via aiohttp
aiohttp==3.11.2
aiohttp==3.11.7
# via openai
aiosignal==1.3.1
# via aiohttp
Expand Down Expand Up @@ -41,9 +41,9 @@ beautifulsoup4==4.12.3
# taxonomy-connector
billiard==4.2.1
# via celery
boto3==1.35.63
boto3==1.35.68
# via django-ses
botocore==1.35.63
botocore==1.35.68
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -89,7 +89,7 @@ click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
code-annotations==1.8.1
code-annotations==1.8.2
# via edx-toggles
contentful==2.2.0
# via -r requirements/base.in
Expand Down Expand Up @@ -296,7 +296,7 @@ edx-django-release-util==1.4.0
# via -r requirements/base.in
edx-django-sites-extensions==4.2.0
# via -r requirements/base.in
edx-django-utils==7.0.0
edx-django-utils==7.0.1
# via
# -r requirements/base.in
# django-config-models
Expand Down Expand Up @@ -356,7 +356,7 @@ gevent==24.11.1
# via -r requirements/production.in
google-api-core==2.23.0
# via google-api-python-client
google-api-python-client==2.153.0
google-api-python-client==2.154.0
# via -r requirements/base.in
google-auth==2.36.0
# via
Expand Down Expand Up @@ -427,7 +427,7 @@ multidict==6.1.0
# yarl
mysqlclient==2.2.6
# via -r requirements/production.in
newrelic==10.2.0
newrelic==10.3.0
# via
# -r requirements/production.in
# edx-django-utils
Expand Down Expand Up @@ -580,7 +580,7 @@ rjsmin==1.2.2
# via django-compressor
rsa==4.9
# via google-auth
s3transfer==0.10.3
s3transfer==0.10.4
# via boto3
semantic-version==2.10.0
# via edx-drf-extensions
Expand Down Expand Up @@ -611,7 +611,7 @@ soupsieve==2.6
# via beautifulsoup4
sqlparse==0.5.2
# via django
stevedore==5.3.0
stevedore==5.4.0
# via
# code-annotations
# edx-django-utils
Expand All @@ -626,7 +626,7 @@ tinycss2==1.4.0
# cssselect2
tomlkit==0.13.2
# via snowflake-connector-python
tqdm==4.67.0
tqdm==4.67.1
# via openai
typing-extensions==4.12.2
# via
Expand Down Expand Up @@ -664,7 +664,7 @@ webencodings==0.5.1
# tinycss2
xss-utils==0.6.0
# via -r requirements/base.in
yarl==1.17.2
yarl==1.18.0
# via aiohttp
zeep==4.3.1
# via simple-salesforce
Expand Down

0 comments on commit 00cb2c8

Please sign in to comment.