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
1d57ef22
Commit
1d57ef22
authored
9 years ago
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix course specific user teams in teams dashboard page
parent
7bb6653d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletions
+70
-1
lms/djangoapps/teams/tests/test_views.py
+69
-0
lms/djangoapps/teams/views.py
+1
-1
No files found.
lms/djangoapps/teams/tests/test_views.py
View file @
1d57ef22
...
...
@@ -147,6 +147,49 @@ class TestDashboard(SharedModuleStoreTestCase):
response
=
self
.
client
.
get
(
bad_team_url
)
self
.
assertEqual
(
404
,
response
.
status_code
)
def
get_user_course_specific_teams_list
(
self
):
"""Gets the list of user course specific teams."""
# Create a course two
course_two
=
CourseFactory
.
create
(
teams_configuration
=
{
"max_team_size"
:
1
,
"topics"
:
[
{
"name"
:
"Test topic for course two"
,
"id"
:
1
,
"description"
:
"Description for test topic for course two."
}
]
}
)
# Login and enroll user in both course course
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
test_password
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
course_two
.
id
)
# Create teams in both courses
course_one_team
=
CourseTeamFactory
.
create
(
name
=
"Course one team"
,
course_id
=
self
.
course
.
id
,
topic_id
=
1
)
course_two_team
=
CourseTeamFactory
.
create
(
name
=
"Course two team"
,
course_id
=
course_two
.
id
,
topic_id
=
1
)
# pylint: disable=unused-variable
# Check that initially list of user teams in course one is empty
course_one_teams_url
=
reverse
(
'teams_dashboard'
,
args
=
[
self
.
course
.
id
])
response
=
self
.
client
.
get
(
course_one_teams_url
)
self
.
assertIn
(
'"teams": {"count": 0'
,
response
.
content
)
# Add user to a course one team
course_one_team
.
add_user
(
self
.
user
)
# Check that list of user teams in course one is not empty, it is one now
response
=
self
.
client
.
get
(
course_one_teams_url
)
self
.
assertIn
(
'"teams": {"count": 1'
,
response
.
content
)
# Check that list of user teams in course two is still empty
course_two_teams_url
=
reverse
(
'teams_dashboard'
,
args
=
[
course_two
.
id
])
response
=
self
.
client
.
get
(
course_two_teams_url
)
self
.
assertIn
(
'"teams": {"count": 0'
,
response
.
content
)
class
TeamAPITestCase
(
APITestCase
,
SharedModuleStoreTestCase
):
"""Base class for Team API test cases."""
...
...
@@ -372,6 +415,32 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
data
.
update
({
'course_id'
:
self
.
test_course_1
.
id
})
return
self
.
make_call
(
reverse
(
'teams_list'
),
expected_status
,
'get'
,
data
,
**
kwargs
)
def
get_user_course_specific_teams_list
(
self
):
"""Gets the list of user course specific teams."""
# Create and enroll user in both courses
user
=
self
.
create_and_enroll_student
(
courses
=
[
self
.
test_course_1
,
self
.
test_course_2
],
username
=
'test_user_enrolled_both_courses'
)
course_one_data
=
{
'course_id'
:
self
.
test_course_1
.
id
,
'username'
:
user
}
course_two_data
=
{
'course_id'
:
self
.
test_course_2
.
id
,
'username'
:
user
}
# Check that initially list of user teams in course one is empty
team_list
=
self
.
get_teams_list
(
user
=
user
,
expected_status
=
200
,
data
=
course_one_data
)
self
.
assertEqual
(
team_list
[
'count'
],
0
)
# Add user to a course one team
self
.
solar_team
.
add_user
(
self
.
users
[
user
])
# Check that list of user teams in course one is not empty now
team_list
=
self
.
get_teams_list
(
user
=
user
,
expected_status
=
200
,
data
=
course_one_data
)
self
.
assertEqual
(
team_list
[
'count'
],
1
)
# Check that list of user teams in course two is still empty
team_list
=
self
.
get_teams_list
(
user
=
user
,
expected_status
=
200
,
data
=
course_two_data
)
self
.
assertEqual
(
team_list
[
'count'
],
0
)
def
build_team_data
(
self
,
name
=
"Test team"
,
course
=
None
,
description
=
"Filler description"
,
**
kwargs
):
"""Creates the payload for creating a team. kwargs can be used to specify additional fields."""
data
=
kwargs
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/teams/views.py
View file @
1d57ef22
...
...
@@ -155,7 +155,7 @@ class TeamsDashboardView(GenericAPIView):
user
=
request
.
user
user_teams
=
CourseTeam
.
objects
.
filter
(
membership__user
=
user
)
user_teams
=
CourseTeam
.
objects
.
filter
(
membership__user
=
user
,
course_id
=
course
.
id
)
user_teams_data
=
self
.
_serialize_and_paginate
(
MyTeamsPagination
,
user_teams
,
...
...
This diff is collapsed.
Click to expand it.
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