diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 0542d4cf03..4ab152adb1 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -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: diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 4013af2e89..d24eabd780 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -1,12 +1,11 @@ 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): diff --git a/cms/templates/emails/activation_email.txt b/cms/templates/emails/activation_email.txt index eca5effdd6..209ff98335 100644 --- a/cms/templates/emails/activation_email.txt +++ b/cms/templates/emails/activation_email.txt @@ -1,12 +1,11 @@ -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 diff --git a/cms/templates/emails/activation_email_subject.txt b/cms/templates/emails/activation_email_subject.txt index c25c006a81..495e0b5fad 100644 --- a/cms/templates/emails/activation_email_subject.txt +++ b/cms/templates/emails/activation_email_subject.txt @@ -1 +1 @@ -Your account for edX's on-line ${course_title} course +Your account for edX diff --git a/cms/templates/registration/activation_complete.html b/cms/templates/registration/activation_complete.html new file mode 100644 index 0000000000..30e731e8cc --- /dev/null +++ b/cms/templates/registration/activation_complete.html @@ -0,0 +1,30 @@ +<%! from django.core.urlresolvers import reverse %> +<%inherit file="../base.html" /> + +<%namespace name='static' file='../static_content.html'/> + +
+ +
+ %if not already_active: +

Activation Complete!

+ %else: +

Account already active!

+ %endif +
+ +

+ %if not already_active: + Thanks for activating your account. + %else: + This account has already been activated. + %endif + + %if user_logged_in: + Visit your dashboard to see your courses. + %else: + You can now login. + %endif +

+
+
diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 82fd521148..0f6ffd6fdd 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -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: diff --git a/common/lib/xmodule/tests/__init__.py b/common/lib/xmodule/tests/__init__.py index 5483015a82..ee18fcb98f 100644 --- a/common/lib/xmodule/tests/__init__.py +++ b/common/lib/xmodule/tests/__init__.py @@ -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