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
ade47343
Commit
ade47343
authored
Sep 08, 2015
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9661 from edx/bderusha/teams-search-index
Add more defensive code around elasticsearch connection
parents
9badf24a
62ef4b5b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
16 deletions
+43
-16
common/test/acceptance/tests/lms/test_teams.py
+2
-0
lms/djangoapps/teams/errors.py
+5
-0
lms/djangoapps/teams/search_indexes.py
+13
-2
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
+4
-4
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
+1
-1
lms/djangoapps/teams/static/teams/js/views/teams_tab.js
+1
-1
lms/djangoapps/teams/static/teams/js/views/topic_teams.js
+9
-6
lms/djangoapps/teams/views.py
+8
-2
No files found.
common/test/acceptance/tests/lms/test_teams.py
View file @
ade47343
...
...
@@ -10,6 +10,7 @@ import ddt
from
flaky
import
flaky
from
nose.plugins.attrib
import
attr
from
uuid
import
uuid4
from
unittest
import
skip
from
..helpers
import
UniqueCourseTest
,
EventsTestMixin
from
...fixtures
import
LMS_BASE_URL
...
...
@@ -705,6 +706,7 @@ class BrowseTeamsWithinTopicTest(TeamsTabBase):
self
.
browse_teams_page
.
click_browse_all_teams_link
()
self
.
assertTrue
(
self
.
topics_page
.
is_browser_on_page
())
@skip
(
'Disabled until search connectivity issues are resolved, see TNL-3206'
)
def
test_search
(
self
):
"""
Scenario: User should be able to search for a team
...
...
lms/djangoapps/teams/errors.py
View file @
ade47343
...
...
@@ -16,6 +16,11 @@ class AlreadyOnTeamInCourse(TeamAPIRequestError):
pass
class
ElasticSearchConnectionError
(
TeamAPIRequestError
):
"""System was unable to connect to the configured elasticsearch instance"""
pass
class
ImmutableMembershipFieldException
(
Exception
):
"""An attempt was made to change an immutable field on a CourseTeamMembership model"""
pass
lms/djangoapps/teams/search_indexes.py
View file @
ade47343
""" Search index used to load data into elasticsearch"""
import
logging
from
requests
import
ConnectionError
from
django.conf
import
settings
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
search.search_engine_base
import
SearchEngine
from
.errors
import
ElasticSearchConnectionError
from
.serializers
import
CourseTeamSerializer
,
CourseTeam
...
...
@@ -78,7 +82,11 @@ class CourseTeamIndexer(object):
Return course team search engine (if feature is enabled).
"""
if
cls
.
search_is_enabled
():
return
SearchEngine
.
get_search_engine
(
index
=
cls
.
INDEX_NAME
)
try
:
return
SearchEngine
.
get_search_engine
(
index
=
cls
.
INDEX_NAME
)
except
ConnectionError
as
err
:
logging
.
error
(
"Error connecting to elasticsearch:
%
s"
,
err
)
raise
ElasticSearchConnectionError
@classmethod
def
search_is_enabled
(
cls
):
...
...
@@ -93,4 +101,7 @@ def course_team_post_save_callback(**kwargs):
"""
Reindex object after save.
"""
CourseTeamIndexer
.
index
(
kwargs
[
'instance'
])
try
:
CourseTeamIndexer
.
index
(
kwargs
[
'instance'
])
except
ElasticSearchConnectionError
:
pass
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
View file @
ade47343
...
...
@@ -134,7 +134,7 @@ define([
));
};
it
(
'can search teams'
,
function
()
{
x
it
(
'can search teams'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
browseTopic
(
TeamSpecHelpers
.
testTopicID
);
...
...
@@ -154,7 +154,7 @@ define([
expect
(
teamsTabView
.
$
(
'.page-description'
).
text
()).
toBe
(
'Showing results for "foo"'
);
});
it
(
'can clear a search'
,
function
()
{
x
it
(
'can clear a search'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
browseTopic
(
TeamSpecHelpers
.
testTopicID
);
...
...
@@ -177,7 +177,7 @@ define([
expect
(
teamsTabView
.
$
(
'.page-description'
).
text
()).
toBe
(
'Test description 1'
);
});
it
(
'clears the search when navigating away and then back'
,
function
()
{
x
it
(
'clears the search when navigating away and then back'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
browseTopic
(
TeamSpecHelpers
.
testTopicID
);
...
...
@@ -199,7 +199,7 @@ define([
expect
(
teamsTabView
.
$
(
'.page-description'
).
text
()).
toBe
(
'Test description 1'
);
});
it
(
'does not switch to showing results when the search returns an error'
,
function
()
{
x
it
(
'does not switch to showing results when the search returns an error'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
browseTopic
(
TeamSpecHelpers
.
testTopicID
);
...
...
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
View file @
ade47343
...
...
@@ -66,7 +66,7 @@ define([
expect
(
Backbone
.
history
.
navigate
.
calls
[
0
].
args
).
toContain
(
'browse'
);
});
it
(
'gives the search field focus when clicking on the search teams link'
,
function
()
{
x
it
(
'gives the search field focus when clicking on the search teams link'
,
function
()
{
var
emptyMembership
=
TeamSpecHelpers
.
createMockTeamMemberships
([]),
teamsView
=
createTopicTeamsView
({
teamMemberships
:
emptyMembership
});
spyOn
(
$
.
fn
,
'focus'
).
andCallThrough
();
...
...
lms/djangoapps/teams/static/teams/js/views/teams_tab.js
View file @
ade47343
...
...
@@ -303,7 +303,7 @@
viewWithHeader
=
this
.
createViewWithHeader
({
subject
:
topic
,
mainView
:
teamsView
,
headerActionsView
:
searchFieldView
,
headerActionsView
:
null
,
// TODO: add back SearchFieldView when search is enabled
title
:
options
.
title
,
description
:
options
.
description
,
breadcrumbs
:
options
.
breadcrumbs
...
...
lms/djangoapps/teams/static/teams/js/views/topic_teams.js
View file @
ade47343
...
...
@@ -57,13 +57,16 @@
},
searchTeams
:
function
(
event
)
{
var
searchField
=
$
(
'.page-header-search .search-field'
);
//
var searchField = $('.page-header-search .search-field');
event
.
preventDefault
();
searchField
.
focus
();
searchField
.
select
();
$
(
'html, body'
).
animate
({
scrollTop
:
0
},
500
);
//searchField.focus();
//searchField.select();
//$('html, body').animate({
// scrollTop: 0
//}, 500);
// TODO! Will navigate to correct place once required functionality is available
Backbone
.
history
.
navigate
(
'browse'
,
{
trigger
:
true
});
},
showCreateTeamForm
:
function
(
event
)
{
...
...
lms/djangoapps/teams/views.py
View file @
ade47343
...
...
@@ -52,7 +52,7 @@ from .serializers import (
add_team_count
)
from
.search_indexes
import
CourseTeamIndexer
from
.errors
import
AlreadyOnTeamInCourse
,
NotEnrolledInCourseForTeam
from
.errors
import
AlreadyOnTeamInCourse
,
NotEnrolledInCourseForTeam
,
ElasticSearchConnectionError
TEAM_MEMBERSHIPS_PER_PAGE
=
2
TOPICS_PER_PAGE
=
12
...
...
@@ -330,7 +330,13 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
result_filter
.
update
({
'topic_id'
:
request
.
QUERY_PARAMS
[
'topic_id'
]})
if
text_search
and
CourseTeamIndexer
.
search_is_enabled
():
search_engine
=
CourseTeamIndexer
.
engine
()
try
:
search_engine
=
CourseTeamIndexer
.
engine
()
except
ElasticSearchConnectionError
:
return
Response
(
build_api_error
(
ugettext_noop
(
'Error connecting to elasticsearch'
)),
status
=
status
.
HTTP_400_BAD_REQUEST
)
result_filter
.
update
({
'course_id'
:
course_id_string
})
search_results
=
search_engine
.
search
(
...
...
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