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
4b2b734b
Commit
4b2b734b
authored
Sep 26, 2013
by
Jason Bau
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1145 from edx/dcadams/cme_registration
Dcadams/cme registration
parents
6456a7de
352a9407
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
24 deletions
+67
-24
common/djangoapps/cme_registration/models.py
+8
-8
common/djangoapps/cme_registration/tests/registration_tests.py
+16
-5
common/djangoapps/cme_registration/views.py
+35
-5
lms/templates/cme_register.html
+8
-6
No files found.
common/djangoapps/cme_registration/models.py
View file @
4b2b734b
...
@@ -212,7 +212,7 @@ class CmeUserProfile(UserProfile):
...
@@ -212,7 +212,7 @@ class CmeUserProfile(UserProfile):
(
'Guyana'
,
'Guyana'
),
(
'Guyana'
,
'Guyana'
),
(
'Haiti'
,
'Haiti'
),
(
'Haiti'
,
'Haiti'
),
(
'Heard Island And McDonald Is lands'
,
'Heard Island And McDonald Is lands'
),
(
'Heard Island And McDonald Is lands'
,
'Heard Island And McDonald Is lands'
),
(
'Holy See (V
.atican City State)'
,
'Holy See (V.
atican City State)'
),
(
'Holy See (V
atican City State)'
,
'Holy See (V
atican City State)'
),
(
'Honduras'
,
'Honduras'
),
(
'Honduras'
,
'Honduras'
),
(
'Hong Kong'
,
'Hong Kong'
),
(
'Hong Kong'
,
'Hong Kong'
),
(
'Hungary'
,
'Hungary'
),
(
'Hungary'
,
'Hungary'
),
...
@@ -245,8 +245,8 @@ class CmeUserProfile(UserProfile):
...
@@ -245,8 +245,8 @@ class CmeUserProfile(UserProfile):
(
'Liechtenstein'
,
'Liechtenstein'
),
(
'Liechtenstein'
,
'Liechtenstein'
),
(
'Lithuania'
,
'Lithuania'
),
(
'Lithuania'
,
'Lithuania'
),
(
'Luxembourg'
,
'Luxembourg'
),
(
'Luxembourg'
,
'Luxembourg'
),
(
'Mac
Ao'
,
'MacA
o'
),
(
'Mac
ao'
,
'Maca
o'
),
(
'Mac
Edonia, The Former Yugoslav Republic Of'
,
'MacE
donia, The Former Yugoslav Republic Of'
),
(
'Mac
edonia, The Former Yugoslav Republic Of'
,
'Mace
donia, The Former Yugoslav Republic Of'
),
(
'Madagascar'
,
'Madagascar'
),
(
'Madagascar'
,
'Madagascar'
),
(
'Malawi'
,
'Malawi'
),
(
'Malawi'
,
'Malawi'
),
(
'Malaysia'
,
'Malaysia'
),
(
'Malaysia'
,
'Malaysia'
),
...
@@ -255,7 +255,7 @@ class CmeUserProfile(UserProfile):
...
@@ -255,7 +255,7 @@ class CmeUserProfile(UserProfile):
(
'Malta'
,
'Malta'
),
(
'Malta'
,
'Malta'
),
(
'Marshall Islands'
,
'Marshall Islands'
),
(
'Marshall Islands'
,
'Marshall Islands'
),
(
'Martinique'
,
'Martinique'
),
(
'Martinique'
,
'Martinique'
),
(
'Mauritan
ia'
,
'Mauritan
ia'
),
(
'Mauritan
ia'
,
'Mauritan
ia'
),
(
'Mauritius'
,
'Mauritius'
),
(
'Mauritius'
,
'Mauritius'
),
(
'Mayotte'
,
'Mayotte'
),
(
'Mayotte'
,
'Mayotte'
),
(
'Mexico'
,
'Mexico'
),
(
'Mexico'
,
'Mexico'
),
...
@@ -282,7 +282,6 @@ class CmeUserProfile(UserProfile):
...
@@ -282,7 +282,6 @@ class CmeUserProfile(UserProfile):
(
'Norfolk Island'
,
'Norfolk Island'
),
(
'Norfolk Island'
,
'Norfolk Island'
),
(
'Northern Mariana Islands'
,
'Northern Mariana Islands'
),
(
'Northern Mariana Islands'
,
'Northern Mariana Islands'
),
(
'Norway'
,
'Norway'
),
(
'Norway'
,
'Norway'
),
(
'Not Specified'
,
'Not Specified'
),
(
'Oman'
,
'Oman'
),
(
'Oman'
,
'Oman'
),
(
'Pakistan'
,
'Pakistan'
),
(
'Pakistan'
,
'Pakistan'
),
(
'Palau'
,
'Palau'
),
(
'Palau'
,
'Palau'
),
...
@@ -292,7 +291,7 @@ class CmeUserProfile(UserProfile):
...
@@ -292,7 +291,7 @@ class CmeUserProfile(UserProfile):
(
'Paraguay'
,
'Paraguay'
),
(
'Paraguay'
,
'Paraguay'
),
(
'Peru'
,
'Peru'
),
(
'Peru'
,
'Peru'
),
(
'Philippines'
,
'Philippines'
),
(
'Philippines'
,
'Philippines'
),
(
'Pitc
.airn'
,
'Pitc.
airn'
),
(
'Pitc
airn'
,
'Pitc
airn'
),
(
'Poland'
,
'Poland'
),
(
'Poland'
,
'Poland'
),
(
'Portugal'
,
'Portugal'
),
(
'Portugal'
,
'Portugal'
),
(
'Puerto Rico'
,
'Puerto Rico'
),
(
'Puerto Rico'
,
'Puerto Rico'
),
...
@@ -321,6 +320,7 @@ class CmeUserProfile(UserProfile):
...
@@ -321,6 +320,7 @@ class CmeUserProfile(UserProfile):
(
'Somalia'
,
'Somalia'
),
(
'Somalia'
,
'Somalia'
),
(
'South Africa'
,
'South Africa'
),
(
'South Africa'
,
'South Africa'
),
(
'South Georgia And The South Sandwich Islands'
,
'South Georgia And The South Sandwich Islands'
),
(
'South Georgia And The South Sandwich Islands'
,
'South Georgia And The South Sandwich Islands'
),
(
'South Sudan'
,
'South Sudan'
),
(
'Spain'
,
'Spain'
),
(
'Spain'
,
'Spain'
),
(
'Sri Lanka'
,
'Sri Lanka'
),
(
'Sri Lanka'
,
'Sri Lanka'
),
(
'Sudan'
,
'Sudan'
),
(
'Sudan'
,
'Sudan'
),
...
@@ -329,7 +329,7 @@ class CmeUserProfile(UserProfile):
...
@@ -329,7 +329,7 @@ class CmeUserProfile(UserProfile):
(
'Swaziland'
,
'Swaziland'
),
(
'Swaziland'
,
'Swaziland'
),
(
'Sweden'
,
'Sweden'
),
(
'Sweden'
,
'Sweden'
),
(
'Switzerland'
,
'Switzerland'
),
(
'Switzerland'
,
'Switzerland'
),
(
'Syrian A
lab Republic'
,
'Syrian Al
ab Republic'
),
(
'Syrian A
rab Republic'
,
'Syrian Ar
ab Republic'
),
(
'Taiwan'
,
'Taiwan'
),
(
'Taiwan'
,
'Taiwan'
),
(
'Tajikistan'
,
'Tajikistan'
),
(
'Tajikistan'
,
'Tajikistan'
),
(
'Tanzania, United Republic Of'
,
'Tanzania, United Republic Of'
),
(
'Tanzania, United Republic Of'
,
'Tanzania, United Republic Of'
),
...
@@ -347,7 +347,7 @@ class CmeUserProfile(UserProfile):
...
@@ -347,7 +347,7 @@ class CmeUserProfile(UserProfile):
(
'U.S. Minor Outlying Islands'
,
'U.S. Minor Outlying Islands'
),
(
'U.S. Minor Outlying Islands'
,
'U.S. Minor Outlying Islands'
),
(
'Uganda'
,
'Uganda'
),
(
'Uganda'
,
'Uganda'
),
(
'Ukraine'
,
'Ukraine'
),
(
'Ukraine'
,
'Ukraine'
),
(
'United A
lab Emirates'
,
'United Al
ab Emirates'
),
(
'United A
rab Emirates'
,
'United Ar
ab Emirates'
),
(
'United Kingdom'
,
'United Kingdom'
),
(
'United Kingdom'
,
'United Kingdom'
),
(
'Uruguay'
,
'Uruguay'
),
(
'Uruguay'
,
'Uruguay'
),
(
'Uzbekistan'
,
'Uzbekistan'
),
(
'Uzbekistan'
,
'Uzbekistan'
),
...
...
common/djangoapps/cme_registration/tests/registration_tests.py
View file @
4b2b734b
...
@@ -18,7 +18,7 @@ from django.contrib.auth.models import User
...
@@ -18,7 +18,7 @@ from django.contrib.auth.models import User
from
student.models
import
Registration
,
UserProfile
from
student.models
import
Registration
,
UserProfile
from
cme_registration.models
import
CmeUserProfile
from
cme_registration.models
import
CmeUserProfile
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
cme_registration.views
import
DENIED_COUNTRIES
,
validate_export_controls
TEST_MITX_FEATURES
=
settings
.
MITX_FEATURES
.
copy
()
TEST_MITX_FEATURES
=
settings
.
MITX_FEATURES
.
copy
()
TEST_MITX_FEATURES
[
'USE_CME_REGISTRATION'
]
=
True
TEST_MITX_FEATURES
[
'USE_CME_REGISTRATION'
]
=
True
...
@@ -132,7 +132,7 @@ class TestCmeRegistration(TestCase):
...
@@ -132,7 +132,7 @@ class TestCmeRegistration(TestCase):
url
=
reverse
(
'create_account'
)
url
=
reverse
(
'create_account'
)
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
self
.
assertContains
(
response
,
'
{"success": true}
'
)
self
.
assertContains
(
response
,
'
"success": true
'
)
@unittest.skipIf
(
settings
.
MITX_FEATURES
.
get
(
'DISABLE_CME_REGISTRATION_TESTS'
,
False
),
@unittest.skipIf
(
settings
.
MITX_FEATURES
.
get
(
'DISABLE_CME_REGISTRATION_TESTS'
,
False
),
dedent
(
"""Skipping Test because the url is not in CMS"""
))
dedent
(
"""Skipping Test because the url is not in CMS"""
))
...
@@ -344,7 +344,7 @@ class TestCmeRegistration(TestCase):
...
@@ -344,7 +344,7 @@ class TestCmeRegistration(TestCase):
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
#Check page displays success
#Check page displays success
self
.
assertContains
(
response
,
'
{"success": true}
'
)
self
.
assertContains
(
response
,
'
"success": true
'
)
#Check user was created
#Check user was created
user
=
User
.
objects
.
filter
(
email
=
'test@email.com'
)
user
=
User
.
objects
.
filter
(
email
=
'test@email.com'
)
...
@@ -402,7 +402,7 @@ class TestCmeRegistration(TestCase):
...
@@ -402,7 +402,7 @@ class TestCmeRegistration(TestCase):
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
#Check page displays success
#Check page displays success
self
.
assertContains
(
response
,
'
{"success": true}
'
)
self
.
assertContains
(
response
,
'
"success": true
'
)
#Check user was created
#Check user was created
user
=
User
.
objects
.
filter
(
email
=
'test@email.com'
)
user
=
User
.
objects
.
filter
(
email
=
'test@email.com'
)
...
@@ -514,7 +514,7 @@ class TestCmeRegistration(TestCase):
...
@@ -514,7 +514,7 @@ class TestCmeRegistration(TestCase):
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
response
=
self
.
client
.
post
(
url
,
self
.
post_vars
)
#Check page displays success
#Check page displays success
self
.
assertContains
(
response
,
'
{"success": true}
'
)
self
.
assertContains
(
response
,
'
"success": true
'
)
@patch
(
'cme_registration.models.CmeUserProfile.save'
,
Mock
(
side_effect
=
Exception
()))
@patch
(
'cme_registration.models.CmeUserProfile.save'
,
Mock
(
side_effect
=
Exception
()))
@unittest.skipIf
(
settings
.
MITX_FEATURES
.
get
(
'DISABLE_CME_REGISTRATION_TESTS'
,
False
),
@unittest.skipIf
(
settings
.
MITX_FEATURES
.
get
(
'DISABLE_CME_REGISTRATION_TESTS'
,
False
),
...
@@ -543,3 +543,14 @@ class TestCmeRegistration(TestCase):
...
@@ -543,3 +543,14 @@ class TestCmeRegistration(TestCase):
self
.
assertRaises
(
Exception
)
self
.
assertRaises
(
Exception
)
self
.
assertContains
(
response
,
'Could not send activation e-mail.'
)
self
.
assertContains
(
response
,
'Could not send activation e-mail.'
)
def
test_export_controls
(
self
):
"""
Test export controls verification
"""
for
country
in
DENIED_COUNTRIES
:
retv
=
validate_export_controls
({
'country'
:
country
})
self
.
assertFalse
(
retv
[
'success'
])
self
.
assertEqual
(
retv
[
'field'
],
'country'
)
self
.
assertIsNone
(
validate_export_controls
({
'country'
:
'United States'
}))
common/djangoapps/cme_registration/views.py
View file @
4b2b734b
...
@@ -4,7 +4,7 @@ CME Registration methods
...
@@ -4,7 +4,7 @@ CME Registration methods
import
json
import
json
import
logging
import
logging
from
statsd
import
statsd
from
dogapi
import
dog_stats_api
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -18,6 +18,7 @@ from django.db import IntegrityError
...
@@ -18,6 +18,7 @@ from django.db import IntegrityError
from
django.core.mail
import
send_mail
from
django.core.mail
import
send_mail
from
student.models
import
Registration
from
student.models
import
Registration
import
student
from
cme_registration.models
import
CmeUserProfile
from
cme_registration.models
import
CmeUserProfile
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
...
@@ -100,6 +101,11 @@ def cme_create_account(request, post_override=None):
...
@@ -100,6 +101,11 @@ def cme_create_account(request, post_override=None):
json_string
[
'field'
]
=
'username'
json_string
[
'field'
]
=
'username'
return
HttpResponse
(
json
.
dumps
(
json_string
))
return
HttpResponse
(
json
.
dumps
(
json_string
))
#Validate Export controls
error
=
validate_export_controls
(
post_vars
)
if
error
is
not
None
:
return
HttpResponse
(
json
.
dumps
(
error
))
# Ok, looks like everything is legit. Create the account.
# Ok, looks like everything is legit. Create the account.
ret
=
_do_cme_create_account
(
post_vars
)
ret
=
_do_cme_create_account
(
post_vars
)
if
isinstance
(
ret
,
HttpResponse
):
# if there was an error then return that
if
isinstance
(
ret
,
HttpResponse
):
# if there was an error then return that
...
@@ -137,12 +143,14 @@ def cme_create_account(request, post_override=None):
...
@@ -137,12 +143,14 @@ def cme_create_account(request, post_override=None):
login
(
request
,
login_user
)
login
(
request
,
login_user
)
request
.
session
.
set_expiry
(
0
)
request
.
session
.
set_expiry
(
0
)
statsd
.
increment
(
"common.student.account_created"
)
redirect_url
=
student
.
views
.
try_change_enrollment
(
request
)
dog_stats_api
.
increment
(
"common.student.successful_login"
)
json_string
=
{
'success'
:
True
,
'redirect_url'
:
redirect_url
}
json_string
=
{
'success'
:
True
}
response
=
HttpResponse
(
json
.
dumps
(
json_string
))
HttpResponse
(
json
.
dumps
(
json_string
),
mimetype
=
"application/json"
)
response
=
HttpResponse
(
json
.
dumps
({
'success'
:
True
}))
return
response
return
response
...
@@ -335,6 +343,28 @@ def validate_required_radios(post_vars):
...
@@ -335,6 +343,28 @@ def validate_required_radios(post_vars):
return
error
return
error
def
validate_export_controls
(
post_vars
):
"""
Checks that we are US export control compliant.
In keeping with the style of the rest of the app, returns failure dict if failed, else None
"""
country
=
post_vars
.
get
(
'country'
,
''
)
if
country
in
DENIED_COUNTRIES
:
return
{
'success'
:
False
,
'field'
:
'country'
,
'value'
:
'We are unable to register you at this present time.'
# obfuscated message
}
DENIED_COUNTRIES
=
[
'Sudan'
,
'Korea, Democratic People
\'
s Republic Of'
,
'Iran, Islamic Republic Of'
,
'Cuba'
,
'Syrian Arab Republic'
,
]
#Construct dicts for specialty and sub-specialty dropdowns
#Construct dicts for specialty and sub-specialty dropdowns
SPECIALTY_CHOICES
=
{}
SPECIALTY_CHOICES
=
{}
SUB_SPECIALTY_CHOICES
=
{}
SUB_SPECIALTY_CHOICES
=
{}
...
...
lms/templates/cme_register.html
View file @
4b2b734b
...
@@ -87,7 +87,12 @@
...
@@ -87,7 +87,12 @@
$
(
'#register-form'
).
on
(
'ajax:success'
,
function
(
event
,
json
,
xhr
)
{
$
(
'#register-form'
).
on
(
'ajax:success'
,
function
(
event
,
json
,
xhr
)
{
if
(
json
.
success
)
{
if
(
json
.
success
)
{
$
(
'.message.submission-error'
).
removeClass
(
'is-shown'
);
$
(
'.message.submission-error'
).
removeClass
(
'is-shown'
);
location
.
href
=
"${reverse('dashboard')}"
;
if
(
json
.
redirect_url
){
location
.
href
=
json
.
redirect_url
;
}
else
{
location
.
href
=
"${reverse('dashboard')}"
;
}
}
else
{
}
else
{
$
(
'.status.message.submission-error'
).
addClass
(
'is-shown'
).
focus
();
$
(
'.status.message.submission-error'
).
addClass
(
'is-shown'
).
focus
();
$
(
'.status.message.submission-error .message-copy'
).
html
(
json
.
value
).
stop
().
css
(
"display"
,
"block"
);
$
(
'.status.message.submission-error .message-copy'
).
html
(
json
.
value
).
stop
().
css
(
"display"
,
"block"
);
...
@@ -497,11 +502,8 @@
...
@@ -497,11 +502,8 @@
</div>
</div>
</li>
</li>
<div
class=
"field select checkbox"
id=
"mailing_list"
>
<input
id=
"mailing_list"
type=
"hidden"
name=
"mailing_list"
value=
"true"
/>
<input
id=
"mailing_list"
type=
"checkbox"
name=
"mailing_list"
value=
"true"
checked
/>
<label
for=
"mailing_list"
>
Yes, include me on the mailing list for future educational activities
</label>
</div>
</ol>
</ol>
</fieldset>
</fieldset>
...
...
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