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
8ad34c08
Commit
8ad34c08
authored
Jun 27, 2016
by
Simon Chen
Committed by
GitHub
Jun 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ECOM-4804 Add the organization logo url to the program details page (#12862)
parent
f9edd4e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
openedx/core/djangoapps/programs/tests/test_utils.py
+29
-0
openedx/core/djangoapps/programs/utils.py
+8
-0
No files found.
openedx/core/djangoapps/programs/tests/test_utils.py
View file @
8ad34c08
...
...
@@ -763,3 +763,32 @@ class TestSupplementProgramData(ProgramsApiConfigMixin, ModuleStoreTestCase):
self
.
_assert_supplemented
(
data
,
certificate_url
=
expected_url
)
else
:
self
.
_assert_supplemented
(
data
)
@mock.patch
(
UTILS_MODULE
+
'.get_organization_by_short_name'
)
def
test_organization_logo_exists
(
self
,
mock_get_organization_by_short_name
):
""" Verify the logo image is set from the organizations api """
mock_logo_url
=
'edx/logo.png'
mock_image
=
mock
.
Mock
()
mock_image
.
url
=
mock_logo_url
mock_get_organization_by_short_name
.
return_value
=
{
'logo'
:
mock_image
}
data
=
utils
.
supplement_program_data
(
self
.
program
,
self
.
user
)
self
.
assertEqual
(
data
[
'organizations'
][
0
]
.
get
(
'img'
),
mock_logo_url
)
@mock.patch
(
UTILS_MODULE
+
'.get_organization_by_short_name'
)
def
test_organization_missing
(
self
,
mock_get_organization_by_short_name
):
""" Verify the logo image is not set if the organizations api returns None """
mock_get_organization_by_short_name
.
return_value
=
None
data
=
utils
.
supplement_program_data
(
self
.
program
,
self
.
user
)
self
.
assertEqual
(
data
[
'organizations'
][
0
]
.
get
(
'img'
),
None
)
@mock.patch
(
UTILS_MODULE
+
'.get_organization_by_short_name'
)
def
test_organization_logo_missing
(
self
,
mock_get_organization_by_short_name
):
"""
Verify the logo image is not set if the organizations api returns organization,
but the logo is not available
"""
mock_get_organization_by_short_name
.
return_value
=
{
'logo'
:
None
}
data
=
utils
.
supplement_program_data
(
self
.
program
,
self
.
user
)
self
.
assertEqual
(
data
[
'organizations'
][
0
]
.
get
(
'img'
),
None
)
openedx/core/djangoapps/programs/utils.py
View file @
8ad34c08
...
...
@@ -15,6 +15,7 @@ from openedx.core.djangoapps.content.course_overviews.models import CourseOvervi
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.lib.edx_api_utils
import
get_edx_api_data
from
student.models
import
CourseEnrollment
from
util.organizations_helpers
import
get_organization_by_short_name
from
xmodule.course_metadata_utils
import
DEFAULT_START_DATE
...
...
@@ -327,6 +328,13 @@ def supplement_program_data(program_data, user):
program_data (dict): Representation of a program.
user (User): The user whose enrollments to inspect.
"""
for
organization
in
program_data
[
'organizations'
]:
# TODO cache the results of the get_organization_by_short_name call
# so we don't have to hit database that frequently
org_obj
=
get_organization_by_short_name
(
organization
[
'key'
])
if
org_obj
and
org_obj
.
get
(
'logo'
):
organization
[
'img'
]
=
org_obj
[
'logo'
]
.
url
for
course_code
in
program_data
[
'course_codes'
]:
for
run_mode
in
course_code
[
'run_modes'
]:
course_key
=
CourseKey
.
from_string
(
run_mode
[
'course_key'
])
...
...
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