Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
6d4ed257
Commit
6d4ed257
authored
Aug 22, 2016
by
Clinton Blackburn
Committed by
GitHub
Aug 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #270 from edx/clintonb/course-bug-fixes
Course/CourseRun bug fixes
parents
ed5957f6
5a9f1142
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
course_discovery/apps/api/tests/test_serializers.py
+13
-5
course_discovery/apps/course_metadata/migrations/0022_remove_duplicate_courses.py
+2
-2
course_discovery/apps/course_metadata/search_indexes.py
+4
-1
No files found.
course_discovery/apps/api/tests/test_serializers.py
View file @
6d4ed257
...
@@ -467,13 +467,9 @@ class CourseRunSearchSerializerTests(TestCase):
...
@@ -467,13 +467,9 @@ class CourseRunSearchSerializerTests(TestCase):
def
test_data
(
self
):
def
test_data
(
self
):
course_run
=
CourseRunFactory
()
course_run
=
CourseRunFactory
()
serializer
=
self
.
serialize_course_run
(
course_run
)
course_run_key
=
CourseKey
.
from_string
(
course_run
.
key
)
course_run_key
=
CourseKey
.
from_string
(
course_run
.
key
)
# NOTE: This serializer expects SearchQuerySet results, so we run a search on the newly-created object
# to generate such a result.
result
=
SearchQuerySet
()
.
models
(
CourseRun
)
.
filter
(
key
=
course_run
.
key
)[
0
]
serializer
=
CourseRunSearchSerializer
(
result
)
expected
=
{
expected
=
{
'transcript_languages'
:
[
self
.
serialize_language
(
l
)
for
l
in
course_run
.
transcript_languages
.
all
()],
'transcript_languages'
:
[
self
.
serialize_language
(
l
)
for
l
in
course_run
.
transcript_languages
.
all
()],
'short_description'
:
course_run
.
short_description
,
'short_description'
:
course_run
.
short_description
,
...
@@ -498,6 +494,18 @@ class CourseRunSearchSerializerTests(TestCase):
...
@@ -498,6 +494,18 @@ class CourseRunSearchSerializerTests(TestCase):
}
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
def
serialize_course_run
(
self
,
course_run
):
""" Serializes the given `CourseRun` as a search result. """
result
=
SearchQuerySet
()
.
models
(
CourseRun
)
.
filter
(
key
=
course_run
.
key
)[
0
]
serializer
=
CourseRunSearchSerializer
(
result
)
return
serializer
def
test_data_without_serializers
(
self
):
""" Verify a null `LevelType` is properly serialized as None. """
course_run
=
CourseRunFactory
(
course__level_type
=
None
)
serializer
=
self
.
serialize_course_run
(
course_run
)
self
.
assertEqual
(
serializer
.
data
[
'level_type'
],
None
)
class
ProgramSearchSerializerTests
(
TestCase
):
class
ProgramSearchSerializerTests
(
TestCase
):
def
test_data
(
self
):
def
test_data
(
self
):
...
...
course_discovery/apps/course_metadata/migrations/0022_remove_duplicate_courses.py
View file @
6d4ed257
...
@@ -12,12 +12,12 @@ def remove_duplicate_courses(apps, schema_editor):
...
@@ -12,12 +12,12 @@ def remove_duplicate_courses(apps, schema_editor):
' course_metadata_course AS c'
' course_metadata_course AS c'
' JOIN ('
' JOIN ('
' SELECT'
' SELECT'
' LOWER(
key) AS key
,'
' LOWER(
`key`) AS `key`
,'
' COUNT(1)'
' COUNT(1)'
' FROM'
' FROM'
' course_metadata_course'
' course_metadata_course'
' GROUP BY'
' GROUP BY'
' LOWER(
key
)'
' LOWER(
`key`
)'
' HAVING'
' HAVING'
' COUNT(1) > 1'
' COUNT(1) > 1'
' ) AS dupes ON dupes.key = LOWER(c.key)'
)
' ) AS dupes ON dupes.key = LOWER(c.key)'
)
...
...
course_discovery/apps/course_metadata/search_indexes.py
View file @
6d4ed257
...
@@ -52,7 +52,7 @@ class BaseCourseIndex(OrganizationsMixin, BaseIndex):
...
@@ -52,7 +52,7 @@ class BaseCourseIndex(OrganizationsMixin, BaseIndex):
organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
authoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
authoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
sponsoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
sponsoring_organizations
=
indexes
.
MultiValueField
(
faceted
=
True
)
level_type
=
indexes
.
CharField
(
model_attr
=
'level_type__name'
,
null
=
True
,
faceted
=
True
)
level_type
=
indexes
.
CharField
(
null
=
True
,
faceted
=
True
)
partner
=
indexes
.
CharField
(
model_attr
=
'partner__short_code'
,
null
=
True
,
faceted
=
True
)
partner
=
indexes
.
CharField
(
model_attr
=
'partner__short_code'
,
null
=
True
,
faceted
=
True
)
def
prepare_subjects
(
self
,
obj
):
def
prepare_subjects
(
self
,
obj
):
...
@@ -67,6 +67,9 @@ class BaseCourseIndex(OrganizationsMixin, BaseIndex):
...
@@ -67,6 +67,9 @@ class BaseCourseIndex(OrganizationsMixin, BaseIndex):
def
prepare_sponsoring_organizations
(
self
,
obj
):
def
prepare_sponsoring_organizations
(
self
,
obj
):
return
self
.
_prepare_organizations
(
obj
.
sponsoring_organizations
.
all
())
return
self
.
_prepare_organizations
(
obj
.
sponsoring_organizations
.
all
())
def
prepare_level_type
(
self
,
obj
):
return
obj
.
level_type
.
name
if
obj
.
level_type
else
None
class
CourseIndex
(
BaseCourseIndex
,
indexes
.
Indexable
):
class
CourseIndex
(
BaseCourseIndex
,
indexes
.
Indexable
):
model
=
Course
model
=
Course
...
...
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