Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
47cdf392
Commit
47cdf392
authored
Apr 27, 2017
by
asadiqbal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENT-342
parent
acbf8603
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
common/djangoapps/course_modes/tests/test_views.py
+7
-1
common/djangoapps/course_modes/views.py
+0
-1
openedx/features/enterprise_support/api.py
+13
-1
No files found.
common/djangoapps/course_modes/tests/test_views.py
View file @
47cdf392
...
...
@@ -29,12 +29,13 @@ from util.testing import UrlResetMixin
from
openedx.core.djangoapps.theming.tests.test_util
import
with_comprehensive_theme
from
util.tests.mixins.discovery
import
CourseCatalogServiceMockMixin
from
util
import
organizations_helpers
as
organizations_api
from
openedx.core.djangoapps.catalog.tests.mixins
import
CatalogIntegrationMixin
@attr
(
shard
=
3
)
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
CourseModeViewTest
(
UrlResetMixin
,
ModuleStoreTestCase
,
EnterpriseServiceMockMixin
,
CourseCatalogServiceMockMixin
):
class
CourseModeViewTest
(
CatalogIntegrationMixin
,
UrlResetMixin
,
ModuleStoreTestCase
,
EnterpriseServiceMockMixin
,
CourseCatalogServiceMockMixin
):
"""
Course Mode View tests
"""
...
...
@@ -155,6 +156,9 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase, EnterpriseServiceMo
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
catalog_integration
=
self
.
create_catalog_integration
()
UserFactory
(
username
=
catalog_integration
.
service_username
)
self
.
mock_enterprise_learner_api
()
self
.
mock_course_discovery_api_for_catalog_contains
(
...
...
@@ -185,6 +189,8 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase, EnterpriseServiceMo
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
catalog_integration
=
self
.
create_catalog_integration
()
UserFactory
(
username
=
catalog_integration
.
service_username
)
self
.
mock_enterprise_learner_api
()
self
.
mock_course_discovery_api_for_catalog_contains
(
catalog_id
=
1
,
course_run_ids
=
[
str
(
self
.
course
.
id
)]
...
...
common/djangoapps/course_modes/views.py
View file @
47cdf392
...
...
@@ -159,7 +159,6 @@ class ChooseModeView(View):
is_course_in_enterprise_catalog
=
enterprise_api
.
is_course_in_enterprise_catalog
(
site
=
request
.
site
,
course_id
=
course_id
,
user
=
request
.
user
,
enterprise_catalog_id
=
enterprise_learner_data
[
0
][
'enterprise_customer'
][
'catalog'
]
)
...
...
openedx/features/enterprise_support/api.py
View file @
47cdf392
...
...
@@ -29,6 +29,7 @@ from requests.exceptions import ConnectionError, Timeout
from
openedx.core.djangoapps.api_admin.utils
import
course_discovery_api_client
from
openedx.core.lib.token_utils
import
JwtBuilder
from
openedx.core.djangoapps.catalog.models
import
CatalogIntegration
CONSENT_FAILED_PARAMETER
=
'consent_failed'
...
...
@@ -455,7 +456,7 @@ def get_dashboard_consent_notification(request, user, course_enrollments):
return
''
def
is_course_in_enterprise_catalog
(
site
,
course_id
,
user
,
enterprise_catalog_id
):
def
is_course_in_enterprise_catalog
(
site
,
course_id
,
enterprise_catalog_id
):
"""
Verify that the provided course id exists in the site base list of course
run keys from the provided enterprise course catalog.
...
...
@@ -477,6 +478,17 @@ def is_course_in_enterprise_catalog(site, course_id, user, enterprise_catalog_id
)
response
=
cache
.
get
(
cache_key
)
if
not
response
:
catalog_integration
=
CatalogIntegration
.
current
()
if
not
catalog_integration
.
enabled
:
LOGGER
.
error
(
"Catalog integration is not enabled."
)
return
False
try
:
user
=
User
.
objects
.
get
(
username
=
catalog_integration
.
service_username
)
except
User
.
DoesNotExist
:
LOGGER
.
exception
(
"Catalog service user '
%
s' does not exist."
,
catalog_integration
.
service_username
)
return
False
try
:
# GET: /api/v1/catalogs/{catalog_id}/contains?course_run_id={course_run_ids}
response
=
course_discovery_api_client
(
user
=
user
)
.
catalogs
(
enterprise_catalog_id
)
.
contains
.
get
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment