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
874c6314
Commit
874c6314
authored
Aug 26, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users who are not logged in to register.
parent
15b23a16
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
10 deletions
+25
-10
common/djangoapps/course_modes/views.py
+6
-3
common/djangoapps/student/views.py
+12
-7
lms/templates/login.html
+2
-0
lms/templates/register.html
+5
-0
No files found.
common/djangoapps/course_modes/views.py
View file @
874c6314
...
...
@@ -6,6 +6,8 @@ from django.shortcuts import redirect
from
django.views.generic.base
import
View
from
django.utils.translation
import
ugettext
as
_
from
django.utils.http
import
urlencode
from
django.contrib.auth.decorators
import
login_required
from
django.utils.decorators
import
method_decorator
from
mitxmako.shortcuts
import
render_to_response
...
...
@@ -16,12 +18,13 @@ from student.views import course_from_id
class
ChooseModeView
(
View
):
@method_decorator
(
login_required
)
def
get
(
self
,
request
):
course_id
=
request
.
GET
.
get
(
"course_id"
)
context
=
{
"course_id"
:
course_id
,
"modes"
:
CourseMode
.
modes_for_course_dict
(
course_id
),
"course_name"
:
course_from_id
(
course_id
)
.
display_name
"course_id"
:
course_id
,
"modes"
:
CourseMode
.
modes_for_course_dict
(
course_id
),
"course_name"
:
course_from_id
(
course_id
)
.
display_name
}
return
render_to_response
(
"course_modes/choose.html"
,
context
)
...
...
common/djangoapps/student/views.py
View file @
874c6314
...
...
@@ -325,10 +325,12 @@ def try_change_enrollment(request):
enrollment_response
.
content
)
)
if
enrollment_response
.
content
!=
''
:
return
enrollment_response
.
content
except
Exception
,
e
:
log
.
exception
(
"Exception automatically enrolling after login: {0}"
.
format
(
str
(
e
)))
@login_required
@require_POST
def
change_enrollment
(
request
):
"""
...
...
@@ -354,6 +356,9 @@ def change_enrollment(request):
if
course_id
is
None
:
return
HttpResponseBadRequest
(
_
(
"Course id not specified"
))
if
not
user
.
is_authenticated
():
return
HttpResponseForbidden
()
if
action
==
"enroll"
:
# Make sure the course exists
# We don't do this check on unenroll, or a bad course id can't be unenrolled from
...
...
@@ -458,10 +463,10 @@ def login_user(request, error=""):
log
.
exception
(
e
)
raise
try_change_enrollment
(
request
)
redirect_url
=
try_change_enrollment
(
request
)
statsd
.
increment
(
"common.student.successful_login"
)
response
=
HttpResponse
(
json
.
dumps
({
'success'
:
True
}))
response
=
HttpResponse
(
json
.
dumps
({
'success'
:
True
,
'redirect_url'
:
redirect_url
}))
# set the login cookie for the edx marketing site
# we want this cookie to be accessed via javascript
...
...
@@ -724,14 +729,14 @@ def create_account(request, post_override=None):
login_user
.
save
()
AUDIT_LOG
.
info
(
u"Login activated on extauth account - {0} ({1})"
.
format
(
login_user
.
username
,
login_user
.
email
))
try_change_enrollment
(
request
)
redirect_url
=
try_change_enrollment
(
request
)
statsd
.
increment
(
"common.student.account_created"
)
js
=
{
'success'
:
True
}
HttpResponse
(
json
.
dumps
(
js
),
mimetype
=
"application/json"
)
response_params
=
{
'success'
:
True
,
'redirect_url'
:
redirect_url
}
response
=
HttpResponse
(
json
.
dumps
(
{
'success'
:
True
}
))
response
=
HttpResponse
(
json
.
dumps
(
response_params
))
# set the login cookie for the edx marketing site
# we want this cookie to be accessed via javascript
...
...
lms/templates/login.html
View file @
874c6314
...
...
@@ -50,6 +50,8 @@
next
=
u
.
split
(
"next="
)[
1
];
if
(
next
&&
!
isExternal
(
next
))
{
location
.
href
=
next
;
}
else
if
(
json
.
redirect_url
){
location
.
href
=
json
.
redirect_url
;
}
else
{
location
.
href
=
"${reverse('dashboard')}"
;
}
...
...
lms/templates/register.html
View file @
874c6314
...
...
@@ -53,7 +53,12 @@
$
(
'#register-form'
).
on
(
'ajax:success'
,
function
(
event
,
json
,
xhr
)
{
if
(
json
.
success
)
{
if
(
json
.
redirect_url
){
location
.
href
=
json
.
redirect_url
;
}
else
{
location
.
href
=
"${reverse('dashboard')}"
;
}
}
else
{
toggleSubmitButton
(
true
);
$
(
'.status.message.submission-error'
).
addClass
(
'is-shown'
).
focus
();
...
...
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