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
69886290
Commit
69886290
authored
Aug 14, 2015
by
Eric Fischer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9322 from edx/efischer/tnl3061-rc-branch
Validating team size on join, server-side
parents
1b08d940
fc6930a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
lms/djangoapps/teams/tests/test_views.py
+17
-1
lms/djangoapps/teams/views.py
+7
-1
No files found.
lms/djangoapps/teams/tests/test_views.py
View file @
69886290
...
...
@@ -140,7 +140,8 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
'name'
:
'Public Profiles'
,
'description'
:
'Description for topic 6.'
},
]
],
'max_team_size'
:
1
}
cls
.
test_course_2
=
CourseFactory
.
create
(
org
=
'MIT'
,
...
...
@@ -182,6 +183,13 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
profile
.
year_of_birth
=
1970
profile
.
save
()
# This student is enrolled in the other course, but not yet a member of a team. This is to allow
# course_2 to use a max_team_size of 1 without breaking other tests on course_1
self
.
create_and_enroll_student
(
courses
=
[
self
.
test_course_2
],
username
=
'student_enrolled_other_course_not_on_team'
)
# 'solar team' is intentionally lower case to test case insensitivity in name ordering
self
.
test_team_1
=
CourseTeamFactory
.
create
(
name
=
u'sólar team'
,
...
...
@@ -935,6 +943,14 @@ class TestCreateMembershipAPI(TeamAPITestCase):
)
self
.
assertIn
(
'not enrolled'
,
json
.
loads
(
response
.
content
)[
'developer_message'
])
def
test_over_max_team_size_in_course_2
(
self
):
response
=
self
.
post_create_membership
(
400
,
self
.
build_membership_data
(
'student_enrolled_other_course_not_on_team'
,
self
.
test_team_5
),
user
=
'student_enrolled_other_course_not_on_team'
)
self
.
assertIn
(
'full'
,
json
.
loads
(
response
.
content
)[
'developer_message'
])
@ddt.ddt
class
TestDetailMembershipAPI
(
TeamAPITestCase
):
...
...
lms/djangoapps/teams/views.py
View file @
69886290
...
...
@@ -51,7 +51,6 @@ from .serializers import (
)
from
.errors
import
AlreadyOnTeamInCourse
,
NotEnrolledInCourseForTeam
TEAM_MEMBERSHIPS_PER_PAGE
=
2
TOPICS_PER_PAGE
=
12
...
...
@@ -889,6 +888,13 @@ class MembershipListView(ExpandableFieldViewMixin, GenericAPIView):
except
User
.
DoesNotExist
:
return
Response
(
status
=
status
.
HTTP_404_NOT_FOUND
)
course_module
=
modulestore
()
.
get_course
(
team
.
course_id
)
if
course_module
.
teams_max_size
is
not
None
and
team
.
users
.
count
()
>=
course_module
.
teams_max_size
:
return
Response
(
build_api_error
(
ugettext_noop
(
"This team is already full."
)),
status
=
status
.
HTTP_400_BAD_REQUEST
)
try
:
membership
=
team
.
add_user
(
user
)
except
AlreadyOnTeamInCourse
:
...
...
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