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
1ea65455
Commit
1ea65455
authored
Jun 04, 2013
by
dcadams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked on reducing pep8 violations.
parent
56f81fb1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
52 deletions
+42
-52
common/djangoapps/student/views.py
+11
-17
lms/djangoapps/instructor/tests/test_enrollment.py
+2
-3
lms/djangoapps/instructor/views.py
+29
-32
No files found.
common/djangoapps/student/views.py
View file @
1ea65455
...
@@ -264,7 +264,6 @@ def dashboard(request):
...
@@ -264,7 +264,6 @@ def dashboard(request):
if
not
user
.
is_active
:
if
not
user
.
is_active
:
message
=
render_to_string
(
'registration/activate_account_notice.html'
,
{
'email'
:
user
.
email
})
message
=
render_to_string
(
'registration/activate_account_notice.html'
,
{
'email'
:
user
.
email
})
# Global staff can see what courses errored on their dashboard
# Global staff can see what courses errored on their dashboard
staff_access
=
False
staff_access
=
False
errored_courses
=
{}
errored_courses
=
{}
...
@@ -355,7 +354,7 @@ def change_enrollment(request):
...
@@ -355,7 +354,7 @@ def change_enrollment(request):
course
=
course_from_id
(
course_id
)
course
=
course_from_id
(
course_id
)
except
ItemNotFoundError
:
except
ItemNotFoundError
:
log
.
warning
(
"User {0} tried to enroll in non-existent course {1}"
log
.
warning
(
"User {0} tried to enroll in non-existent course {1}"
.
format
(
user
.
username
,
course_id
))
.
format
(
user
.
username
,
course_id
))
return
HttpResponseBadRequest
(
"Course id is invalid"
)
return
HttpResponseBadRequest
(
"Course id is invalid"
)
if
not
has_access
(
user
,
course
,
'enroll'
):
if
not
has_access
(
user
,
course
,
'enroll'
):
...
@@ -363,9 +362,9 @@ def change_enrollment(request):
...
@@ -363,9 +362,9 @@ def change_enrollment(request):
org
,
course_num
,
run
=
course_id
.
split
(
"/"
)
org
,
course_num
,
run
=
course_id
.
split
(
"/"
)
statsd
.
increment
(
"common.student.enrollment"
,
statsd
.
increment
(
"common.student.enrollment"
,
tags
=
[
"org:{0}"
.
format
(
org
),
tags
=
[
"org:{0}"
.
format
(
org
),
"course:{0}"
.
format
(
course_num
),
"course:{0}"
.
format
(
course_num
),
"run:{0}"
.
format
(
run
)])
"run:{0}"
.
format
(
run
)])
try
:
try
:
enrollment
,
created
=
CourseEnrollment
.
objects
.
get_or_create
(
user
=
user
,
course_id
=
course
.
id
)
enrollment
,
created
=
CourseEnrollment
.
objects
.
get_or_create
(
user
=
user
,
course_id
=
course
.
id
)
...
@@ -382,9 +381,9 @@ def change_enrollment(request):
...
@@ -382,9 +381,9 @@ def change_enrollment(request):
org
,
course_num
,
run
=
course_id
.
split
(
"/"
)
org
,
course_num
,
run
=
course_id
.
split
(
"/"
)
statsd
.
increment
(
"common.student.unenrollment"
,
statsd
.
increment
(
"common.student.unenrollment"
,
tags
=
[
"org:{0}"
.
format
(
org
),
tags
=
[
"org:{0}"
.
format
(
org
),
"course:{0}"
.
format
(
course_num
),
"course:{0}"
.
format
(
course_num
),
"run:{0}"
.
format
(
run
)])
"run:{0}"
.
format
(
run
)])
return
HttpResponse
()
return
HttpResponse
()
except
CourseEnrollment
.
DoesNotExist
:
except
CourseEnrollment
.
DoesNotExist
:
...
@@ -454,7 +453,6 @@ def login_user(request, error=""):
...
@@ -454,7 +453,6 @@ def login_user(request, error=""):
expires_time
=
time
.
time
()
+
max_age
expires_time
=
time
.
time
()
+
max_age
expires
=
cookie_date
(
expires_time
)
expires
=
cookie_date
(
expires_time
)
response
.
set_cookie
(
settings
.
EDXMKTG_COOKIE_NAME
,
response
.
set_cookie
(
settings
.
EDXMKTG_COOKIE_NAME
,
'true'
,
max_age
=
max_age
,
'true'
,
max_age
=
max_age
,
expires
=
expires
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
,
expires
=
expires
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
,
...
@@ -515,8 +513,8 @@ def _do_create_account(post_vars):
...
@@ -515,8 +513,8 @@ def _do_create_account(post_vars):
Note: this function is also used for creating test users.
Note: this function is also used for creating test users.
"""
"""
user
=
User
(
username
=
post_vars
[
'username'
],
user
=
User
(
username
=
post_vars
[
'username'
],
email
=
post_vars
[
'email'
],
email
=
post_vars
[
'email'
],
is_active
=
False
)
is_active
=
False
)
user
.
set_password
(
post_vars
[
'password'
])
user
.
set_password
(
post_vars
[
'password'
])
registration
=
Registration
()
registration
=
Registration
()
# TODO: Rearrange so that if part of the process fails, the whole process fails.
# TODO: Rearrange so that if part of the process fails, the whole process fails.
...
@@ -698,7 +696,6 @@ def create_account(request, post_override=None):
...
@@ -698,7 +696,6 @@ def create_account(request, post_override=None):
expires_time
=
time
.
time
()
+
max_age
expires_time
=
time
.
time
()
+
max_age
expires
=
cookie_date
(
expires_time
)
expires
=
cookie_date
(
expires_time
)
response
.
set_cookie
(
settings
.
EDXMKTG_COOKIE_NAME
,
response
.
set_cookie
(
settings
.
EDXMKTG_COOKIE_NAME
,
'true'
,
max_age
=
max_age
,
'true'
,
max_age
=
max_age
,
expires
=
expires
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
,
expires
=
expires
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
,
...
@@ -708,7 +705,6 @@ def create_account(request, post_override=None):
...
@@ -708,7 +705,6 @@ def create_account(request, post_override=None):
return
response
return
response
def
exam_registration_info
(
user
,
course
):
def
exam_registration_info
(
user
,
course
):
""" Returns a Registration object if the user is currently registered for a current
""" Returns a Registration object if the user is currently registered for a current
exam of the course. Returns None if the user is not registered, or if there is no
exam of the course. Returns None if the user is not registered, or if there is no
...
@@ -849,7 +845,6 @@ def create_exam_registration(request, post_override=None):
...
@@ -849,7 +845,6 @@ def create_exam_registration(request, post_override=None):
response_data
[
'non_field_errors'
]
=
form
.
non_field_errors
()
response_data
[
'non_field_errors'
]
=
form
.
non_field_errors
()
return
HttpResponse
(
json
.
dumps
(
response_data
),
mimetype
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
response_data
),
mimetype
=
"application/json"
)
# only do the following if there is accommodation text to send,
# only do the following if there is accommodation text to send,
# and a destination to which to send it.
# and a destination to which to send it.
# TODO: still need to create the accommodation email templates
# TODO: still need to create the accommodation email templates
...
@@ -872,7 +867,6 @@ def create_exam_registration(request, post_override=None):
...
@@ -872,7 +867,6 @@ def create_exam_registration(request, post_override=None):
# response_data['non_field_errors'] = [ 'Could not send accommodation e-mail.', ]
# response_data['non_field_errors'] = [ 'Could not send accommodation e-mail.', ]
# return HttpResponse(json.dumps(response_data), mimetype="application/json")
# return HttpResponse(json.dumps(response_data), mimetype="application/json")
js
=
{
'success'
:
True
}
js
=
{
'success'
:
True
}
return
HttpResponse
(
json
.
dumps
(
js
),
mimetype
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
js
),
mimetype
=
"application/json"
)
...
@@ -916,7 +910,7 @@ def activate_account(request, key):
...
@@ -916,7 +910,7 @@ def activate_account(request, key):
if
not
r
[
0
]
.
user
.
is_active
:
if
not
r
[
0
]
.
user
.
is_active
:
r
[
0
]
.
activate
()
r
[
0
]
.
activate
()
already_active
=
False
already_active
=
False
#Enroll student in any pending courses he/she may have if auto_enroll flag is set
#Enroll student in any pending courses he/she may have if auto_enroll flag is set
student
=
request
.
user
student
=
request
.
user
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
email
=
student
.
email
)
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
email
=
student
.
email
)
...
@@ -924,7 +918,7 @@ def activate_account(request, key):
...
@@ -924,7 +918,7 @@ def activate_account(request, key):
if
cea
.
auto_enroll
:
if
cea
.
auto_enroll
:
course_id
=
cea
.
course_id
course_id
=
cea
.
course_id
enrollment
,
created
=
CourseEnrollment
.
objects
.
get_or_create
(
user_id
=
student
.
id
,
course_id
=
course_id
)
enrollment
,
created
=
CourseEnrollment
.
objects
.
get_or_create
(
user_id
=
student
.
id
,
course_id
=
course_id
)
resp
=
render_to_response
(
"registration/activation_complete.html"
,
{
'user_logged_in'
:
user_logged_in
,
'already_active'
:
already_active
})
resp
=
render_to_response
(
"registration/activation_complete.html"
,
{
'user_logged_in'
:
user_logged_in
,
'already_active'
:
already_active
})
return
resp
return
resp
if
len
(
r
)
==
0
:
if
len
(
r
)
==
0
:
...
...
lms/djangoapps/instructor/tests/test_enrollment.py
View file @
1ea65455
...
@@ -172,7 +172,7 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
...
@@ -172,7 +172,7 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
'''
'''
Clean user input test
Clean user input test
'''
'''
string
=
"abc@test.com, def@test.com ghi@test.com
\n
\n
jkl@test.com "
string
=
"abc@test.com, def@test.com ghi@test.com
\n
\n
jkl@test.com "
cleaned_string
,
cleaned_string_lc
=
get_and_clean_student_list
(
string
)
cleaned_string
,
cleaned_string_lc
=
get_and_clean_student_list
(
string
)
self
.
assertEqual
(
cleaned_string
,
[
'abc@test.com'
,
'def@test.com'
,
'ghi@test.com'
,
'jkl@test.com'
])
self
.
assertEqual
(
cleaned_string
,
[
'abc@test.com'
,
'def@test.com'
,
'ghi@test.com'
,
'jkl@test.com'
])
\ No newline at end of file
lms/djangoapps/instructor/views.py
View file @
1ea65455
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