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
fc195ddf
Unverified
Commit
fc195ddf
authored
Dec 13, 2017
by
Matt Tuchfarber
Committed by
GitHub
Dec 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16736 from edx/tuchfarber/WL_1343_instructor_ordering
Order program instructors based on new program field
parents
d674f908
a4f5c14c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
openedx/core/djangoapps/catalog/tests/factories.py
+1
-0
openedx/core/djangoapps/programs/utils.py
+21
-1
No files found.
openedx/core/djangoapps/catalog/tests/factories.py
View file @
fc195ddf
...
...
@@ -189,6 +189,7 @@ class ProgramFactory(DictFactoryBase):
expected_learning_items
=
factory
.
LazyFunction
(
partial
(
generate_instances
,
CourseFactory
))
faq
=
factory
.
LazyFunction
(
partial
(
generate_instances
,
FAQFactory
))
hidden
=
False
instructor_ordering
=
factory
.
LazyFunction
(
partial
(
generate_instances
,
PersonFactory
))
is_program_eligible_for_one_click_purchase
=
True
job_outlook_items
=
factory
.
LazyFunction
(
partial
(
generate_instances
,
JobOutlookItemFactory
))
marketing_slug
=
factory
.
Faker
(
'slug'
)
...
...
openedx/core/djangoapps/programs/utils.py
View file @
fc195ddf
...
...
@@ -698,7 +698,27 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
program_instructors
=
self
.
instructors
cache
.
set
(
cache_key
,
program_instructors
,
3600
)
self
.
data
[
'instructors'
]
=
program_instructors
if
'instructor_ordering'
not
in
self
.
data
:
# If no instructor ordering is set in discovery, it doesn't populate this key
self
.
data
[
'instructor_ordering'
]
=
[]
sorted_instructor_names
=
[
' '
.
join
(
filter
(
None
,
(
instructor
[
'given_name'
],
instructor
[
'family_name'
])))
for
instructor
in
self
.
data
[
'instructor_ordering'
]
]
instructors_to_be_sorted
=
[
instructor
for
instructor
in
program_instructors
if
instructor
[
'name'
]
in
sorted_instructor_names
]
instructors_to_not_be_sorted
=
[
instructor
for
instructor
in
program_instructors
if
instructor
[
'name'
]
not
in
sorted_instructor_names
]
sorted_instructors
=
sorted
(
instructors_to_be_sorted
,
key
=
lambda
item
:
sorted_instructor_names
.
index
(
item
[
'name'
])
)
self
.
data
[
'instructors'
]
=
sorted_instructors
+
instructors_to_not_be_sorted
def
extend
(
self
):
"""Execute extension handlers, returning the extended data."""
...
...
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