User info cookie

* Add a new cookie for user information
* Make marketing cookie names configurable.
* Handle URL reversal when URLs don't exist (in Studio)
* Move cookie code from student/helpers.py into its own module.
This commit is contained in:
Will Daly
2015-06-23 12:55:35 -07:00
parent 545f521933
commit 5e86a64729
14 changed files with 222 additions and 66 deletions

View File

@@ -1264,7 +1264,8 @@ class RegistrationViewTest(ApiTestCase):
"honor_code": "true",
})
self.assertHttpOK(response)
self.assertIn(settings.EDXMKTG_COOKIE_NAME, self.client.cookies)
self.assertIn(settings.EDXMKTG_LOGGED_IN_COOKIE_NAME, self.client.cookies)
self.assertIn(settings.EDXMKTG_USER_INFO_COOKIE_NAME, self.client.cookies)
user = User.objects.get(username=self.USERNAME)
account_settings = get_account_settings(user)

View File

@@ -25,7 +25,7 @@ import third_party_auth
from django_comment_common.models import Role
from edxmako.shortcuts import marketing_link
from student.views import create_account_with_params
from student.helpers import set_logged_in_cookie
from student.cookies import set_logged_in_cookies
from openedx.core.lib.api.authentication import SessionAuthenticationAllowInactiveUser
from util.json_request import JsonResponse
from .preferences.api import update_email_opt_in
@@ -295,7 +295,7 @@ class RegistrationView(APIView):
data["terms_of_service"] = data["honor_code"]
try:
create_account_with_params(request, data)
user = create_account_with_params(request, data)
except ValidationError as err:
# Should only get non-field errors from this function
assert NON_FIELD_ERRORS not in err.message_dict
@@ -307,7 +307,7 @@ class RegistrationView(APIView):
return JsonResponse(errors, status=400)
response = JsonResponse({"success": True})
set_logged_in_cookie(request, response)
set_logged_in_cookies(request, response, user)
return response
def _add_email_field(self, form_desc, required=True):