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
72ea41f9
Commit
72ea41f9
authored
Sep 08, 2015
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't localize search indexes for teams
TNL-3239
parent
3949242c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
lms/djangoapps/teams/search_indexes.py
+9
-6
lms/djangoapps/teams/tests/test_views.py
+17
-5
No files found.
lms/djangoapps/teams/search_indexes.py
View file @
72ea41f9
...
...
@@ -3,6 +3,7 @@
from
django.conf
import
settings
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
django.utils
import
translation
from
search.search_engine_base
import
SearchEngine
...
...
@@ -45,12 +46,14 @@ class CourseTeamIndexer(object):
"""
Generate the text field used for general search.
"""
return
"{name}
\n
{description}
\n
{country}
\n
{language}"
.
format
(
name
=
self
.
course_team
.
name
.
encode
(
'utf-8'
),
description
=
self
.
course_team
.
description
.
encode
(
'utf-8'
),
country
=
self
.
course_team
.
country
.
name
.
format
(),
language
=
self
.
_language_name
()
)
# Always use the English version of any localizable strings (see TNL-3239)
with
translation
.
override
(
'en'
):
return
"{name}
\n
{description}
\n
{country}
\n
{language}"
.
format
(
name
=
self
.
course_team
.
name
.
encode
(
'utf-8'
),
description
=
self
.
course_team
.
description
.
encode
(
'utf-8'
),
country
=
self
.
course_team
.
country
.
name
.
format
(),
language
=
self
.
_language_name
()
)
def
_language_name
(
self
):
"""
...
...
lms/djangoapps/teams/tests/test_views.py
View file @
72ea41f9
...
...
@@ -9,6 +9,7 @@ import ddt
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.db.models.signals
import
post_save
from
django.utils
import
translation
from
nose.plugins.attrib
import
attr
from
rest_framework.test
import
APITestCase
,
APIClient
...
...
@@ -519,12 +520,13 @@ class TestListTeamsAPI(EventTestMixin, TeamAPITestCase):
)
@ddt.unpack
def
test_text_search
(
self
,
text_search
,
expected_team_names
):
# clear out the teams search index before reindexing
CourseTeamIndexer
.
engine
()
.
destroy
()
for
team
in
self
.
test_team_name_id_map
.
values
():
CourseTeamIndexer
.
index
(
team
)
def
reset_search_index
():
"""Clear out the search index and reindex the teams."""
CourseTeamIndexer
.
engine
()
.
destroy
()
for
team
in
self
.
test_team_name_id_map
.
values
():
CourseTeamIndexer
.
index
(
team
)
reset_search_index
()
self
.
verify_names
(
{
'course_id'
:
self
.
test_course_2
.
id
,
'text_search'
:
text_search
},
200
,
...
...
@@ -540,6 +542,16 @@ class TestListTeamsAPI(EventTestMixin, TeamAPITestCase):
number_of_results
=
len
(
expected_team_names
)
)
# Verify that the searches still work for a user from a different locale
with
translation
.
override
(
'ar'
):
reset_search_index
()
self
.
verify_names
(
{
'course_id'
:
self
.
test_course_2
.
id
,
'text_search'
:
text_search
},
200
,
expected_team_names
,
user
=
'student_enrolled_public_profile'
)
@ddt.ddt
class
TestCreateTeamAPI
(
EventTestMixin
,
TeamAPITestCase
):
...
...
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