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
53ad61a7
Commit
53ad61a7
authored
Sep 02, 2016
by
Clinton Blackburn
Committed by
GitHub
Sep 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #298 from edx/clintonb/language-fix
Language indexing updates
parents
695ec99a
bc3a6fad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
5 deletions
+37
-5
course_discovery/apps/api/tests/test_serializers.py
+5
-1
course_discovery/apps/course_metadata/search_indexes.py
+7
-2
course_discovery/apps/ietf_language_tags/migrations/0003_fix_language_tag_names.py
+2
-2
course_discovery/apps/ietf_language_tags/migrations/0005_fix_language_tag_names_again.py
+23
-0
No files found.
course_discovery/apps/api/tests/test_serializers.py
View file @
53ad61a7
...
...
@@ -26,6 +26,7 @@ from course_discovery.apps.course_metadata.tests.factories import (
OrganizationFactory
,
PersonFactory
,
SeatFactory
,
ProgramFactory
,
CorporateEndorsementFactory
,
EndorsementFactory
,
JobOutlookItemFactory
,
ExpectedLearningItemFactory
,
PositionFactory
)
from
course_discovery.apps.ietf_language_tags.models
import
LanguageTag
# pylint:disable=no-member
...
...
@@ -46,6 +47,9 @@ def serialize_datetime(d):
def
serialize_language
(
language
):
if
language
.
code
.
startswith
(
'zh'
):
return
language
.
name
return
language
.
macrolanguage
...
...
@@ -579,7 +583,7 @@ class AffiliateWindowSerializerTests(TestCase):
class
CourseRunSearchSerializerTests
(
TestCase
):
def
test_data
(
self
):
course_run
=
CourseRunFactory
()
course_run
=
CourseRunFactory
(
transcript_languages
=
LanguageTag
.
objects
.
filter
(
code__in
=
[
'en-us'
,
'zh-cn'
])
)
serializer
=
self
.
serialize_course_run
(
course_run
)
course_run_key
=
CourseKey
.
from_string
(
course_run
.
key
)
...
...
course_discovery/apps/course_metadata/search_indexes.py
View file @
53ad61a7
...
...
@@ -121,12 +121,17 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable):
return
obj
.
status
==
CourseRun
.
Status
.
Published
def
_prepare_language
(
self
,
language
):
if
language
:
# ECOM-5466: Render the macro language for all languages except Chinese
if
language
.
code
.
startswith
(
'zh'
):
return
language
.
name
else
:
return
language
.
macrolanguage
return
None
def
prepare_language
(
self
,
obj
):
if
obj
.
language
:
return
self
.
_prepare_language
(
obj
.
language
)
return
None
def
prepare_number
(
self
,
obj
):
course_run_key
=
CourseKey
.
from_string
(
obj
.
key
)
...
...
course_discovery/apps/ietf_language_tags/migrations/0003_fix_language_tag_names.py
View file @
53ad61a7
...
...
@@ -9,7 +9,7 @@ def fix_tag_names(apps, schema_editor):
LanguageTag
=
apps
.
get_model
(
'ietf_language_tags'
,
'LanguageTag'
)
for
tag
in
LanguageTag
.
objects
.
all
():
tag
.
name
=
tag
.
name
.
replace
(
'
—
'
,
'-'
)
tag
.
name
=
tag
.
name
.
replace
(
'
–
'
,
'-'
)
tag
.
save
()
...
...
@@ -19,5 +19,5 @@ class Migration(migrations.Migration):
]
operations
=
[
migrations
.
RunPython
(
fix_tag_names
),
migrations
.
RunPython
(
fix_tag_names
,
migrations
.
RunPython
.
noop
),
]
course_discovery/apps/ietf_language_tags/migrations/0005_fix_language_tag_names_again.py
0 → 100644
View file @
53ad61a7
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
def
fix_tag_names
(
apps
,
schema_editor
):
""" Replace dashes (—) in tag names with hyphens (-)."""
LanguageTag
=
apps
.
get_model
(
'ietf_language_tags'
,
'LanguageTag'
)
for
tag
in
LanguageTag
.
objects
.
all
():
tag
.
name
=
tag
.
name
.
replace
(
'–'
,
'-'
)
tag
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'ietf_language_tags'
,
'0004_add_chinese_tags'
),
]
operations
=
[
migrations
.
RunPython
(
fix_tag_names
,
migrations
.
RunPython
.
noop
),
]
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