Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
47e16405
Commit
47e16405
authored
Aug 23, 2012
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
7cdda13f
2542080e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
weblate/accounts/models.py
weblate/accounts/models.py
+19
-17
No files found.
weblate/accounts/models.py
View file @
47e16405
...
...
@@ -35,6 +35,7 @@ from django.utils import translation
from
django.template.loader
import
render_to_string
,
get_template_from_string
from
django.template.context
import
Context
from
django.core.mail
import
EmailMessage
from
django.db
import
transaction
from
south.signals
import
post_migrate
...
...
@@ -226,31 +227,32 @@ def set_lang(sender, **kwargs):
lang_code
=
user
.
get_profile
().
language
request
.
session
[
'django_language'
]
=
lang_code
@
receiver
(
post_save
,
sender
=
User
)
def
create_profile_callback
(
sender
,
**
kwargs
):
'''
Automatically create profile when creating new user.
'''
if
kwargs
[
'created'
]:
# Create profile
# Need to handle this in separate transaction as it might fail
# in case we're run from syncdb. Transaction handling is needed
# for PostgreSQL as otherwise whole transaction will be in bad
# state ("current transaction is aborted, queries ignored until
# end of transaction block")
transaction
.
commit
()
try
:
profile
,
newprofile
=
Profile
.
objects
.
get_or_create
(
user
=
kwargs
[
'instance'
])
if
newprofile
:
profile
.
save
with
transaction
.
commit_on_success
():
# Create profile
profile
,
newprofile
=
Profile
.
objects
.
get_or_create
(
user
=
kwargs
[
'instance'
])
with
transaction
.
commit_on_success
():
# Add user to Users group if it exists
try
:
group
=
Group
.
objects
.
get
(
name
=
'Users'
)
kwargs
[
'instance'
].
groups
.
add
(
group
)
except
Group
.
DoesNotExist
:
pass
except
DatabaseError
:
# Database not set up (we're being run from initial syncdb)
return
# Add user to Users group if it exists
try
:
group
=
Group
.
objects
.
get
(
name
=
'Users'
)
kwargs
[
'instance'
].
groups
.
add
(
group
)
except
Group
.
DoesNotExist
:
pass
except
DatabaseError
:
# Database not set up (we're being run from initial syncdb)
return
post_save
.
connect
(
create_profile_callback
,
sender
=
User
)
def
create_groups
(
update
,
move
):
...
...
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