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
ae95e07c
Commit
ae95e07c
authored
May 22, 2014
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deserialze values coming into course_groups views
parent
253ed3b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
+18
-1
common/djangoapps/course_groups/tests/test_views.py
+1
-1
common/djangoapps/course_groups/views.py
+17
-0
No files found.
common/djangoapps/course_groups/tests/test_views.py
View file @
ae95e07c
...
...
@@ -67,7 +67,7 @@ class AddUsersToCohortTestCase(ModuleStoreTestCase):
expected_unknown
=
expected_unknown
or
[]
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"users"
:
users_string
})
request
.
user
=
self
.
staff_user
response
=
add_users_to_cohort
(
request
,
self
.
course
.
id
,
self
.
cohort1
.
id
)
response
=
add_users_to_cohort
(
request
,
self
.
course
.
id
.
to_deprecated_string
()
,
self
.
cohort1
.
id
)
self
.
assertEqual
(
response
.
status_code
,
200
)
result
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
result
.
get
(
"success"
),
True
)
...
...
common/djangoapps/course_groups/views.py
View file @
ae95e07c
...
...
@@ -8,6 +8,7 @@ import json
import
logging
import
re
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
from
courseware.courses
import
get_course_with_access
from
edxmako.shortcuts
import
render_to_response
...
...
@@ -40,6 +41,10 @@ def list_cohorts(request, course_key):
{'success': True,
'cohorts': [{'name': name, 'id': id}, ...]}
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
all_cohorts
=
[{
'name'
:
c
.
name
,
'id'
:
c
.
id
}
...
...
@@ -63,6 +68,9 @@ def add_cohort(request, course_key):
{'success': False,
'msg': error_msg} if there's an error
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
name
=
request
.
POST
.
get
(
"name"
)
...
...
@@ -97,6 +105,9 @@ def users_in_cohort(request, course_key, cohort_id):
'users': [{'username': ..., 'email': ..., 'name': ...}]
}
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
# this will error if called with a non-int cohort_id. That's ok--it
...
...
@@ -144,6 +155,8 @@ def add_users_to_cohort(request, course_key, cohort_id):
'present': [str1, str2, ...], # already there
'unknown': [str1, str2, ...]}
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
cohort
=
cohorts
.
get_cohort_by_id
(
course_key
,
cohort_id
)
...
...
@@ -193,6 +206,8 @@ def remove_user_from_cohort(request, course_key, cohort_id):
{'success': False,
'msg': error_msg}
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
username
=
request
.
POST
.
get
(
'username'
)
...
...
@@ -215,6 +230,8 @@ def debug_cohort_mgmt(request, course_key):
"""
Debugging view for dev.
"""
# this is a string when we get it here
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_key
)
# add staff check to make sure it's safe if it's accidentally deployed.
get_course_with_access
(
request
.
user
,
'staff'
,
course_key
)
...
...
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