Commit 08498bc2 by Usman Khalid

Also pass course_id when fetching memberships for user in team profile view.

TNL-3053
parent b9cf31f4
define([ define([
'underscore', 'common/js/spec_helpers/ajax_helpers', 'teams/js/models/team', 'underscore', 'common/js/spec_helpers/ajax_helpers', 'teams/js/models/team',
'teams/js/spec_helpers/team_spec_helpers',
'teams/js/views/team_join' 'teams/js/views/team_join'
], function (_, AjaxHelpers, TeamModel, TeamJoinView) { ], function (_, AjaxHelpers, TeamModel, TeamSpecHelpers, TeamJoinView) {
'use strict'; 'use strict';
describe('TeamJoinView', function () { describe('TeamJoinView', function () {
var createTeamsUrl, var createTeamsUrl,
...@@ -61,6 +62,7 @@ define([ ...@@ -61,6 +62,7 @@ define([
var teamJoinView = new TeamJoinView( var teamJoinView = new TeamJoinView(
{ {
courseID: TeamSpecHelpers.testCourseID,
model: model, model: model,
teamsUrl: createTeamsUrl(teamId), teamsUrl: createTeamsUrl(teamId),
maxTeamSize: maxTeamSize, maxTeamSize: maxTeamSize,
...@@ -91,7 +93,9 @@ define([ ...@@ -91,7 +93,9 @@ define([
AjaxHelpers.expectRequest( AjaxHelpers.expectRequest(
requests, requests,
'GET', 'GET',
TEAMS_MEMBERSHIP_URL + '?' + $.param({"username": currentUsername}) TEAMS_MEMBERSHIP_URL + '?' + $.param({
'username': currentUsername, 'course_id': TeamSpecHelpers.testCourseID
})
); );
// current user is not a member of any team so we should see the Join Team button // current user is not a member of any team so we should see the Join Team button
...@@ -134,7 +138,9 @@ define([ ...@@ -134,7 +138,9 @@ define([
AjaxHelpers.expectRequest( AjaxHelpers.expectRequest(
requests, requests,
'GET', 'GET',
TEAMS_MEMBERSHIP_URL + '?' + $.param({"username": currentUsername}) TEAMS_MEMBERSHIP_URL + '?' + $.param({
'username': currentUsername, 'course_id': TeamSpecHelpers.testCourseID
})
); );
// current user is a member of another team so we should see the correct message // current user is a member of another team so we should see the correct message
......
...@@ -19,6 +19,7 @@ define(['backbone', ...@@ -19,6 +19,7 @@ define(['backbone',
initialize: function(options) { initialize: function(options) {
this.template = _.template(teamJoinTemplate); this.template = _.template(teamJoinTemplate);
this.courseID = options.courseID;
this.maxTeamSize = options.maxTeamSize; this.maxTeamSize = options.maxTeamSize;
this.currentUsername = options.currentUsername; this.currentUsername = options.currentUsername;
this.teamMembershipsUrl = options.teamMembershipsUrl; this.teamMembershipsUrl = options.teamMembershipsUrl;
...@@ -85,7 +86,7 @@ define(['backbone', ...@@ -85,7 +86,7 @@ define(['backbone',
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: view.teamMembershipsUrl, url: view.teamMembershipsUrl,
data: {'username': username} data: {'username': username, 'course_id': view.courseID}
}).done(function (data) { }).done(function (data) {
info.alreadyMember = (data.count > 0); info.alreadyMember = (data.count > 0);
info.memberOfCurrentTeam = false; info.memberOfCurrentTeam = false;
......
...@@ -290,6 +290,7 @@ ...@@ -290,6 +290,7 @@
}); });
var teamJoinView = new TeamJoinView( var teamJoinView = new TeamJoinView(
{ {
courseID: courseID,
model: team, model: team,
teamsUrl: self.teamsUrl, teamsUrl: self.teamsUrl,
maxTeamSize: self.maxTeamSize, maxTeamSize: self.maxTeamSize,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment