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
b9c6e366
Commit
b9c6e366
authored
Jul 23, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #266 from MITx/cpennington/fix_tests
Cpennington/fix tests
parents
b7a389df
7a34a8c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
21 deletions
+62
-21
cms/djangoapps/contentstore/tests/tests.py
+7
-2
cms/djangoapps/contentstore/views.py
+13
-7
cms/templates/emails/activation_email.txt
+4
-5
cms/templates/emails/activation_email_subject.txt
+1
-1
cms/templates/registration/activation_complete.html
+30
-0
common/djangoapps/student/views.py
+5
-5
common/lib/xmodule/tests/__init__.py
+2
-1
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
b9c6e366
...
...
@@ -30,6 +30,7 @@ class AuthTestCase(TestCase):
self
.
email
=
'a@b.com'
self
.
pw
=
'xyz'
self
.
username
=
'testuser'
self
.
client
=
Client
()
def
check_page_get
(
self
,
url
,
expected
):
resp
=
self
.
client
.
get
(
url
)
...
...
@@ -63,7 +64,8 @@ class AuthTestCase(TestCase):
'language'
:
'Franglish'
,
'name'
:
'Fred Weasley'
,
'terms_of_service'
:
'true'
,
'honor_code'
:
'true'
})
'honor_code'
:
'true'
,
})
return
resp
def
create_account
(
self
,
username
,
email
,
pw
):
...
...
@@ -121,7 +123,7 @@ class AuthTestCase(TestCase):
resp
=
self
.
_login
(
self
.
email
,
self
.
pw
)
data
=
parse_json
(
resp
)
self
.
assertFalse
(
data
[
'success'
])
self
.
activate_user
(
self
.
email
)
# Now login should work
...
...
@@ -144,6 +146,9 @@ class AuthTestCase(TestCase):
# need an activated user
self
.
test_create_account
()
# Create a new session
self
.
client
=
Client
()
# Not logged in. Should redirect to login.
print
'Not logged in'
for
page
in
auth_pages
:
...
...
cms/djangoapps/contentstore/views.py
View file @
b9c6e366
from
util.json_request
import
expect_json
import
json
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
Http404
from
django.contrib.auth.decorators
import
login_required
from
django.core.context_processors
import
csrf
from
django_future.csrf
import
ensure_csrf_cookie
from
django.core.urlresolvers
import
reverse
from
fs.osfs
import
OSFS
from
xmodule.modulestore
import
Location
from
github_sync
import
export_to_github
...
...
@@ -14,6 +13,7 @@ from github_sync import export_to_github
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore.django
import
modulestore
# ==== Public views ==================================================
@ensure_csrf_cookie
...
...
@@ -22,7 +22,8 @@ def signup(request):
Display the signup form.
"""
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
@ensure_csrf_cookie
def
login_page
(
request
):
...
...
@@ -30,8 +31,9 @@ def login_page(request):
Display the login form.
"""
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
return
render_to_response
(
'login.html'
,
{
'csrf'
:
csrf_token
})
return
render_to_response
(
'login.html'
,
{
'csrf'
:
csrf_token
})
# ==== Views for any logged-in user ==================================
@login_required
...
...
@@ -47,6 +49,7 @@ def index(request):
for
course
in
courses
]
})
# ==== Views with per-item permissions================================
def
has_access
(
user
,
location
):
...
...
@@ -54,18 +57,20 @@ def has_access(user, location):
# TODO (vshnayder): actually check perms
return
user
.
is_active
and
user
.
is_authenticated
@login_required
@ensure_csrf_cookie
def
course_index
(
request
,
org
,
course
,
name
):
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
if
not
has_access
(
request
.
user
,
location
):
raise
Http404
# TODO (vshnayder): better error
# TODO (cpennington): These need to be read in from the active user
course
=
modulestore
()
.
get_item
(
location
)
weeks
=
course
.
get_children
()
return
render_to_response
(
'course_index.html'
,
{
'weeks'
:
weeks
})
@login_required
def
edit_item
(
request
):
# TODO (vshnayder): change name from id to location in coffee+html as well.
...
...
@@ -73,7 +78,7 @@ def edit_item(request):
print
item_location
,
request
.
GET
if
not
has_access
(
request
.
user
,
item_location
):
raise
Http404
# TODO (vshnayder): better error
item
=
modulestore
()
.
get_item
(
item_location
)
return
render_to_response
(
'unit.html'
,
{
'contents'
:
item
.
get_html
(),
...
...
@@ -98,6 +103,7 @@ def user_author_string(user):
last
=
l
,
email
=
user
.
email
)
@login_required
@expect_json
def
save_item
(
request
):
...
...
cms/templates/emails/activation_email.txt
View file @
b9c6e366
Someone, hopefully you, signed up for an account for edX's on-line
offering of "${ course_title}" using this email address. If it was
you, and you'd like to activate and use your account, copy and paste
this address into your web browser's address bar:
Thank you for signing up for edX! To activate your account,
please copy and paste this address into your web browser's
address bar:
% if is_secure:
https://${ site }/activate/${ key }
% else:
http://
edx4edx.mitx.mit.edu
/activate/${ key }
http://
${ site }
/activate/${ key }
% endif
If you didn't request this, you don't need to do anything; you won't
...
...
cms/templates/emails/activation_email_subject.txt
View file @
b9c6e366
Your account for edX
's on-line ${course_title} course
Your account for edX
cms/templates/registration/activation_complete.html
0 → 100644
View file @
b9c6e366
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%
inherit
file=
"../base.html"
/>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<section
class=
"container activation"
>
<section
class=
"message"
>
%if not already_active:
<h1
class=
"valid"
>
Activation Complete!
</h1>
%else:
<h1>
Account already active!
</h1>
%endif
<hr
class=
"horizontal-divider"
>
<p>
%if not already_active:
Thanks for activating your account.
%else:
This account has already been activated.
%endif
%if user_logged_in:
Visit your
<a
href=
"${reverse('dashboard')}"
>
dashboard
</a>
to see your courses.
%else:
You can now
<a
href=
"#login-modal"
rel=
"leanModal"
>
login
</a>
.
%endif
</p>
</section>
</section>
common/djangoapps/student/views.py
View file @
b9c6e366
...
...
@@ -307,14 +307,14 @@ def create_account(request, post_override=None):
up
=
UserProfile
(
user
=
u
)
up
.
name
=
post_vars
[
'name'
]
up
.
level_of_education
=
post_vars
[
'level_of_education'
]
up
.
gender
=
post_vars
[
'gender'
]
up
.
mailing_address
=
post_vars
[
'mailing_address'
]
up
.
goals
=
post_vars
[
'goals'
]
up
.
level_of_education
=
post_vars
.
get
(
'level_of_education'
)
up
.
gender
=
post_vars
.
get
(
'gender'
)
up
.
mailing_address
=
post_vars
.
get
(
'mailing_address'
)
up
.
goals
=
post_vars
.
get
(
'goals'
)
try
:
up
.
year_of_birth
=
int
(
post_vars
[
'year_of_birth'
])
except
ValueError
:
except
(
ValueError
,
KeyError
)
:
up
.
year_of_birth
=
None
# If they give us garbage, just ignore it instead
# of asking them to put an integer.
try
:
...
...
common/lib/xmodule/tests/__init__.py
View file @
b9c6e366
...
...
@@ -7,6 +7,7 @@
import
unittest
import
os
import
fs
import
numpy
...
...
@@ -27,7 +28,7 @@ class I4xSystem(object):
def
__init__
(
self
):
self
.
ajax_url
=
'/'
self
.
track_function
=
lambda
x
:
None
self
.
filestore
=
None
self
.
filestore
=
fs
.
osfs
.
OSFS
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)))
self
.
render_function
=
lambda
x
:
{}
# Probably incorrect
self
.
module_from_xml
=
lambda
x
:
None
# May need a real impl...
self
.
exception404
=
Exception
...
...
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