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
1b6d1b37
Commit
1b6d1b37
authored
Oct 30, 2014
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix i18n and quality errors in course_groups/views.py
parent
8b73de91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
common/djangoapps/course_groups/views.py
+15
-13
No files found.
common/djangoapps/course_groups/views.py
View file @
1b6d1b37
from
django_future.csrf
import
ensure_csrf_cookie
from
django.views.decorators.http
import
require_POST
from
django.contrib.auth.models
import
User
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.core.paginator
import
Paginator
,
EmptyPage
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseBadRequest
from
django.utils.translation
import
ugettext
as
_
import
json
import
logging
import
re
...
...
@@ -27,11 +26,11 @@ def json_http_response(data):
return
HttpResponse
(
json
.
dumps
(
data
),
content_type
=
"application/json"
)
def
split_by_comma_and_whitespace
(
s
):
def
split_by_comma_and_whitespace
(
cstr
):
"""
Split a string both by commas and whitespice. Returns a list.
"""
return
re
.
split
(
r'[\s,]+'
,
s
)
return
re
.
split
(
r'[\s,]+'
,
cstr
)
@ensure_csrf_cookie
...
...
@@ -84,19 +83,21 @@ def add_cohort(request, course_key_string):
name
=
request
.
POST
.
get
(
"name"
)
if
not
name
:
return
json_http_response
({
'success'
:
False
,
'msg'
:
"No name specified"
})
'msg'
:
"No name specified"
})
try
:
cohort
=
cohorts
.
add_cohort
(
course_key
,
name
)
except
ValueError
as
err
:
return
json_http_response
({
'success'
:
False
,
'msg'
:
str
(
err
)})
'msg'
:
str
(
err
)})
return
json_http_response
({
'success'
:
'True'
,
'cohort'
:
{
'id'
:
cohort
.
id
,
'name'
:
cohort
.
name
}})
return
json_http_response
({
'success'
:
'True'
,
'cohort'
:
{
'id'
:
cohort
.
id
,
'name'
:
cohort
.
name
}
})
@ensure_csrf_cookie
...
...
@@ -126,10 +127,11 @@ def users_in_cohort(request, course_key_string, cohort_id):
try
:
page
=
int
(
request
.
GET
.
get
(
'page'
))
except
(
TypeError
,
ValueError
):
return
HttpResponseBadRequest
(
_
(
'Requested page must be numeric'
))
# These strings aren't user-facing so don't translate them
return
HttpResponseBadRequest
(
'Requested page must be numeric'
)
else
:
if
page
<
0
:
return
HttpResponseBadRequest
(
_
(
'Requested page must be greater than zero'
)
)
return
HttpResponseBadRequest
(
'Requested page must be greater than zero'
)
try
:
users
=
paginator
.
page
(
page
)
...
...
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