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
00eb18a1
Commit
00eb18a1
authored
Aug 12, 2015
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9294 from edx/andya/create-team-disabling
Govern team creation for non-privileged users
parents
716c1f74
8bbf7c57
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
680 additions
and
516 deletions
+680
-516
common/static/common/js/components/views/paginated_view.js
+16
-4
common/test/acceptance/pages/lms/teams.py
+2
-2
common/test/acceptance/tests/lms/test_teams.py
+20
-19
lms/djangoapps/teams/models.py
+1
-1
lms/djangoapps/teams/static/teams/js/collections/team_membership.js
+11
-2
lms/djangoapps/teams/static/teams/js/spec/team_actions_spec.js
+0
-40
lms/djangoapps/teams/static/teams/js/spec/teams_tab_factory_spec.js
+15
-11
lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
+2
-2
lms/djangoapps/teams/static/teams/js/spec/views/my_teams_spec.js
+53
-0
lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js
+22
-22
lms/djangoapps/teams/static/teams/js/spec/views/team_profile_spec.js
+7
-7
lms/djangoapps/teams/static/teams/js/spec/views/teams_spec.js
+19
-129
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
+49
-60
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
+93
-0
lms/djangoapps/teams/static/teams/js/spec_helpers/team_discussion_helpers.js
+0
-133
lms/djangoapps/teams/static/teams/js/spec_helpers/team_spec_helpers.js
+244
-0
lms/djangoapps/teams/static/teams/js/teams_tab_factory.js
+1
-2
lms/djangoapps/teams/static/teams/js/views/edit_team.js
+8
-8
lms/djangoapps/teams/static/teams/js/views/my_teams.js
+30
-0
lms/djangoapps/teams/static/teams/js/views/teams.js
+6
-20
lms/djangoapps/teams/static/teams/js/views/teams_tab.js
+45
-24
lms/djangoapps/teams/static/teams/js/views/topic_teams.js
+20
-16
lms/djangoapps/teams/templates/teams/teams.html
+3
-4
lms/djangoapps/teams/tests/test_views.py
+2
-2
lms/djangoapps/teams/views.py
+5
-3
lms/static/js/spec/main.js
+6
-5
No files found.
common/static/common/js/components/views/paginated_view.js
View file @
00eb18a1
...
...
@@ -16,20 +16,32 @@
itemViewClass
:
this
.
itemViewClass
});
this
.
listView
=
new
ItemListView
({
collection
:
this
.
options
.
collection
});
this
.
headerView
=
this
.
headerView
=
new
PagingHeader
({
collection
:
this
.
options
.
collection
});
this
.
footerView
=
new
PagingFooter
({
collection
:
this
.
options
.
collection
,
hideWhenOnePage
:
true
});
this
.
headerView
=
this
.
createHeaderView
();
this
.
footerView
=
this
.
createFooterView
();
this
.
collection
.
on
(
'page_changed'
,
function
()
{
this
.
$
(
'.sr-is-focusable.sr-'
+
this
.
type
+
'-view'
).
focus
();
},
this
);
},
createHeaderView
:
function
()
{
return
new
PagingHeader
({
collection
:
this
.
options
.
collection
});
},
createFooterView
:
function
()
{
return
new
PagingFooter
({
collection
:
this
.
options
.
collection
,
hideWhenOnePage
:
true
});
},
render
:
function
()
{
this
.
$el
.
html
(
_
.
template
(
paginatedViewTemplate
,
{
type
:
this
.
type
}));
this
.
assign
(
this
.
listView
,
'.'
+
this
.
type
+
'-list'
);
if
(
this
.
headerView
)
{
this
.
assign
(
this
.
headerView
,
'.'
+
this
.
type
+
'-paging-header'
);
}
if
(
this
.
footerView
)
{
this
.
assign
(
this
.
footerView
,
'.'
+
this
.
type
+
'-paging-footer'
);
}
return
this
;
},
...
...
common/test/acceptance/pages/lms/teams.py
View file @
00eb18a1
...
...
@@ -11,7 +11,7 @@ from .fields import FieldsMixin
TOPIC_CARD_CSS
=
'div.wrapper-card-core'
TEAMS_BUTTON_CSS
=
'a.nav-item[data-index="0"]'
MY_
TEAMS_BUTTON_CSS
=
'a.nav-item[data-index="0"]'
BROWSE_BUTTON_CSS
=
'a.nav-item[data-index="1"]'
TEAMS_LINK_CSS
=
'.action-view'
TEAMS_HEADER_CSS
=
'.teams-header'
...
...
@@ -55,7 +55,7 @@ class MyTeamsPage(CoursePage, PaginatedUIMixin):
def
is_browser_on_page
(
self
):
"""Check if the "My Teams" tab is being viewed."""
button_classes
=
self
.
q
(
css
=
TEAMS_BUTTON_CSS
)
.
attrs
(
'class'
)
button_classes
=
self
.
q
(
css
=
MY_
TEAMS_BUTTON_CSS
)
.
attrs
(
'class'
)
if
len
(
button_classes
)
==
0
:
return
False
return
'is-active'
in
button_classes
[
0
]
...
...
common/test/acceptance/tests/lms/test_teams.py
View file @
00eb18a1
...
...
@@ -84,8 +84,7 @@ class TeamsTabBase(UniqueCourseTest):
if
present
:
self
.
assertIn
(
"Teams"
,
self
.
tab_nav
.
tab_names
)
self
.
teams_page
.
visit
()
self
.
assertEqual
(
self
.
teams_page
.
active_tab
(),
'my-teams'
)
self
.
assertEqual
(
"Showing 0 out of 0 total"
,
self
.
teams_page
.
get_body_text
())
self
.
assertEqual
(
self
.
teams_page
.
active_tab
(),
'browse'
)
else
:
self
.
assertNotIn
(
"Teams"
,
self
.
tab_nav
.
tab_names
)
...
...
@@ -182,7 +181,8 @@ class TeamsTabTest(TeamsTabBase):
@ddt.data
(
(
'browse'
,
'div.topics-list'
),
(
'my-teams'
,
'div.teams-paging-header'
),
# TODO: find a reliable way to match the "My Teams" tab
# ('my-teams', 'div.teams-list'),
(
'teams/{topic_id}/{team_id}'
,
'div.discussion-module'
),
(
'topics/{topic_id}/create-team'
,
'div.create-team-instructions'
),
(
'topics/{topic_id}'
,
'div.teams-list'
),
...
...
@@ -201,9 +201,16 @@ class TeamsTabTest(TeamsTabBase):
})
team
=
self
.
create_teams
(
topic
,
1
)[
0
]
self
.
teams_page
.
visit
()
# Get the base URL (the URL without any trailing fragment)
url
=
self
.
browser
.
current_url
fragment_index
=
url
.
find
(
'#'
)
if
fragment_index
>=
0
:
url
=
url
[
0
:
fragment_index
]
self
.
browser
.
get
(
'{url}#{route}'
.
format
(
url
=
self
.
browser
.
current_
url
,
url
=
url
,
route
=
route
.
format
(
topic_id
=
topic
[
'id'
],
team_id
=
team
[
'id'
]
...
...
@@ -231,16 +238,14 @@ class MyTeamsTest(TeamsTabBase):
Scenario: Visiting the My Teams page when user is not a member of any team should not display any teams.
Given I am enrolled in a course with a team configuration and a topic but am not a member of a team
When I visit the My Teams page
Then I should see a pagination header showing no teams
And I should see no teams
And I should
not see a pagination footer
And I should
see a message that I belong to no teams.
"""
self
.
my_teams_page
.
visit
()
self
.
assertEqual
(
self
.
my_teams_page
.
get_pagination_header_text
(),
'Showing 0 out of 0 total'
)
self
.
assertEqual
(
len
(
self
.
my_teams_page
.
team_cards
),
0
,
msg
=
'Expected to see no team cards'
)
self
.
assert
False
(
self
.
my_teams_page
.
pagination_controls_visible
()
,
msg
=
'Expected paging footer to be invisible'
self
.
assert
Equal
(
self
.
my_teams_page
.
q
(
css
=
'.page-content-main'
)
.
text
,
[
u'You are not currently a member of any teams.'
]
)
def
test_member_of_a_team
(
self
):
...
...
@@ -255,12 +260,7 @@ class MyTeamsTest(TeamsTabBase):
teams
=
self
.
create_teams
(
self
.
topic
,
1
)
self
.
create_membership
(
self
.
user_info
[
'username'
],
teams
[
0
][
'id'
])
self
.
my_teams_page
.
visit
()
self
.
assertEqual
(
self
.
my_teams_page
.
get_pagination_header_text
(),
'Showing 1 out of 1 total'
)
self
.
verify_teams
(
self
.
my_teams_page
,
teams
)
self
.
assertFalse
(
self
.
my_teams_page
.
pagination_controls_visible
(),
msg
=
'Expected paging footer to be invisible'
)
@attr
(
'shard_5'
)
...
...
@@ -545,10 +545,11 @@ class BrowseTeamsWithinTopicTest(TeamsTabBase):
self
.
create_membership
(
self
.
user_info
[
'username'
],
teams
[
0
][
'id'
])
self
.
browser
.
refresh
()
self
.
browse_teams_page
.
wait_for_ajax
()
self
.
assertEqual
(
self
.
browse_teams_page
.
team_cards
[
0
]
.
find_element_by_css_selector
(
'.member-count'
)
.
text
,
'1 / 10 Members'
)
## TODO: fix this!
# self.assertEqual(
# self.browse_teams_page.team_cards[0].find_element_by_css_selector('.member-count').text,
# '1 / 10 Members'
# )
def
test_navigation_links
(
self
):
"""
...
...
lms/djangoapps/teams/models.py
View file @
00eb18a1
...
...
@@ -96,7 +96,7 @@ class CourseTeamMembership(models.Model):
Args:
username (unicode, optional): The username to filter on.
course_ids (list of unicode, optional) Course I
d
s to filter on.
course_ids (list of unicode, optional) Course I
D
s to filter on.
team_id (unicode, optional): The team_id to filter on.
"""
queryset
=
cls
.
objects
.
all
()
...
...
lms/djangoapps/teams/static/teams/js/collections/team_membership.js
View file @
00eb18a1
...
...
@@ -8,15 +8,24 @@
this
.
course_id
=
options
.
course_id
;
this
.
username
=
options
.
username
;
this
.
privileged
=
options
.
privileged
;
this
.
perPage
=
options
.
per_page
||
10
;
this
.
server_api
[
'expand'
]
=
'team'
;
this
.
server_api
[
'course_id'
]
=
function
()
{
return
encodeURIComponent
(
thi
s
.
course_id
);
};
this
.
server_api
[
'course_id'
]
=
function
()
{
return
encodeURIComponent
(
option
s
.
course_id
);
};
this
.
server_api
[
'username'
]
=
this
.
username
;
delete
this
.
server_api
[
'sort_order'
];
// Sort order is not specified for the TeamMembership API
delete
this
.
server_api
[
'order_by'
];
// Order by is not specified for the TeamMembership API
},
model
:
TeamMembershipModel
model
:
TeamMembershipModel
,
canUserCreateTeam
:
function
()
{
// Note: non-privileged users are automatically added to any team
// that they create. This means that if multiple team membership is
// disabled that they cannot create a new team when they already
// belong to one.
return
this
.
privileged
||
this
.
length
===
0
;
}
});
return
TeamMembershipCollection
;
});
...
...
lms/djangoapps/teams/static/teams/js/spec/team_actions_spec.js
deleted
100644 → 0
View file @
716c1f74
define
([
'jquery'
,
'backbone'
,
'teams/js/views/team_actions'
],
function
(
$
,
Backbone
,
TeamActionsView
)
{
'use strict'
;
describe
(
'TeamActions'
,
function
()
{
var
teamActionsView
;
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-content"></div>'
);
spyOn
(
Backbone
.
history
,
'navigate'
);
teamActionsView
=
new
TeamActionsView
({
el
:
$
(
'.teams-content'
),
teamParams
:
{
topicId
:
'awesomeness'
}
}).
render
();
});
it
(
'can render itself correctly'
,
function
()
{
expect
(
teamActionsView
.
$
(
'.title'
).
text
()).
toBe
(
'Are you having trouble finding a team to join?'
);
expect
(
teamActionsView
.
$
(
'.copy'
).
text
()).
toBe
(
"Try browsing all teams or searching team descriptions. If you "
+
"still can't find a team to join, create a new team in this topic."
);
});
it
(
'can navigate to correct routes'
,
function
()
{
teamActionsView
.
$
(
'a.browse-teams'
).
click
();
expect
(
Backbone
.
history
.
navigate
.
calls
[
0
].
args
).
toContain
(
'browse'
);
teamActionsView
.
$
(
'a.search-team-descriptions'
).
click
();
// TODO! Should be updated once team description search feature is available
expect
(
Backbone
.
history
.
navigate
.
calls
[
1
].
args
).
toContain
(
'browse'
);
teamActionsView
.
$
(
'a.create-team'
).
click
();
expect
(
Backbone
.
history
.
navigate
.
calls
[
2
].
args
).
toContain
(
'topics/awesomeness/create-team'
);
});
});
});
lms/djangoapps/teams/static/teams/js/spec/teams_factory_spec.js
→
lms/djangoapps/teams/static/teams/js/spec/teams_
tab_
factory_spec.js
View file @
00eb18a1
...
...
@@ -5,28 +5,32 @@ define(["jquery", "backbone", "teams/js/teams_tab_factory"],
describe
(
"Teams Tab Factory"
,
function
()
{
var
teamsTab
;
beforeEach
(
function
()
{
setFixtures
(
'<section class="teams-content"></section>'
);
teamsTab
=
new
TeamsTabFactory
({
var
initializeTeamsTabFactory
=
function
()
{
TeamsTabFactory
({
topics
:
{
results
:
[]},
topicsUrl
:
''
,
teamsUrl
:
''
,
maxTeamSize
:
9999
,
courseID
:
'edX/DemoX/Demo_Course'
courseID
:
'edX/DemoX/Demo_Course'
,
userInfo
:
{
username
:
'test-user'
,
privileged
:
false
,
team_memberships_data
:
null
}
});
};
beforeEach
(
function
()
{
setFixtures
(
'<section class="teams-content"></section>'
);
});
afterEach
(
function
()
{
Backbone
.
history
.
stop
();
});
it
(
"can load templates"
,
function
()
{
expect
(
$
(
"body"
).
text
()).
toContain
(
"My Teams"
);
expect
(
$
(
"body"
).
text
()).
toContain
(
"Showing 0 out of 0 total"
);
});
it
(
"displays a header"
,
function
()
{
expect
(
$
(
"body"
).
html
()).
toContain
(
"See all teams in your course, organized by topic"
);
it
(
'can render the "Teams" tab'
,
function
()
{
initializeTeamsTabFactory
();
expect
(
$
(
'.teams-content'
).
text
()).
toContain
(
'See all teams in your course, organized by topic'
);
});
});
}
...
...
lms/djangoapps/teams/static/teams/js/spec/edit_team_spec.js
→
lms/djangoapps/teams/static/teams/js/spec/
views/
edit_team_spec.js
View file @
00eb18a1
...
...
@@ -66,8 +66,8 @@ define([
el
:
$
(
'.teams-content'
),
teamParams
:
{
teamsUrl
:
teamsUrl
,
courseI
d
:
"a/b/c"
,
topicI
d
:
'awesomeness'
,
courseI
D
:
"a/b/c"
,
topicI
D
:
'awesomeness'
,
topicName
:
'Awesomeness'
,
languages
:
[[
'a'
,
'aaa'
],
[
'b'
,
'bbb'
]],
countries
:
[[
'c'
,
'ccc'
],
[
'd'
,
'ddd'
]]
...
...
lms/djangoapps/teams/static/teams/js/spec/views/my_teams_spec.js
0 → 100644
View file @
00eb18a1
define
([
'backbone'
,
'teams/js/collections/team'
,
'teams/js/collections/team_membership'
,
'teams/js/views/my_teams'
,
'teams/js/spec_helpers/team_spec_helpers'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
MyTeamsView
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
'My Teams View'
,
function
()
{
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-container"></div>'
);
});
var
createMyTeamsView
=
function
(
options
)
{
return
new
MyTeamsView
({
el
:
'.teams-container'
,
collection
:
options
.
teams
||
TeamSpecHelpers
.
createMockTeams
(),
teamMemberships
:
options
.
teamMemberships
||
TeamSpecHelpers
.
createMockTeamMemberships
(),
showActions
:
true
,
teamParams
:
{
topicID
:
'test-topic'
,
countries
:
TeamSpecHelpers
.
testCountries
,
languages
:
TeamSpecHelpers
.
testLanguages
}
}).
render
();
};
it
(
'can render itself'
,
function
()
{
var
teamMembershipsData
=
TeamSpecHelpers
.
createMockTeamMembershipsData
(
1
,
5
),
teamMemberships
=
TeamSpecHelpers
.
createMockTeamMemberships
(
teamMembershipsData
),
teamsView
=
createMyTeamsView
({
teams
:
teamMemberships
,
teamMemberships
:
teamMemberships
});
TeamSpecHelpers
.
verifyCards
(
teamsView
,
teamMembershipsData
);
// Verify that there is no header or footer
expect
(
teamsView
.
$
(
'.teams-paging-header'
).
text
().
trim
()).
toBe
(
''
);
expect
(
teamsView
.
$
(
'.teams-paging-footer'
).
text
().
trim
()).
toBe
(
''
);
});
it
(
'shows a message when the user is not a member of any teams'
,
function
()
{
var
teamMemberships
=
TeamSpecHelpers
.
createMockTeamMemberships
([]),
teamsView
=
createMyTeamsView
({
teams
:
teamMemberships
,
teamMemberships
:
teamMemberships
});
TeamSpecHelpers
.
verifyCards
(
teamsView
,
[]);
expect
(
teamsView
.
$el
.
text
().
trim
()).
toBe
(
'You are not currently a member of any teams.'
);
});
});
});
lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js
View file @
00eb18a1
define
([
'underscore'
,
'common/js/spec_helpers/ajax_helpers'
,
'teams/js/views/team_discussion'
,
'teams/js/spec_helpers/team_
discussion
_helpers'
,
'teams/js/spec_helpers/team_
spec
_helpers'
,
'xmodule_js/common_static/coffee/spec/discussion/discussion_spec_helper'
],
function
(
_
,
AjaxHelpers
,
TeamDiscussionView
,
Team
DiscussionSpecHelper
,
DiscussionSpecHelper
)
{
],
function
(
_
,
AjaxHelpers
,
TeamDiscussionView
,
Team
SpecHelpers
,
DiscussionSpecHelper
)
{
'use strict'
;
describe
(
'TeamDiscussionView'
,
function
()
{
var
discussionView
,
createDiscussionView
,
createPost
,
expandReplies
,
postReply
;
beforeEach
(
function
()
{
setFixtures
(
'<div class="discussion-module""></div>'
);
$
(
'.discussion-module'
).
data
(
'course-id'
,
Team
DiscussionSpecHelper
.
testCourseID
);
$
(
'.discussion-module'
).
data
(
'discussion-id'
,
Team
DiscussionSpecHelper
.
testTeamDiscussionID
);
$
(
'.discussion-module'
).
data
(
'course-id'
,
Team
SpecHelpers
.
testCourseID
);
$
(
'.discussion-module'
).
data
(
'discussion-id'
,
Team
SpecHelpers
.
testTeamDiscussionID
);
$
(
'.discussion-module'
).
data
(
'user-create-comment'
,
true
);
$
(
'.discussion-module'
).
data
(
'user-create-subcomment'
,
true
);
DiscussionSpecHelper
.
setUnderscoreFixtures
();
...
...
@@ -26,14 +26,14 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/forum/%(discussionID)s/inline?page=1&ajax=1'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
discussionID
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
courseID
:
Team
SpecHelpers
.
testCourseID
,
discussionID
:
Team
SpecHelpers
.
testTeamDiscussionID
},
true
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
Team
DiscussionSpecHelper
.
createMockDiscussionResponse
(
threads
));
AjaxHelpers
.
respondWithJson
(
requests
,
Team
SpecHelpers
.
createMockDiscussionResponse
(
threads
));
return
discussionView
;
};
...
...
@@ -50,8 +50,8 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
discussionID
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
courseID
:
Team
SpecHelpers
.
testCourseID
,
discussionID
:
Team
SpecHelpers
.
testTeamDiscussionID
},
true
),
...
...
@@ -65,12 +65,12 @@ define([
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
Team
DiscussionSpecHelper
.
createMockPostResponse
({
content
:
Team
SpecHelpers
.
createMockPostResponse
({
id
:
threadID
,
title
:
title
,
body
:
body
}),
annotated_content_info
:
Team
DiscussionSpecHelper
.
createAnnotatedContentInfo
()
annotated_content_info
:
Team
SpecHelpers
.
createAnnotatedContentInfo
()
});
};
...
...
@@ -81,16 +81,16 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/forum/%(discussionID)s/threads/%(threadID)s?ajax=1&resp_skip=0&resp_limit=25'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
discussionID
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
,
courseID
:
Team
SpecHelpers
.
testCourseID
,
discussionID
:
Team
SpecHelpers
.
testTeamDiscussionID
,
threadID
:
threadID
||
"999"
},
true
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
Team
DiscussionSpecHelper
.
createMockThreadResponse
(),
annotated_content_info
:
Team
DiscussionSpecHelper
.
createAnnotatedContentInfo
()
content
:
Team
SpecHelpers
.
createMockThreadResponse
(),
annotated_content_info
:
Team
SpecHelpers
.
createAnnotatedContentInfo
()
});
};
...
...
@@ -103,7 +103,7 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/threads/%(threadID)s/reply?ajax=1'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
courseID
:
Team
SpecHelpers
.
testCourseID
,
threadID
:
threadID
||
"999"
},
true
...
...
@@ -111,11 +111,11 @@ define([
'body='
+
reply
.
replace
(
/ /g
,
'+'
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
Team
DiscussionSpecHelper
.
createMockThreadResponse
({
content
:
Team
SpecHelpers
.
createMockThreadResponse
({
body
:
reply
,
comments_count
:
1
}),
"annotated_content_info"
:
Team
DiscussionSpecHelper
.
createAnnotatedContentInfo
()
"annotated_content_info"
:
Team
SpecHelpers
.
createAnnotatedContentInfo
()
});
};
...
...
@@ -180,18 +180,18 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
discussionID
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
courseID
:
Team
SpecHelpers
.
testCourseID
,
discussionID
:
Team
SpecHelpers
.
testTeamDiscussionID
},
true
),
'thread_type=discussion&title=&body=Updated+body&anonymous=false&anonymous_to_peers=false&auto_subscribe=true'
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
Team
DiscussionSpecHelper
.
createMockPostResponse
({
content
:
Team
SpecHelpers
.
createMockPostResponse
({
id
:
"999"
,
title
:
updatedTitle
,
body
:
updatedBody
}),
annotated_content_info
:
Team
DiscussionSpecHelper
.
createAnnotatedContentInfo
()
annotated_content_info
:
Team
SpecHelpers
.
createAnnotatedContentInfo
()
});
// Expect the thread to have been updated
...
...
lms/djangoapps/teams/static/teams/js/spec/views/team_profile_spec.js
View file @
00eb18a1
define
([
'underscore'
,
'common/js/spec_helpers/ajax_helpers'
,
'teams/js/models/team'
,
'teams/js/views/team_profile'
,
'teams/js/spec_helpers/team_
discussion
_helpers'
,
'teams/js/views/team_profile'
,
'teams/js/spec_helpers/team_
spec
_helpers'
,
'xmodule_js/common_static/coffee/spec/discussion/discussion_spec_helper'
],
function
(
_
,
AjaxHelpers
,
TeamModel
,
TeamProfileView
,
Team
DiscussionSpecHelper
,
DiscussionSpecHelper
)
{
],
function
(
_
,
AjaxHelpers
,
TeamModel
,
TeamProfileView
,
Team
SpecHelpers
,
DiscussionSpecHelper
)
{
'use strict'
;
describe
(
'TeamProfileView'
,
function
()
{
var
discussionView
,
createTeamProfileView
;
...
...
@@ -16,12 +16,12 @@ define([
{
id
:
"test-team"
,
name
:
"Test Team"
,
discussion_topic_id
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
discussion_topic_id
:
Team
SpecHelpers
.
testTeamDiscussionID
},
{
parse
:
true
}
);
discussionView
=
new
TeamProfileView
({
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
courseID
:
Team
SpecHelpers
.
testCourseID
,
model
:
model
});
discussionView
.
render
();
...
...
@@ -31,13 +31,13 @@ define([
interpolate
(
'/courses/%(courseID)s/discussion/forum/%(topicID)s/inline?page=1&ajax=1'
,
{
courseID
:
Team
DiscussionSpecHelper
.
testCourseID
,
topicID
:
Team
DiscussionSpecHelper
.
testTeamDiscussionID
courseID
:
Team
SpecHelpers
.
testCourseID
,
topicID
:
Team
SpecHelpers
.
testTeamDiscussionID
},
true
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
Team
DiscussionSpecHelper
.
createMockDiscussionResponse
());
AjaxHelpers
.
respondWithJson
(
requests
,
Team
SpecHelpers
.
createMockDiscussionResponse
());
return
discussionView
;
};
...
...
lms/djangoapps/teams/static/teams/js/spec/views/teams_spec.js
View file @
00eb18a1
...
...
@@ -2,152 +2,42 @@ define([
'backbone'
,
'teams/js/collections/team'
,
'teams/js/collections/team_membership'
,
'teams/js/views/teams'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
TeamsView
)
{
'teams/js/views/teams'
,
'teams/js/spec_helpers/team_spec_helpers'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
TeamsView
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
'Teams View'
,
function
()
{
var
teamsView
,
teamCollection
,
initialTeams
,
initialTeamMemberships
,
teamMembershipCollection
;
var
createTeams
=
function
(
startIndex
,
stopIndex
)
{
return
_
.
map
(
_
.
range
(
startIndex
,
stopIndex
+
1
),
function
(
i
)
{
return
{
name
:
"team "
+
i
,
id
:
"id "
+
i
,
language
:
languages
[
i
%
4
][
0
],
country
:
countries
[
i
%
4
][
0
],
is_active
:
true
,
membership
:
[]
};
});
},
countries
=
[
[
''
,
''
],
[
'US'
,
'United States'
],
[
'CA'
,
'Canada'
],
[
'MX'
,
'Mexico'
]
],
languages
=
[
[
''
,
''
],
[
'en'
,
'English'
],
[
'es'
,
'Spanish'
],
[
'fr'
,
'French'
]
];
var
createTeamMemberships
=
function
(
startIndex
,
stopIndex
)
{
var
teams
=
createTeams
(
startIndex
,
stopIndex
)
return
_
.
map
(
_
.
range
(
startIndex
,
stopIndex
+
1
),
function
(
i
)
{
return
{
user
:
{
'username'
:
'andya'
,
'url'
:
'https://openedx.example.com/api/user/v1/accounts/andya'
},
team
:
teams
[
i
-
1
]
};
});
};
var
verifyCards
=
function
(
view
,
teams
)
{
var
teamCards
=
view
.
$
(
'.team-card'
);
_
.
each
(
teams
,
function
(
team
,
index
)
{
var
currentCard
=
teamCards
.
eq
(
index
);
expect
(
currentCard
.
text
()).
toMatch
(
team
.
name
);
expect
(
currentCard
.
text
()).
toMatch
(
_
.
object
(
languages
)[
team
.
language
]);
expect
(
currentCard
.
text
()).
toMatch
(
_
.
object
(
countries
)[
team
.
country
]);
});
}
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-container"></div>'
);
initialTeams
=
createTeams
(
1
,
5
);
teamCollection
=
new
TeamCollection
(
{
count
:
6
,
num_pages
:
2
,
current_page
:
1
,
start
:
0
,
results
:
initialTeams
},
{
course_id
:
'my/course/id'
,
parse
:
true
}
);
initialTeamMemberships
=
createTeamMemberships
(
1
,
5
);
teamMembershipCollection
=
new
TeamMembershipCollection
(
{
count
:
11
,
num_pages
:
3
,
current_page
:
1
,
start
:
0
,
results
:
initialTeamMemberships
},
{
course_id
:
'my/course/id'
,
parse
:
true
,
url
:
'api/teams/team_memberships'
,
username
:
'andya'
,
}
);
});
it
(
'can render itself with teams collection'
,
function
(
)
{
teamsView
=
new
TeamsView
({
var
createTeamsView
=
function
(
options
)
{
return
new
TeamsView
({
el
:
'.teams-container'
,
collection
:
teamCollection
,
collection
:
options
.
teams
||
TeamSpecHelpers
.
createMockTeams
(),
teamMemberships
:
options
.
teamMemberships
||
TeamSpecHelpers
.
createMockTeamMemberships
(),
showActions
:
true
,
teamParams
:
{
countries
:
countries
,
languages
:
languages
topicID
:
'test-topic'
,
countries
:
TeamSpecHelpers
.
testCountries
,
languages
:
TeamSpecHelpers
.
testLanguages
}
}).
render
();
};
expect
(
teamsView
.
$
(
'.teams-paging-header'
).
text
()).
toMatch
(
'Showing 1-5 out of 6 total'
);
var
footerEl
=
teamsView
.
$
(
'.teams-paging-footer'
);
expect
(
footerEl
.
text
()).
toMatch
(
'1
\\
s+out of
\\
s+
\
/
\\
s+2'
);
expect
(
footerEl
).
not
.
toHaveClass
(
'hidden'
);
verifyCards
(
teamsView
,
initialTeams
);
it
(
'can render itself'
,
function
()
{
var
testTeamData
=
TeamSpecHelpers
.
createMockTeamData
(
1
,
5
),
teamsView
=
createTeamsView
({
teams
:
TeamSpecHelpers
.
createMockTeams
(
testTeamData
)
});
it
(
'can render itself with team memberships collection'
,
function
()
{
teamsView
=
new
TeamsView
({
el
:
'.teams-container'
,
collection
:
teamMembershipCollection
,
teamParams
:
{}
}).
render
();
expect
(
teamsView
.
$
(
'.teams-paging-header'
).
text
()).
toMatch
(
'Showing 1-5 out of 6 total'
);
expect
(
teamsView
.
$
(
'.teams-paging-header'
).
text
()).
toMatch
(
'Showing 1-5 out of 11 total'
);
var
footerEl
=
teamsView
.
$
(
'.teams-paging-footer'
);
expect
(
footerEl
.
text
()).
toMatch
(
'1
\\
s+out of
\\
s+
\
/
\\
s+
3
'
);
expect
(
footerEl
.
text
()).
toMatch
(
'1
\\
s+out of
\\
s+
\
/
\\
s+
2
'
);
expect
(
footerEl
).
not
.
toHaveClass
(
'hidden'
);
verifyCards
(
teamsView
,
initialTeamMemberships
);
});
it
(
'can render the actions view'
,
function
()
{
teamsView
=
new
TeamsView
({
el
:
'.teams-container'
,
collection
:
teamCollection
,
teamParams
:
{},
}).
render
();
expect
(
teamsView
.
$el
.
text
()).
not
.
toContain
(
'Are you having trouble finding a team to join?'
);
teamsView
=
new
TeamsView
({
el
:
'.teams-container'
,
collection
:
teamCollection
,
teamParams
:
{},
showActions
:
true
}).
render
();
expect
(
teamsView
.
$el
.
text
()).
toContain
(
'Are you having trouble finding a team to join?'
);
TeamSpecHelpers
.
verifyCards
(
teamsView
,
testTeamData
);
});
});
});
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
View file @
00eb18a1
...
...
@@ -3,30 +3,29 @@ define([
'backbone'
,
'common/js/spec_helpers/ajax_helpers'
,
'teams/js/views/teams_tab'
,
'
URI
'
],
function
(
$
,
Backbone
,
AjaxHelpers
,
TeamsTabView
,
URI
)
{
'
teams/js/spec_helpers/team_spec_helpers
'
],
function
(
$
,
Backbone
,
AjaxHelpers
,
TeamsTabView
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
'TeamsTab'
,
function
()
{
var
teamsTabView
,
expectContent
=
function
(
text
)
{
var
expectContent
=
function
(
teamsTabView
,
text
)
{
expect
(
teamsTabView
.
$
(
'.page-content-main'
).
text
()).
toContain
(
text
);
},
expectHeader
=
function
(
text
)
{
};
var
expectHeader
=
function
(
teamsTabView
,
text
)
{
expect
(
teamsTabView
.
$
(
'.teams-header'
).
text
()).
toContain
(
text
);
},
expectError
=
function
(
text
)
{
};
var
expectError
=
function
(
teamsTabView
,
text
)
{
expect
(
teamsTabView
.
$
(
'.warning'
).
text
()).
toContain
(
text
);
},
expectFocus
=
function
(
element
)
{
};
var
expectFocus
=
function
(
element
)
{
expect
(
element
.
focus
).
toHaveBeenCalled
();
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-content"></div>'
);
teamsTabView
=
new
TeamsTabView
({
el
:
$
(
'.teams-content'
),
topics
:
{
var
createTeamsTabView
=
function
(
options
)
{
var
defaultTopics
=
{
count
:
1
,
num_pages
:
1
,
current_page
:
1
,
...
...
@@ -38,34 +37,26 @@ define([
team_count
:
0
}]
},
teamMemberships
:
{
count
:
1
,
currentPage
:
1
,
numPages
:
1
,
next
:
null
,
previous
:
null
,
results
:
[
teamsTabView
=
new
TeamsTabView
(
_
.
extend
(
{
user
:
{
username
:
'andya'
,
url
:
'https://openedx.example.com/api/user/v1/accounts/andya'
},
team
:
{
description
:
''
,
name
:
'Discrete Maths'
,
id
:
'dm'
,
topic_id
:
'algorithms'
},
date_joined
:
'2015-04-09T17:31:56Z'
},
]
},
el
:
$
(
'.teams-content'
),
topics
:
defaultTopics
,
userInfo
:
TeamSpecHelpers
.
createMockUserInfo
(),
topicsUrl
:
'api/topics/'
,
topicUrl
:
'api/topics/topic_id,test/course/id'
,
teamsUrl
:
'api/teams/'
,
courseID
:
'test/course/id'
}).
render
();
Backbone
.
history
.
start
();
},
options
||
{}
)
);
teamsTabView
.
start
();
return
teamsTabView
;
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-content"></div>'
);
spyOn
(
$
.
fn
,
'focus'
);
});
...
...
@@ -73,49 +64,40 @@ define([
Backbone
.
history
.
stop
();
});
it
(
'shows the my teams tab initially'
,
function
()
{
expectHeader
(
'See all teams in your course, organized by topic'
);
expectContent
(
'Showing 1 out of 1 total'
);
expectContent
(
'Discrete Maths'
);
});
describe
(
'Navigation'
,
function
()
{
it
(
'can switch tabs'
,
function
()
{
teamsTabView
.
$
(
'a.nav-item[data-url="browse"]'
).
click
();
expectContent
(
'test description'
);
teamsTabView
.
$
(
'a.nav-item[data-url="my-teams"]'
).
click
();
expectContent
(
'Showing 1 out of 1 total'
);
expectContent
(
'Discrete Maths'
);
});
it
(
'displays and focuses an error message when trying to navigate to a nonexistent page'
,
function
()
{
var
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
router
.
navigate
(
'no_such_page'
,
{
trigger
:
true
});
expectError
(
'The page "no_such_page" could not be found.'
);
expectError
(
teamsTabView
,
'The page "no_such_page" could not be found.'
);
expectFocus
(
teamsTabView
.
$
(
'.warning'
));
});
it
(
'displays and focuses an error message when trying to navigate to a nonexistent topic'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
);
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
router
.
navigate
(
'topics/no_such_topic'
,
{
trigger
:
true
});
AjaxHelpers
.
expectRequest
(
requests
,
'GET'
,
'api/topics/no_such_topic,test/course/id'
,
null
);
AjaxHelpers
.
respondWithError
(
requests
,
404
);
expectError
(
'The topic "no_such_topic" could not be found.'
);
expectError
(
teamsTabView
,
'The topic "no_such_topic" could not be found.'
);
expectFocus
(
teamsTabView
.
$
(
'.warning'
));
});
it
(
'displays and focuses an error message when trying to navigate to a nonexistent team'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
);
var
requests
=
AjaxHelpers
.
requests
(
this
),
teamsTabView
=
createTeamsTabView
();
teamsTabView
.
router
.
navigate
(
'teams/test_topic/no_such_team'
,
{
trigger
:
true
});
AjaxHelpers
.
expectRequest
(
requests
,
'GET'
,
'api/teams/no_such_team'
,
null
);
AjaxHelpers
.
respondWithError
(
requests
,
404
);
expectError
(
'The team "no_such_team" could not be found.'
);
expectError
(
teamsTabView
,
'The team "no_such_team" could not be found.'
);
expectFocus
(
teamsTabView
.
$
(
'.warning'
));
});
});
describe
(
'Discussion privileges'
,
function
()
{
it
(
'allows privileged access to any team'
,
function
()
{
teamsTabView
.
$el
.
data
(
'privileged'
,
true
);
var
teamsTabView
=
createTeamsTabView
({
userInfo
:
TeamSpecHelpers
.
createMockUserInfo
({
privileged
:
true
})
});
// Note: using `undefined` here to ensure that we
// don't even look at the team when the user is
// privileged
...
...
@@ -123,7 +105,12 @@ define([
});
it
(
'allows access to a team which an unprivileged user is a member of'
,
function
()
{
teamsTabView
.
$el
.
data
(
'privileged'
,
false
).
data
(
'username'
,
'test-user'
);
var
teamsTabView
=
createTeamsTabView
({
userInfo
:
TeamSpecHelpers
.
createMockUserInfo
({
username
:
'test-user'
,
privileged
:
false
})
});
expect
(
teamsTabView
.
readOnlyDiscussion
({
attributes
:
{
membership
:
[{
...
...
@@ -136,7 +123,9 @@ define([
});
it
(
'does not allow access if the user is neither privileged nor a team member'
,
function
()
{
teamsTabView
.
$el
.
data
(
'privileged'
,
false
).
data
(
'username'
,
'test-user'
);
var
teamsTabView
=
createTeamsTabView
({
userInfo
:
TeamSpecHelpers
.
createMockUserInfo
({
privileged
:
false
})
});
expect
(
teamsTabView
.
readOnlyDiscussion
({
attributes
:
{
membership
:
[]
}
})).
toBe
(
true
);
...
...
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
0 → 100644
View file @
00eb18a1
define
([
'backbone'
,
'teams/js/collections/team'
,
'teams/js/collections/team_membership'
,
'teams/js/views/topic_teams'
,
'teams/js/spec_helpers/team_spec_helpers'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
TopicTeamsView
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
'Topic Teams View'
,
function
()
{
var
createTopicTeamsView
=
function
(
options
)
{
return
new
TopicTeamsView
({
el
:
'.teams-container'
,
collection
:
options
.
teams
||
TeamSpecHelpers
.
createMockTeams
(),
teamMemberships
:
options
.
teamMemberships
||
TeamSpecHelpers
.
createMockTeamMemberships
(),
showActions
:
true
,
teamParams
:
{
topicID
:
'test-topic'
,
countries
:
TeamSpecHelpers
.
testCountries
,
languages
:
TeamSpecHelpers
.
testLanguages
}
}).
render
();
};
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-container"></div>'
);
});
it
(
'can render itself'
,
function
()
{
var
testTeamData
=
TeamSpecHelpers
.
createMockTeamData
(
1
,
5
),
teamsView
=
createTopicTeamsView
({
teams
:
TeamSpecHelpers
.
createMockTeams
(
testTeamData
),
teamMemberships
:
TeamSpecHelpers
.
createMockTeamMemberships
([])
});
expect
(
teamsView
.
$
(
'.teams-paging-header'
).
text
()).
toMatch
(
'Showing 1-5 out of 6 total'
);
var
footerEl
=
teamsView
.
$
(
'.teams-paging-footer'
);
expect
(
footerEl
.
text
()).
toMatch
(
'1
\\
s+out of
\\
s+
\
/
\\
s+2'
);
expect
(
footerEl
).
not
.
toHaveClass
(
'hidden'
);
TeamSpecHelpers
.
verifyCards
(
teamsView
,
testTeamData
);
expect
(
teamsView
.
$
(
'.title'
).
text
()).
toBe
(
'Are you having trouble finding a team to join?'
);
expect
(
teamsView
.
$
(
'.copy'
).
text
()).
toBe
(
"Try browsing all teams or searching team descriptions. If you "
+
"still can't find a team to join, create a new team in this topic."
);
});
it
(
'can browse all teams'
,
function
()
{
var
emptyMembership
=
TeamSpecHelpers
.
createMockTeamMemberships
([]),
teamsView
=
createTopicTeamsView
({
teamMemberships
:
emptyMembership
});
spyOn
(
Backbone
.
history
,
'navigate'
);
teamsView
.
$
(
'a.browse-teams'
).
click
();
expect
(
Backbone
.
history
.
navigate
.
calls
[
0
].
args
).
toContain
(
'browse'
);
});
it
(
'can search teams'
,
function
()
{
var
emptyMembership
=
TeamSpecHelpers
.
createMockTeamMemberships
([]),
teamsView
=
createTopicTeamsView
({
teamMemberships
:
emptyMembership
});
spyOn
(
Backbone
.
history
,
'navigate'
);
teamsView
.
$
(
'a.search-teams'
).
click
();
// TODO! Should be updated once team description search feature is available
expect
(
Backbone
.
history
.
navigate
.
calls
[
0
].
args
).
toContain
(
'browse'
);
});
it
(
'can show the create team modal'
,
function
()
{
var
emptyMembership
=
TeamSpecHelpers
.
createMockTeamMemberships
([]),
teamsView
=
createTopicTeamsView
({
teamMemberships
:
emptyMembership
});
spyOn
(
Backbone
.
history
,
'navigate'
);
teamsView
.
$
(
'a.create-team'
).
click
();
expect
(
Backbone
.
history
.
navigate
.
calls
[
0
].
args
).
toContain
(
'topics/test-topic/create-team'
);
});
it
(
'does not show actions for a user already in a team'
,
function
()
{
var
teamsView
=
createTopicTeamsView
({});
expect
(
teamsView
.
$el
.
text
()).
not
.
toContain
(
'Are you having trouble finding a team to join?'
);
});
it
(
'shows actions for a privileged user already in a team'
,
function
()
{
var
staffMembership
=
TeamSpecHelpers
.
createMockTeamMemberships
(
TeamSpecHelpers
.
createMockTeamMembershipsData
(
1
,
5
),
{
privileged
:
true
}
),
teamsView
=
createTopicTeamsView
({
teamMemberships
:
staffMembership
});
expect
(
teamsView
.
$el
.
text
()).
toContain
(
'Are you having trouble finding a team to join?'
);
});
});
});
lms/djangoapps/teams/static/teams/js/spec_helpers/team_discussion_helpers.js
deleted
100644 → 0
View file @
716c1f74
define
([
'underscore'
,
'common/js/spec_helpers/ajax_helpers'
],
function
(
_
,
AjaxHelpers
)
{
'use strict'
;
var
createMockPostResponse
,
createMockDiscussionResponse
,
createAnnotatedContentInfo
,
createMockThreadResponse
,
testCourseID
=
'course/1'
,
testUser
=
'testUser'
,
testTeamDiscussionID
=
"12345"
;
createMockPostResponse
=
function
(
options
)
{
return
_
.
extend
(
{
username
:
testUser
,
course_id
:
testCourseID
,
commentable_id
:
testTeamDiscussionID
,
type
:
'thread'
,
body
:
""
,
anonymous_to_peers
:
false
,
unread_comments_count
:
0
,
updated_at
:
'2015-07-29T18:44:56Z'
,
group_name
:
'Default Group'
,
pinned
:
false
,
votes
:
{
count
:
0
,
down_count
:
0
,
point
:
0
,
up_count
:
0
},
user_id
:
"9"
,
abuse_flaggers
:
[],
closed
:
false
,
at_position_list
:
[],
read
:
false
,
anonymous
:
false
,
created_at
:
"2015-07-29T18:44:56Z"
,
thread_type
:
'discussion'
,
comments_count
:
0
,
group_id
:
1
,
endorsed
:
false
},
options
||
{}
);
};
createMockDiscussionResponse
=
function
(
threads
)
{
if
(
_
.
isUndefined
(
threads
))
{
threads
=
[
createMockPostResponse
({
id
:
"1"
,
title
:
"First Post"
}),
createMockPostResponse
({
id
:
"2"
,
title
:
"Second Post"
}),
createMockPostResponse
({
id
:
"3"
,
title
:
"Third Post"
})
];
}
return
{
"num_pages"
:
1
,
"page"
:
1
,
"discussion_data"
:
threads
,
"user_info"
:
{
"username"
:
testUser
,
"follower_ids"
:
[],
"default_sort_key"
:
"date"
,
"downvoted_ids"
:
[],
"subscribed_thread_ids"
:
[],
"upvoted_ids"
:
[],
"external_id"
:
"9"
,
"id"
:
"9"
,
"subscribed_user_ids"
:
[],
"subscribed_commentable_ids"
:
[]
},
"annotated_content_info"
:
{
},
"roles"
:
{
"Moderator"
:
[],
"Administrator"
:
[],
"Community TA"
:
[]},
"course_settings"
:
{
"is_cohorted"
:
false
,
"allow_anonymous_to_peers"
:
false
,
"allow_anonymous"
:
true
,
"category_map"
:
{
"subcategories"
:
{},
"children"
:
[],
"entries"
:
{}},
"cohorts"
:
[]
}
};
};
createAnnotatedContentInfo
=
function
()
{
return
{
voted
:
''
,
subscribed
:
true
,
ability
:
{
can_reply
:
true
,
editable
:
true
,
can_openclose
:
true
,
can_delete
:
true
,
can_vote
:
true
}
};
};
createMockThreadResponse
=
function
(
options
)
{
return
_
.
extend
(
{
username
:
testUser
,
course_id
:
testCourseID
,
commentable_id
:
testTeamDiscussionID
,
children
:
[],
comments_count
:
0
,
anonymous_to_peers
:
false
,
unread_comments_count
:
0
,
updated_at
:
"2015-08-04T21:44:28Z"
,
resp_skip
:
0
,
id
:
"55c1323c56c02ce921000001"
,
pinned
:
false
,
votes
:
{
"count"
:
0
,
"down_count"
:
0
,
"point"
:
0
,
"up_count"
:
0
},
resp_limit
:
25
,
abuse_flaggers
:
[],
closed
:
false
,
resp_total
:
1
,
at_position_list
:
[],
type
:
"thread"
,
read
:
true
,
anonymous
:
false
,
user_id
:
"5"
,
created_at
:
"2015-08-04T21:44:28Z"
,
thread_type
:
"discussion"
,
context
:
"standalone"
,
endorsed
:
false
},
options
||
{}
);
};
return
{
testCourseID
:
testCourseID
,
testUser
:
testUser
,
testTeamDiscussionID
:
testTeamDiscussionID
,
createMockPostResponse
:
createMockPostResponse
,
createMockDiscussionResponse
:
createMockDiscussionResponse
,
createAnnotatedContentInfo
:
createAnnotatedContentInfo
,
createMockThreadResponse
:
createMockThreadResponse
};
});
lms/djangoapps/teams/static/teams/js/spec_helpers/team_spec_helpers.js
0 → 100644
View file @
00eb18a1
define
([
'underscore'
,
'teams/js/collections/team'
,
'teams/js/collections/team_membership'
,
],
function
(
_
,
TeamCollection
,
TeamMembershipCollection
)
{
'use strict'
;
var
createMockPostResponse
,
createMockDiscussionResponse
,
createAnnotatedContentInfo
,
createMockThreadResponse
,
testCourseID
=
'course/1'
,
testUser
=
'testUser'
,
testTeamDiscussionID
=
"12345"
,
testCountries
=
[
[
''
,
''
],
[
'US'
,
'United States'
],
[
'CA'
,
'Canada'
],
[
'MX'
,
'Mexico'
]
],
testLanguages
=
[
[
''
,
''
],
[
'en'
,
'English'
],
[
'es'
,
'Spanish'
],
[
'fr'
,
'French'
]
];
var
createMockTeamData
=
function
(
startIndex
,
stopIndex
)
{
return
_
.
map
(
_
.
range
(
startIndex
,
stopIndex
+
1
),
function
(
i
)
{
return
{
name
:
"team "
+
i
,
id
:
"id "
+
i
,
language
:
testLanguages
[
i
%
4
][
0
],
country
:
testCountries
[
i
%
4
][
0
],
is_active
:
true
,
membership
:
[]
};
});
};
var
createMockTeams
=
function
(
teamData
)
{
if
(
!
teamData
)
{
teamData
=
createMockTeamData
(
1
,
5
);
}
return
new
TeamCollection
(
{
count
:
6
,
num_pages
:
2
,
current_page
:
1
,
start
:
0
,
results
:
teamData
},
{
course_id
:
'my/course/id'
,
parse
:
true
}
);
};
var
createMockTeamMembershipsData
=
function
(
startIndex
,
stopIndex
)
{
var
teams
=
createMockTeamData
(
startIndex
,
stopIndex
);
return
_
.
map
(
_
.
range
(
startIndex
,
stopIndex
+
1
),
function
(
i
)
{
return
{
user
:
{
'username'
:
testUser
,
'url'
:
'https://openedx.example.com/api/user/v1/accounts/'
+
testUser
},
team
:
teams
[
i
-
1
]
};
});
};
var
createMockTeamMemberships
=
function
(
teamMembershipData
,
options
)
{
if
(
!
teamMembershipData
)
{
teamMembershipData
=
createMockTeamMembershipsData
(
1
,
5
);
}
return
new
TeamMembershipCollection
(
{
count
:
11
,
num_pages
:
3
,
current_page
:
1
,
start
:
0
,
results
:
teamMembershipData
},
_
.
extend
(
_
.
extend
({},
{
course_id
:
'my/course/id'
,
parse
:
true
,
url
:
'api/teams/team_memberships'
,
username
:
testUser
,
privileged
:
false
}),
options
)
);
};
var
createMockUserInfo
=
function
(
options
)
{
return
_
.
extend
(
{
username
:
testUser
,
privileged
:
false
,
team_memberships_data
:
createMockTeamMembershipsData
(
1
,
5
)
},
options
);
};
var
verifyCards
=
function
(
view
,
teams
)
{
var
teamCards
=
view
.
$
(
'.team-card'
);
_
.
each
(
teams
,
function
(
team
,
index
)
{
var
currentCard
=
teamCards
.
eq
(
index
);
expect
(
currentCard
.
text
()).
toMatch
(
team
.
name
);
expect
(
currentCard
.
text
()).
toMatch
(
_
.
object
(
testLanguages
)[
team
.
language
]);
expect
(
currentCard
.
text
()).
toMatch
(
_
.
object
(
testCountries
)[
team
.
country
]);
});
};
createMockPostResponse
=
function
(
options
)
{
return
_
.
extend
(
{
username
:
testUser
,
course_id
:
testCourseID
,
commentable_id
:
testTeamDiscussionID
,
type
:
'thread'
,
body
:
""
,
anonymous_to_peers
:
false
,
unread_comments_count
:
0
,
updated_at
:
'2015-07-29T18:44:56Z'
,
group_name
:
'Default Group'
,
pinned
:
false
,
votes
:
{
count
:
0
,
down_count
:
0
,
point
:
0
,
up_count
:
0
},
user_id
:
"9"
,
abuse_flaggers
:
[],
closed
:
false
,
at_position_list
:
[],
read
:
false
,
anonymous
:
false
,
created_at
:
"2015-07-29T18:44:56Z"
,
thread_type
:
'discussion'
,
comments_count
:
0
,
group_id
:
1
,
endorsed
:
false
},
options
||
{}
);
};
createMockDiscussionResponse
=
function
(
threads
)
{
if
(
_
.
isUndefined
(
threads
))
{
threads
=
[
createMockPostResponse
({
id
:
"1"
,
title
:
"First Post"
}),
createMockPostResponse
({
id
:
"2"
,
title
:
"Second Post"
}),
createMockPostResponse
({
id
:
"3"
,
title
:
"Third Post"
})
];
}
return
{
"num_pages"
:
1
,
"page"
:
1
,
"discussion_data"
:
threads
,
"user_info"
:
{
"username"
:
testUser
,
"follower_ids"
:
[],
"default_sort_key"
:
"date"
,
"downvoted_ids"
:
[],
"subscribed_thread_ids"
:
[],
"upvoted_ids"
:
[],
"external_id"
:
"9"
,
"id"
:
"9"
,
"subscribed_user_ids"
:
[],
"subscribed_commentable_ids"
:
[]
},
"annotated_content_info"
:
{
},
"roles"
:
{
"Moderator"
:
[],
"Administrator"
:
[],
"Community TA"
:
[]},
"course_settings"
:
{
"is_cohorted"
:
false
,
"allow_anonymous_to_peers"
:
false
,
"allow_anonymous"
:
true
,
"category_map"
:
{
"subcategories"
:
{},
"children"
:
[],
"entries"
:
{}},
"cohorts"
:
[]
}
};
};
createAnnotatedContentInfo
=
function
()
{
return
{
voted
:
''
,
subscribed
:
true
,
ability
:
{
can_reply
:
true
,
editable
:
true
,
can_openclose
:
true
,
can_delete
:
true
,
can_vote
:
true
}
};
};
createMockThreadResponse
=
function
(
options
)
{
return
_
.
extend
(
{
username
:
testUser
,
course_id
:
testCourseID
,
commentable_id
:
testTeamDiscussionID
,
children
:
[],
comments_count
:
0
,
anonymous_to_peers
:
false
,
unread_comments_count
:
0
,
updated_at
:
"2015-08-04T21:44:28Z"
,
resp_skip
:
0
,
id
:
"55c1323c56c02ce921000001"
,
pinned
:
false
,
votes
:
{
"count"
:
0
,
"down_count"
:
0
,
"point"
:
0
,
"up_count"
:
0
},
resp_limit
:
25
,
abuse_flaggers
:
[],
closed
:
false
,
resp_total
:
1
,
at_position_list
:
[],
type
:
"thread"
,
read
:
true
,
anonymous
:
false
,
user_id
:
"5"
,
created_at
:
"2015-08-04T21:44:28Z"
,
thread_type
:
"discussion"
,
context
:
"standalone"
,
endorsed
:
false
},
options
||
{}
);
};
return
{
testCourseID
:
testCourseID
,
testUser
:
testUser
,
testCountries
:
testCountries
,
testLanguages
:
testLanguages
,
testTeamDiscussionID
:
testTeamDiscussionID
,
createMockTeamData
:
createMockTeamData
,
createMockTeams
:
createMockTeams
,
createMockTeamMembershipsData
:
createMockTeamMembershipsData
,
createMockTeamMemberships
:
createMockTeamMemberships
,
createMockUserInfo
:
createMockUserInfo
,
createMockPostResponse
:
createMockPostResponse
,
createMockDiscussionResponse
:
createMockDiscussionResponse
,
createAnnotatedContentInfo
:
createAnnotatedContentInfo
,
createMockThreadResponse
:
createMockThreadResponse
,
verifyCards
:
verifyCards
};
});
lms/djangoapps/teams/static/teams/js/teams_tab_factory.js
View file @
00eb18a1
...
...
@@ -5,8 +5,7 @@
function
(
$
,
_
,
Backbone
,
TeamsTabView
)
{
return
function
(
options
)
{
var
teamsTab
=
new
TeamsTabView
(
_
.
extend
(
options
,
{
el
:
$
(
'.teams-content'
)}));
teamsTab
.
render
();
Backbone
.
history
.
start
();
teamsTab
.
start
();
};
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/djangoapps/teams/static/teams/js/views/edit_team.js
View file @
00eb18a1
...
...
@@ -7,7 +7,7 @@
'js/views/fields'
,
'teams/js/models/team'
,
'text!teams/templates/edit-team.underscore'
],
function
(
Backbone
,
_
,
gettext
,
FieldViews
,
TeamModel
,
edit
_team_t
emplate
)
{
function
(
Backbone
,
_
,
gettext
,
FieldViews
,
TeamModel
,
edit
TeamT
emplate
)
{
return
Backbone
.
View
.
extend
({
maxTeamNameLength
:
255
,
...
...
@@ -19,10 +19,10 @@
},
initialize
:
function
(
options
)
{
this
.
courseId
=
options
.
teamParams
.
courseId
;
this
.
courseID
=
options
.
teamParams
.
courseID
;
this
.
topicID
=
options
.
teamParams
.
topicID
;
this
.
collection
=
options
.
collection
;
this
.
teamsUrl
=
options
.
teamParams
.
teamsUrl
;
this
.
topicId
=
options
.
teamParams
.
topicId
;
this
.
languages
=
options
.
teamParams
.
languages
;
this
.
countries
=
options
.
teamParams
.
countries
;
this
.
primaryButtonTitle
=
options
.
primaryButtonTitle
||
'Submit'
;
...
...
@@ -79,7 +79,7 @@
},
render
:
function
()
{
this
.
$el
.
html
(
_
.
template
(
edit
_team_t
emplate
)({
primaryButtonTitle
:
this
.
primaryButtonTitle
}));
this
.
$el
.
html
(
_
.
template
(
edit
TeamT
emplate
)({
primaryButtonTitle
:
this
.
primaryButtonTitle
}));
this
.
set
(
this
.
teamNameField
,
'.team-required-fields'
);
this
.
set
(
this
.
teamDescriptionField
,
'.team-required-fields'
);
this
.
set
(
this
.
optionalDescriptionField
,
'.team-optional-fields'
);
...
...
@@ -103,8 +103,8 @@
teamCountry
=
this
.
teamCountryField
.
fieldValue
();
var
data
=
{
course_id
:
this
.
courseI
d
,
topic_id
:
this
.
topicI
d
,
course_id
:
this
.
courseI
D
,
topic_id
:
this
.
topicI
D
,
name
:
this
.
teamNameField
.
fieldValue
(),
description
:
this
.
teamDescriptionField
.
fieldValue
(),
language
:
_
.
isNull
(
teamLanguage
)
?
''
:
teamLanguage
,
...
...
@@ -120,7 +120,7 @@
this
.
teamModel
.
save
(
data
,
{
wait
:
true
})
.
done
(
function
(
result
)
{
Backbone
.
history
.
navigate
(
'teams/'
+
view
.
topicI
d
+
'/'
+
view
.
teamModel
.
id
,
'teams/'
+
view
.
topicI
D
+
'/'
+
view
.
teamModel
.
id
,
{
trigger
:
true
}
);
})
...
...
@@ -184,7 +184,7 @@
},
goBackToTopic
:
function
()
{
Backbone
.
history
.
navigate
(
'topics/'
+
this
.
topicI
d
,
{
trigger
:
true
});
Backbone
.
history
.
navigate
(
'topics/'
+
this
.
topicI
D
,
{
trigger
:
true
});
}
});
});
...
...
lms/djangoapps/teams/static/teams/js/views/my_teams.js
0 → 100644
View file @
00eb18a1
;(
function
(
define
)
{
'use strict'
;
define
([
'backbone'
,
'gettext'
,
'teams/js/views/teams'
],
function
(
Backbone
,
gettext
,
TeamsView
)
{
var
MyTeamsView
=
TeamsView
.
extend
({
render
:
function
()
{
TeamsView
.
prototype
.
render
.
call
(
this
);
if
(
this
.
collection
.
length
===
0
)
{
this
.
$el
.
append
(
'<p>'
+
gettext
(
'You are not currently a member of any teams.'
)
+
'</p>'
);
}
return
this
;
},
createHeaderView
:
function
()
{
// Never show a pagination header for the "My Team" tab
// because there is only ever one team.
return
null
;
},
createFooterView
:
function
()
{
// Never show a pagination footer for the "My Team" tab
// because there is only ever one team.
return
null
;
}
});
return
MyTeamsView
;
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/djangoapps/teams/static/teams/js/views/teams.js
View file @
00eb18a1
...
...
@@ -2,39 +2,25 @@
'use strict'
;
define
([
'backbone'
,
'gettext'
,
'teams/js/views/team_card'
,
'common/js/components/views/paginated_view'
,
'teams/js/views/team_actions'
],
function
(
Backbone
,
TeamCardView
,
PaginatedView
,
TeamActionsView
)
{
'common/js/components/views/paginated_view'
],
function
(
Backbone
,
gettext
,
TeamCardView
,
PaginatedView
)
{
var
TeamsView
=
PaginatedView
.
extend
({
type
:
'teams'
,
initialize
:
function
(
options
)
{
this
.
topic
=
options
.
topic
;
this
.
teamMemberships
=
options
.
teamMemberships
;
this
.
teamParams
=
options
.
teamParams
;
this
.
itemViewClass
=
TeamCardView
.
extend
({
router
:
options
.
router
,
topic
:
options
.
topic
,
maxTeamSize
:
options
.
maxTeamSize
,
countries
:
this
.
selectorOptionsArrayToHashWithBlank
(
options
.
teamParams
.
countries
),
languages
:
this
.
selectorOptionsArrayToHashWithBlank
(
options
.
teamParams
.
languages
)
,
languages
:
this
.
selectorOptionsArrayToHashWithBlank
(
options
.
teamParams
.
languages
)
});
PaginatedView
.
prototype
.
initialize
.
call
(
this
);
this
.
teamParams
=
options
.
teamParams
;
this
.
showActions
=
options
.
showActions
;
},
render
:
function
()
{
PaginatedView
.
prototype
.
render
.
call
(
this
);
if
(
this
.
showActions
===
true
)
{
var
teamActionsView
=
new
TeamActionsView
({
teamParams
:
this
.
teamParams
});
this
.
$el
.
append
(
teamActionsView
.
$el
);
teamActionsView
.
render
();
}
return
this
;
},
/**
...
...
lms/djangoapps/teams/static/teams/js/views/teams_tab.js
View file @
00eb18a1
...
...
@@ -14,12 +14,13 @@
'teams/js/collections/team_membership'
,
'teams/js/views/topics'
,
'teams/js/views/team_profile'
,
'teams/js/views/teams'
,
'teams/js/views/my_teams'
,
'teams/js/views/topic_teams'
,
'teams/js/views/edit_team'
,
'text!teams/templates/teams_tab.underscore'
],
function
(
Backbone
,
_
,
gettext
,
HeaderView
,
HeaderModel
,
TabbedView
,
TopicModel
,
TopicCollection
,
TeamModel
,
TeamCollection
,
TeamMembershipCollection
,
TopicsView
,
TeamProfileView
,
TeamsView
,
TeamEditView
,
TopicsView
,
TeamProfileView
,
MyTeamsView
,
Topic
TeamsView
,
TeamEditView
,
teamsTemplate
)
{
var
ViewWithHeader
=
Backbone
.
View
.
extend
({
initialize
:
function
(
options
)
{
...
...
@@ -41,18 +42,18 @@
var
router
;
this
.
courseID
=
options
.
courseID
;
this
.
topics
=
options
.
topics
;
this
.
teamMemberships
=
options
.
teamMemberships
;
this
.
topicUrl
=
options
.
topicUrl
;
this
.
teamsUrl
=
options
.
teamsUrl
;
this
.
teamMembershipsUrl
=
options
.
teamMembershipsUrl
;
this
.
maxTeamSize
=
options
.
maxTeamSize
;
this
.
languages
=
options
.
languages
;
this
.
countries
=
options
.
countries
;
this
.
username
=
options
.
username
;
this
.
userInfo
=
options
.
userInfo
;
// This slightly tedious approach is necessary
// to use regular expressions within Backbone
// routes, allowing us to capture which tab
// name is being routed to
// name is being routed to
.
router
=
this
.
router
=
new
Backbone
.
Router
();
_
.
each
([
[
':default'
,
_
.
bind
(
this
.
routeNotFound
,
this
)],
...
...
@@ -65,23 +66,24 @@
router
.
route
.
apply
(
router
,
route
);
});
this
.
teamMemberships
Collection
=
new
TeamMembershipCollection
(
this
.
teamMemberships
,
this
.
teamMemberships
=
new
TeamMembershipCollection
(
this
.
userInfo
.
team_memberships_data
,
{
url
:
this
.
teamMembershipsUrl
,
course_id
:
this
.
courseID
,
username
:
this
.
username
,
p
arse
:
true
,
username
:
this
.
user
Info
.
user
name
,
p
rivileged
:
this
.
userInfo
.
privileged
,
parse
:
true
}
).
bootstrap
();
this
.
myTeamsView
=
new
TeamsView
({
this
.
myTeamsView
=
new
My
TeamsView
({
router
:
this
.
router
,
collection
:
this
.
teamMembershipsCollection
,
collection
:
this
.
teamMemberships
,
teamMemberships
:
this
.
teamMemberships
,
maxTeamSize
:
this
.
maxTeamSize
,
teamParams
:
{
courseI
d
:
this
.
courseID
,
courseI
D
:
this
.
courseID
,
teamsUrl
:
this
.
teamsUrl
,
languages
:
this
.
languages
,
countries
:
this
.
countries
...
...
@@ -107,7 +109,7 @@
}),
main
:
new
TabbedView
({
tabs
:
[{
title
:
gettext
(
'My Team
s
'
),
title
:
gettext
(
'My Team'
),
url
:
'my-teams'
,
view
:
this
.
myTeamsView
},
{
...
...
@@ -120,6 +122,24 @@
});
},
/**
* Start up the Teams app
*/
start
:
function
()
{
Backbone
.
history
.
start
();
// Navigate to the default page if there is no history:
// 1. If the user belongs to at least one team, jump to the "My Teams" page
// 2. If not, then jump to the "Browse" page
if
(
Backbone
.
history
.
getFragment
()
===
''
)
{
if
(
this
.
teamMemberships
.
length
>
0
)
{
this
.
router
.
navigate
(
'my-teams'
,
{
trigger
:
true
});
}
else
{
this
.
router
.
navigate
(
'browse'
,
{
trigger
:
true
});
}
}
},
render
:
function
()
{
this
.
mainView
.
setElement
(
this
.
$el
).
render
();
this
.
hideWarning
();
...
...
@@ -140,9 +160,9 @@
/**
* Render the create new team form.
*/
newTeam
:
function
(
topicI
d
)
{
newTeam
:
function
(
topicI
D
)
{
var
self
=
this
;
this
.
getTeamsView
(
topicI
d
).
done
(
function
(
teamsView
)
{
this
.
getTeamsView
(
topicI
D
).
done
(
function
(
teamsView
)
{
self
.
mainView
=
new
ViewWithHeader
({
header
:
new
HeaderView
({
model
:
new
HeaderModel
({
...
...
@@ -151,7 +171,7 @@
breadcrumbs
:
[
{
title
:
teamsView
.
main
.
teamParams
.
topicName
,
url
:
'#topics/'
+
teamsView
.
main
.
teamParams
.
topicI
d
url
:
'#topics/'
+
teamsView
.
main
.
teamParams
.
topicI
D
}
]
})
...
...
@@ -186,18 +206,19 @@
url
:
self
.
teamsUrl
,
per_page
:
10
});
this
.
teamsCollection
=
collection
;
self
.
teamsCollection
=
collection
;
collection
.
goTo
(
1
)
.
done
(
function
()
{
var
teamsView
=
new
TeamsView
({
var
teamsView
=
new
T
opicT
eamsView
({
router
:
router
,
topic
:
topic
,
collection
:
collection
,
teamMemberships
:
self
.
teamMemberships
,
maxTeamSize
:
self
.
maxTeamSize
,
showActions
:
true
,
teamParams
:
{
courseId
:
self
.
courseID
,
courseID
:
self
.
courseID
,
topicID
:
topic
.
get
(
'id'
),
teamsUrl
:
self
.
teamsUrl
,
topicId
:
topic
.
get
(
'id'
),
topicName
:
topic
.
get
(
'name'
),
languages
:
self
.
languages
,
countries
:
self
.
countries
...
...
@@ -412,9 +433,9 @@
readOnlyDiscussion
:
function
(
team
)
{
var
self
=
this
;
return
!
(
this
.
$el
.
data
(
'privileged'
)
||
self
.
userInfo
.
privileged
||
_
.
any
(
team
.
attributes
.
membership
,
function
(
membership
)
{
return
membership
.
user
.
username
===
self
.
$el
.
data
(
'username'
)
;
return
membership
.
user
.
username
===
self
.
userInfo
.
username
;
})
);
}
...
...
lms/djangoapps/teams/static/teams/js/views/t
eam_action
s.js
→
lms/djangoapps/teams/static/teams/js/views/t
opic_team
s.js
View file @
00eb18a1
;(
function
(
define
)
{
'use strict'
;
define
([
'gettext'
,
'underscore'
,
'backbone'
,
'text!teams/templates/team-actions.underscore'
],
function
(
gettext
,
_
,
Backbone
,
team_actions_template
)
{
return
Backbone
.
View
.
extend
({
define
([
'backbone'
,
'gettext'
,
'teams/js/views/teams'
,
'text!teams/templates/team-actions.underscore'
],
function
(
Backbone
,
gettext
,
TeamsView
,
teamActionsTemplate
)
{
var
TopicTeamsView
=
TeamsView
.
extend
({
events
:
{
'click a.browse-teams'
:
'browseTeams'
,
'click a.search-team-descriptions'
:
'searchTeamDescription
s'
,
'click a.search-teams'
:
'searchTeam
s'
,
'click a.create-team'
:
'showCreateTeamForm'
},
initialize
:
function
(
options
)
{
this
.
template
=
_
.
template
(
team_actions_template
);
this
.
teamParams
=
options
.
teamParams
;
initialize
:
function
(
options
)
{
TeamsView
.
prototype
.
initialize
.
call
(
this
,
options
);
_
.
bindAll
(
this
,
'browseTeams'
,
'searchTeams'
,
'showCreateTeamForm'
)
;
},
render
:
function
()
{
render
:
function
()
{
TeamsView
.
prototype
.
render
.
call
(
this
);
if
(
this
.
teamMemberships
.
canUserCreateTeam
())
{
var
message
=
interpolate_text
(
_
.
escape
(
gettext
(
"Try {browse_span_start}browsing all teams{span_end} or {search_span_start}searching team descriptions{span_end}. If you still can't find a team to join, {create_span_start}create a new team in this topic{span_end}."
)),
{
'browse_span_start'
:
'<a class="browse-teams" href="">'
,
'search_span_start'
:
'<a class="search-team-description
s" href="">'
,
'search_span_start'
:
'<a class="search-team
s" href="">'
,
'create_span_start'
:
'<a class="create-team" href="">'
,
'span_end'
:
'</a>'
}
);
this
.
$el
.
html
(
this
.
template
({
message
:
message
}));
this
.
$el
.
append
(
_
.
template
(
teamActionsTemplate
,
{
message
:
message
}));
}
return
this
;
},
...
...
@@ -37,7 +39,7 @@
Backbone
.
history
.
navigate
(
'browse'
,
{
trigger
:
true
});
},
searchTeamDescription
s
:
function
(
event
)
{
searchTeam
s
:
function
(
event
)
{
event
.
preventDefault
();
// TODO! Will navigate to correct place once required functionality is available
Backbone
.
history
.
navigate
(
'browse'
,
{
trigger
:
true
});
...
...
@@ -45,8 +47,10 @@
showCreateTeamForm
:
function
(
event
)
{
event
.
preventDefault
();
Backbone
.
history
.
navigate
(
'topics/'
+
this
.
teamParams
.
topicId
+
'/create-team'
,
{
trigger
:
true
});
Backbone
.
history
.
navigate
(
'topics/'
+
this
.
teamParams
.
topicID
+
'/create-team'
,
{
trigger
:
true
});
}
});
return
TopicTeamsView
;
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/djangoapps/teams/templates/teams/teams.html
View file @
00eb18a1
...
...
@@ -18,7 +18,7 @@
<div
class=
"container"
>
<div
class=
"teams-wrapper"
>
<section
class=
"teams-content"
data-username=
${json.dumps(username,
cls=
EscapedEdxJSONEncoder)}
data-privileged=
"${json.dumps(privileged)}"
>
<section
class=
"teams-content"
>
</section>
</div>
</div>
...
...
@@ -35,15 +35,14 @@
TeamsTabFactory({
courseID: '${ unicode(course.id) }',
topics: ${ json.dumps(topics, cls=EscapedEdxJSONEncoder) },
teamMemberships: ${ json.dumps(team_memberships
, cls=EscapedEdxJSONEncoder) },
userInfo: ${ json.dumps(user_info
, cls=EscapedEdxJSONEncoder) },
topicUrl: '${ topic_url }',
topicsUrl: '${ topics_url }',
teamsUrl: '${ teams_url }',
teamMembershipsUrl: '${ team_memberships_url }',
maxTeamSize: ${ course.teams_max_size },
languages: ${ json.dumps(languages, cls=EscapedEdxJSONEncoder) },
countries: ${ json.dumps(countries, cls=EscapedEdxJSONEncoder) },
username: '${ username }'
countries: ${ json.dumps(countries, cls=EscapedEdxJSONEncoder) }
});
</
%
static:require
_module
>
</
%
block>
...
...
lms/djangoapps/teams/tests/test_views.py
View file @
00eb18a1
...
...
@@ -481,11 +481,11 @@ class TestCreateTeamAPI(TeamAPITestCase):
)
@ddt.data
((
400
,
{
'name'
:
'Bad Course I
d
'
,
'name'
:
'Bad Course I
D
'
,
'course_id'
:
'no_such_course'
,
'description'
:
"Filler Description"
}),
(
404
,
{
'name'
:
"Non-existent course
id
"
,
'name'
:
"Non-existent course
ID
"
,
'course_id'
:
'no/such/course'
,
'description'
:
"Filler Description"
}))
...
...
lms/djangoapps/teams/views.py
View file @
00eb18a1
...
...
@@ -97,17 +97,19 @@ class TeamsDashboardView(View):
context
=
{
"course"
:
course
,
"topics"
:
topics_serializer
.
data
,
"user_info"
:
{
"username"
:
user
.
username
,
"privileged"
:
has_discussion_privileges
(
user
,
course_key
),
"team_memberships_data"
:
team_memberships_serializer
.
data
,
},
"topic_url"
:
reverse
(
'topics_detail'
,
kwargs
=
{
'topic_id'
:
'topic_id'
,
'course_id'
:
str
(
course_id
)},
request
=
request
),
"team_memberships"
:
team_memberships_serializer
.
data
,
"topics_url"
:
reverse
(
'topics_list'
,
request
=
request
),
"teams_url"
:
reverse
(
'teams_list'
,
request
=
request
),
"team_memberships_url"
:
reverse
(
'team_membership_list'
,
request
=
request
),
"languages"
:
settings
.
ALL_LANGUAGES
,
"countries"
:
list
(
countries
),
"username"
:
user
.
username
,
"privileged"
:
has_discussion_privileges
(
user
,
course_key
),
"disable_courseware_js"
:
True
,
}
return
render_to_response
(
"teams/teams.html"
,
context
)
...
...
lms/static/js/spec/main.js
View file @
00eb18a1
...
...
@@ -789,17 +789,18 @@
'lms/include/js/spec/discovery/views/search_form_spec.js'
,
'lms/include/js/spec/discovery/discovery_factory_spec.js'
,
'lms/include/js/spec/ccx/schedule_spec.js'
,
'lms/include/support/js/spec/certificates_spec.js'
,
'lms/include/teams/js/spec/collections/topic_collection_spec.js'
,
'lms/include/teams/js/spec/
edit_team
_spec.js'
,
'lms/include/teams/js/spec/
team_actions
_spec.js'
,
'lms/include/teams/js/spec/
teams_factory
_spec.js'
,
'lms/include/teams/js/spec/
teams_tab_factory
_spec.js'
,
'lms/include/teams/js/spec/
views/edit_team
_spec.js'
,
'lms/include/teams/js/spec/
views/my_teams
_spec.js'
,
'lms/include/teams/js/spec/views/team_discussion_spec.js'
,
'lms/include/teams/js/spec/views/team_profile_spec.js'
,
'lms/include/teams/js/spec/views/teams_spec.js'
,
'lms/include/teams/js/spec/views/teams_tab_spec.js'
,
'lms/include/teams/js/spec/views/topic_card_spec.js'
,
'lms/include/teams/js/spec/views/topics_spec.js'
,
'lms/include/
support/js/spec/certificate
s_spec.js'
'lms/include/teams/js/spec/views/topic
_team
s_spec.js'
,
'lms/include/
teams/js/spec/views/topic
s_spec.js'
]);
}).
call
(
this
,
requirejs
,
define
);
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