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
08ed1c54
Commit
08ed1c54
authored
Mar 10, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2832 from edx/gprice/create-account-lang-pref
Save language preference on account creation
parents
a10d8d41
fa29a35a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletions
+47
-1
common/djangoapps/student/tests/test_create_account.py
+43
-0
common/djangoapps/student/views.py
+4
-1
No files found.
common/djangoapps/student/tests/test_create_account.py
0 → 100644
View file @
08ed1c54
"Tests for account creation"
import
ddt
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
import
mock
from
user_api.models
import
UserPreference
from
lang_pref
import
LANGUAGE_KEY
@ddt.ddt
class
TestCreateAccount
(
TestCase
):
"Tests for account creation"
def
setUp
(
self
):
self
.
username
=
"test_user"
self
.
url
=
reverse
(
"create_account"
)
self
.
params
=
{
"username"
:
self
.
username
,
"email"
:
"test@example.org"
,
"password"
:
"testpass"
,
"name"
:
"Test User"
,
"honor_code"
:
"true"
,
"terms_of_service"
:
"true"
,
}
@ddt.data
(
"en"
,
"eo"
)
def
test_default_lang_pref_saved
(
self
,
lang
):
with
mock
.
patch
(
"django.conf.settings.LANGUAGE_CODE"
,
lang
):
response
=
self
.
client
.
post
(
self
.
url
,
self
.
params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
user
=
User
.
objects
.
get
(
username
=
self
.
username
)
self
.
assertEqual
(
UserPreference
.
get_preference
(
user
,
LANGUAGE_KEY
),
lang
)
@ddt.data
(
"en"
,
"eo"
)
def
test_header_lang_pref_saved
(
self
,
lang
):
response
=
self
.
client
.
post
(
self
.
url
,
self
.
params
,
HTTP_ACCEPT_LANGUAGE
=
lang
)
self
.
assertEqual
(
response
.
status_code
,
200
)
user
=
User
.
objects
.
get
(
username
=
self
.
username
)
self
.
assertEqual
(
UserPreference
.
get_preference
(
user
,
LANGUAGE_KEY
),
lang
)
common/djangoapps/student/views.py
View file @
08ed1c54
...
@@ -27,7 +27,7 @@ from django.http import (HttpResponse, HttpResponseBadRequest, HttpResponseForbi
...
@@ -27,7 +27,7 @@ from django.http import (HttpResponse, HttpResponseBadRequest, HttpResponseForbi
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
django.utils.http
import
cookie_date
,
base36_to_int
from
django.utils.http
import
cookie_date
,
base36_to_int
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
,
get_language
from
django.views.decorators.http
import
require_POST
,
require_GET
from
django.views.decorators.http
import
require_POST
,
require_GET
from
ratelimitbackend.exceptions
import
RateLimitException
from
ratelimitbackend.exceptions
import
RateLimitException
...
@@ -1003,6 +1003,9 @@ def _do_create_account(post_vars):
...
@@ -1003,6 +1003,9 @@ def _do_create_account(post_vars):
profile
.
save
()
profile
.
save
()
except
Exception
:
except
Exception
:
log
.
exception
(
"UserProfile creation failed for user {id}."
.
format
(
id
=
user
.
id
))
log
.
exception
(
"UserProfile creation failed for user {id}."
.
format
(
id
=
user
.
id
))
UserPreference
.
set_preference
(
user
,
LANGUAGE_KEY
,
get_language
())
return
(
user
,
profile
,
registration
)
return
(
user
,
profile
,
registration
)
...
...
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