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
c7d379be
Commit
c7d379be
authored
Dec 18, 2012
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add first pass at wiring test registration dialog
parent
b2117c11
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
30 deletions
+123
-30
common/djangoapps/student/views.py
+88
-2
lms/templates/dashboard.html
+2
-1
lms/templates/test_center_register_modal.html
+31
-27
lms/urls.py
+2
-0
No files found.
common/djangoapps/student/views.py
View file @
c7d379be
...
...
@@ -26,7 +26,7 @@ from bs4 import BeautifulSoup
from
django.core.cache
import
cache
from
django_future.csrf
import
ensure_csrf_cookie
,
csrf_exempt
from
student.models
import
(
Registration
,
UserProfile
,
from
student.models
import
(
Registration
,
UserProfile
,
TestCenterUser
,
PendingNameChange
,
PendingEmailChange
,
CourseEnrollment
,
unique_id_for_user
)
...
...
@@ -205,6 +205,14 @@ def dashboard(request):
user
=
request
.
user
enrollments
=
CourseEnrollment
.
objects
.
filter
(
user
=
user
)
# we want to populate the registration page with the relevant information,
# if it already exists. Create an empty object otherwise.
try
:
testcenteruser
=
TestCenterUser
.
objects
.
get
(
user
=
user
)
except
TestCenterUser
.
DoesNotExist
:
testcenteruser
=
TestCenterUser
()
testcenteruser
.
user
=
user
# Build our courses list for the user, but ignore any courses that no longer
# exist (because the course IDs have changed). Still, we don't delete those
# enrollments, because it could have been a data push snafu.
...
...
@@ -244,6 +252,7 @@ def dashboard(request):
'show_courseware_links_for'
:
show_courseware_links_for
,
'cert_statuses'
:
cert_statuses
,
'news'
:
top_news
,
'testcenteruser'
:
testcenteruser
,
}
return
render_to_response
(
'dashboard.html'
,
context
)
...
...
@@ -586,6 +595,83 @@ def create_account(request, post_override=None):
js
=
{
'success'
:
True
}
return
HttpResponse
(
json
.
dumps
(
js
),
mimetype
=
"application/json"
)
@ensure_csrf_cookie
def
create_test_registration
(
request
,
post_override
=
None
):
'''
JSON call to create test registration.
Used by form in test_center_register_modal.html, which is included
into dashboard.html
'''
js
=
{
'success'
:
False
}
post_vars
=
post_override
if
post_override
else
request
.
POST
# Confirm we have a properly formed request
for
a
in
[
'first_name'
,
'last_name'
,
'address_1'
,
'city'
,
'country'
]:
if
a
not
in
post_vars
:
js
[
'value'
]
=
"Error (401 {field}). E-mail us."
.
format
(
field
=
a
)
js
[
'field'
]
=
a
return
HttpResponse
(
json
.
dumps
(
js
))
# Confirm appropriate fields are there.
for
a
in
[
'first_name'
,
'last_name'
,
'address_1'
,
'city'
,
'country'
]:
if
len
(
post_vars
[
a
])
<
2
:
error_str
=
{
'first_name'
:
'First name must be minimum of two characters long.'
,
'last_name'
:
'Last name must be minimum of two characters long.'
,
'address_1'
:
'Last name must be minimum of two characters long.'
,
'city'
:
'Last name must be minimum of two characters long.'
,
'country'
:
'Last name must be minimum of two characters long.'
,
}
js
[
'value'
]
=
error_str
[
a
]
js
[
'field'
]
=
a
return
HttpResponse
(
json
.
dumps
(
js
))
# Once the test_center_user information has been validated, create the entries:
ret
=
_do_create_or_update_test_center_user
(
post_vars
)
if
isinstance
(
ret
,
HttpResponse
):
# if there was an error then return that
return
ret
(
user
,
profile
,
testcenter_user
,
testcenter_registration
)
=
ret
# only do the following if there is accommodation text to send,
# and a destination to which to send it:
if
'accommodation'
in
post_vars
and
settings
.
MITX_FEATURES
.
get
(
'ACCOMMODATION_EMAIL'
):
d
=
{
'accommodation'
:
post_vars
[
'accommodation'
]
}
# composes accommodation email
subject
=
render_to_string
(
'emails/accommodation_email_subject.txt'
,
d
)
# Email subject *must not* contain newlines
subject
=
''
.
join
(
subject
.
splitlines
())
message
=
render_to_string
(
'emails/accommodation_email.txt'
,
d
)
# skip if destination email address is not specified
try
:
dest_addr
=
settings
.
MITX_FEATURES
[
'ACCOMMODATION_EMAIL'
]
send_mail
(
subject
,
message
,
settings
.
DEFAULT_FROM_EMAIL
,
[
dest_addr
],
fail_silently
=
False
)
except
:
log
.
exception
(
sys
.
exc_info
())
js
[
'value'
]
=
'Could not send accommodation e-mail.'
return
HttpResponse
(
json
.
dumps
(
js
))
if
DoExternalAuth
:
eamap
.
user
=
login_user
eamap
.
dtsignup
=
datetime
.
datetime
.
now
()
eamap
.
save
()
log
.
debug
(
'Updated ExternalAuthMap for
%
s to be
%
s'
%
(
post_vars
[
'username'
],
eamap
))
if
settings
.
MITX_FEATURES
.
get
(
'BYPASS_ACTIVATION_EMAIL_FOR_EXTAUTH'
):
log
.
debug
(
'bypassing activation email'
)
login_user
.
is_active
=
True
login_user
.
save
()
# statsd.increment("common.student.account_created")
js
=
{
'success'
:
True
}
return
HttpResponse
(
json
.
dumps
(
js
),
mimetype
=
"application/json"
)
def
get_random_post_override
():
"""
...
...
@@ -641,7 +727,7 @@ def password_reset(request):
# By default, Django doesn't allow Users with is_active = False to reset their passwords,
# but this bites people who signed up a long time ago, never activated, and forgot their
# password. So for their sake, we'll auto-activate a user for whom
e
password_reset is called.
# password. So for their sake, we'll auto-activate a user for whom password_reset is called.
try
:
user
=
User
.
objects
.
get
(
email
=
request
.
POST
[
'email'
])
user
.
is_active
=
True
...
...
lms/templates/dashboard.html
View file @
c7d379be
...
...
@@ -7,6 +7,7 @@
<
%
inherit
file=
"main.html"
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
include
file=
"test_center_register_modal.html"
/>
<
%
block
name=
"title"
><title>
Dashboard
</title></
%
block>
...
...
@@ -221,7 +222,7 @@
<!-- TODO: need to add logic to select which of the following to display. Like certs? -->
<div
class=
"message message-status is-shown exam-register"
>
<a
href=
"#
exam_register
"
rel=
"leanModal"
class=
"exam-button"
id=
"exam_register_button"
>
Register for Pearson exam
</a>
<a
href=
"#
testcenter-register-modal
"
rel=
"leanModal"
class=
"exam-button"
id=
"exam_register_button"
>
Register for Pearson exam
</a>
<p
class=
"message-copy"
>
Registration for the Pearson exam is now open.
</p>
</div>
...
...
lms/templates/test_center_register_modal.html
View file @
c7d379be
...
...
@@ -17,6 +17,10 @@
<div
class=
"notice"
></div>
<div
id=
"register_error"
class=
"modal-form-error"
name=
"register_error"
></div>
<div
id=
"register_error"
name=
"register_error"
></div>
<!-- include these as pass-throughs -->
<input
id=
"id_email"
type=
"hidden"
name=
"email"
maxlength=
"75"
value=
"${user.email}"
/>
<input
id=
"id_username"
type=
"hidden"
name=
"username"
maxlength=
"75"
value=
"${user.username}"
/>
<!-- TODO: add the course somehow... -->
<!-- we should first start with information that we already know about the user,
though we should also give them the option to fix it.
...
...
@@ -24,50 +28,50 @@
or candidate_id.
-->
<div
class=
"input-group"
>
<label
data-field=
"firstname"
>
First Name*
</label>
<input
name=
"first
name"
type=
"text"
value=
"${firstname}
"
placeholder=
"e.g. Jane"
>
<label
data-field=
"lastname"
>
Last Name*
</label>
<input
name=
"last
name"
type=
"text"
value=
"${last
name}"
placeholder=
"e.g. Smith"
>
<label
data-field=
"middlename"
>
Middle Name
</label>
<input
name=
"middle
name"
type=
"text"
value=
"${middle
name}"
placeholder=
"e.g. Michael"
>
<label
data-field=
"first
_
name"
>
First Name*
</label>
<input
name=
"first
_name"
type=
"text"
value=
"${testcenteruser.first_name}"
maxlength=
"30
"
placeholder=
"e.g. Jane"
>
<label
data-field=
"last
_
name"
>
Last Name*
</label>
<input
name=
"last
_name"
type=
"text"
value=
"${testcenteruser.last_
name}"
placeholder=
"e.g. Smith"
>
<label
data-field=
"middle
_
name"
>
Middle Name
</label>
<input
name=
"middle
_name"
type=
"text"
value=
"${testcenteruser.middle_
name}"
placeholder=
"e.g. Michael"
>
<label
data-field=
"suffix"
>
Suffix
</label>
<input
name=
"suffix"
type=
"text"
value=
"${suffix}"
placeholder=
"e.g. Jr."
>
<input
name=
"suffix"
type=
"text"
value=
"${
testcenteruser.
suffix}"
placeholder=
"e.g. Jr."
>
<label
data-field=
"salutation"
>
Salutation
</label>
<input
name=
"salutation"
type=
"text"
value=
"${salutation}"
placeholder=
"e.g. Dr."
>
<input
name=
"salutation"
type=
"text"
value=
"${
testcenteruser.
salutation}"
placeholder=
"e.g. Dr."
>
</div>
<div
class=
"input-group"
>
<label
data-field=
"address1"
>
Address1*
</label>
<input
name=
"address
1"
type=
"text"
value=
"${address
1}"
placeholder=
"123 Main St."
>
<label
data-field=
"address2"
>
Address2
</label>
<input
name=
"address
2"
type=
"text"
value=
"${address
2}"
placeholder=
"Apartment 2B."
>
<label
data-field=
"address3"
>
Address3
</label>
<input
name=
"address
3"
type=
"text"
value=
"${address
3}"
placeholder=
"Attention: John Smith"
>
<label
data-field=
"address
_
1"
>
Address1*
</label>
<input
name=
"address
_1"
type=
"text"
value=
"${testcenteruser.address_
1}"
placeholder=
"123 Main St."
>
<label
data-field=
"address
_
2"
>
Address2
</label>
<input
name=
"address
_2"
type=
"text"
value=
"${testcenteruser.address_
2}"
placeholder=
"Apartment 2B."
>
<label
data-field=
"address
_
3"
>
Address3
</label>
<input
name=
"address
_3"
type=
"text"
value=
"${testcenteruser.address_
3}"
placeholder=
"Attention: John Smith"
>
<label
data-field=
"city"
>
City
</label>
<input
name=
"city"
type=
"text"
value=
"${city}"
placeholder=
"Our Fair City"
>
<input
name=
"city"
type=
"text"
value=
"${
testcenteruser.
city}"
placeholder=
"Our Fair City"
>
<label
data-field=
"state"
>
State/Province
</label>
<input
name=
"state"
type=
"text"
value=
"${state}"
placeholder=
"MA"
>
<input
name=
"state"
type=
"text"
value=
"${
testcenteruser.
state}"
placeholder=
"MA"
>
<label
data-field=
"postal_code"
>
Postal Code
</label>
<input
name=
"postal_code"
type=
"text"
value=
"${postal_code}"
placeholder=
"02138"
>
<input
name=
"postal_code"
type=
"text"
value=
"${
testcenteruser.
postal_code}"
placeholder=
"02138"
>
<label
data-field=
"country"
>
Country Code*
</label>
<input
name=
"country"
type=
"text"
value=
"${country}"
placeholder=
"USA"
>
<input
name=
"country"
type=
"text"
value=
"${
testcenteruser.
country}"
placeholder=
"USA"
>
</div>
<!-- for now, just leave off the phone and company information -->
<div
class=
"input-group"
>
<label
data-field=
"phone"
>
Phone*
</label>
<input
name=
"phone"
type=
"text"
value=
"${phone}"
placeholder=
"1-23-456-7890"
>
<input
name=
"phone"
type=
"text"
value=
"${
testcenteruser.
phone}"
placeholder=
"1-23-456-7890"
>
<label
data-field=
"phone"
>
Extension
</label>
<input
name=
"extension"
type=
"text"
value=
"${extension}"
placeholder=
"x123"
>
<label
data-field=
"phone
-country
"
>
Phone Country Code*
</label>
<input
name=
"phone
-country"
type=
"text"
value=
"${phone_country
}"
placeholder=
"ABC"
>
<input
name=
"extension"
type=
"text"
value=
"${
testcenteruser.
extension}"
placeholder=
"x123"
>
<label
data-field=
"phone
_country_code
"
>
Phone Country Code*
</label>
<input
name=
"phone
_country_code"
type=
"text"
value=
"${testcenteruser.phone_country_code
}"
placeholder=
"ABC"
>
<label
data-field=
"fax"
>
Fax
</label>
<input
name=
"fax"
type=
"text"
value=
"${fax}"
placeholder=
"1-23-456-7891"
>
<label
data-field=
"fax
-country
"
>
Fax Country Code*
</label>
<input
name=
"fax
-country"
type=
"text"
value=
"${fax_country
}"
placeholder=
"ABC"
>
<label
data-field=
"company"
>
Company
</label>
<input
name=
"company
"
type=
"text"
value=
"${company
}"
placeholder=
"Acme Corporation"
>
<input
name=
"fax"
type=
"text"
value=
"${
testcenteruser.
fax}"
placeholder=
"1-23-456-7891"
>
<label
data-field=
"fax
_country_code
"
>
Fax Country Code*
</label>
<input
name=
"fax
_country_code"
type=
"text"
value=
"${testcenteruser.fax_country_code
}"
placeholder=
"ABC"
>
<label
data-field=
"company
_name
"
>
Company
</label>
<input
name=
"company
_name"
type=
"text"
value=
"${testcenteruser.company_name
}"
placeholder=
"Acme Corporation"
>
</div>
<div
class=
"input-group"
>
...
...
lms/urls.py
View file @
c7d379be
...
...
@@ -43,6 +43,8 @@ urlpatterns = ('',
url
(
r'^create_account$'
,
'student.views.create_account'
),
url
(
r'^activate/(?P<key>[^/]*)$'
,
'student.views.activate_account'
,
name
=
"activate"
),
url
(
r'^create_test_registration$'
,
'student.views.create_test_registration'
),
url
(
r'^password_reset/$'
,
'student.views.password_reset'
,
name
=
'password_reset'
),
## Obsolete Django views for password resets
## TODO: Replace with Mako-ized views
...
...
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