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
4db04e69
Commit
4db04e69
authored
Sep 07, 2015
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
7167b8f0
c3e78193
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
13 deletions
+50
-13
docs/changes.rst
docs/changes.rst
+1
-0
weblate/accounts/models.py
weblate/accounts/models.py
+4
-0
weblate/accounts/tests.py
weblate/accounts/tests.py
+23
-13
weblate/trans/models/__init__.py
weblate/trans/models/__init__.py
+21
-0
weblate/trans/signals.py
weblate/trans/signals.py
+1
-0
No files found.
docs/changes.rst
View file @
4db04e69
...
...
@@ -31,6 +31,7 @@ Released on ? 2015.
* Added support for translating and importing CSV files.
* Rewritten handling of static files.
* Direct login/registration links to third party service if that's the only one.
* Commit pending changes on account removal.
weblate 2.3
-----------
...
...
weblate/accounts/models.py
View file @
4db04e69
...
...
@@ -41,6 +41,7 @@ from weblate.lang.models import Language
from
weblate.trans.util
import
get_site_url
,
get_site_domain
from
weblate.accounts.avatar
import
get_user_display
from
weblate.trans.util
import
report_error
from
weblate.trans.signals
import
user_pre_delete
import
weblate
from
weblate.appsettings
import
ANONYMOUS_USER_NAME
,
SITE_TITLE
...
...
@@ -827,6 +828,9 @@ def remove_user(user):
'''
Removes user account.
'''
# Send signal (to commit any pending changes)
user_pre_delete
.
send
(
instance
=
user
,
sender
=
user
.
__class__
)
# Change username
user
.
username
=
'deleted-{0}'
.
format
(
user
.
pk
)
while
User
.
objects
.
filter
(
username
=
user
.
username
).
exists
():
...
...
weblate/accounts/tests.py
View file @
4db04e69
...
...
@@ -454,19 +454,6 @@ class ViewTest(TestCase):
response
=
self
.
client
.
get
(
reverse
(
'logout'
))
self
.
assertRedirects
(
response
,
reverse
(
'home'
))
def
test_removal
(
self
):
# Create user
self
.
get_user
()
# Login
self
.
client
.
login
(
username
=
'testuser'
,
password
=
'testpassword'
)
response
=
self
.
client
.
post
(
reverse
(
'remove'
)
)
self
.
assertRedirects
(
response
,
reverse
(
'home'
))
self
.
assertFalse
(
User
.
objects
.
filter
(
username
=
'testuser'
).
exists
()
)
def
test_password
(
self
):
# Create user
self
.
get_user
()
...
...
@@ -860,3 +847,26 @@ class AvatarTest(ViewTestCase):
)
)
self
.
assertPNG
(
response
)
class
RemoveAcccountTest
(
ViewTestCase
):
def
test_removal
(
self
):
response
=
self
.
client
.
post
(
reverse
(
'remove'
)
)
self
.
assertRedirects
(
response
,
reverse
(
'home'
))
self
.
assertFalse
(
User
.
objects
.
filter
(
username
=
'testuser'
).
exists
()
)
def
test_removal_change
(
self
):
response
=
self
.
edit_unit
(
'Hello, world!
\
n
'
,
'Nazdar svete!
\
n
'
)
# We should have some change to commit
self
.
assertTrue
(
self
.
subproject
.
repo_needs_commit
())
# Remove account
self
.
test_removal
()
# Changes should be committed
self
.
assertFalse
(
self
.
subproject
.
repo_needs_commit
())
weblate/trans/models/__init__.py
View file @
4db04e69
...
...
@@ -39,6 +39,7 @@ from weblate.trans.models.advertisement import Advertisement
from
weblate.trans.models.whiteboard
import
WhiteboardMessage
from
weblate.trans.signals
import
(
vcs_post_push
,
vcs_post_update
,
vcs_pre_commit
,
vcs_post_commit
,
user_pre_delete
,
)
from
weblate.trans.scripts
import
(
run_post_push_script
,
run_post_update_script
,
run_pre_commit_script
,
...
...
@@ -224,3 +225,23 @@ def pre_commit(sender, translation, **kwargs):
@
receiver
(
vcs_post_commit
)
def
post_commit
(
sender
,
translation
,
**
kwargs
):
run_post_commit_script
(
translation
.
subproject
,
translation
.
get_filename
())
@
receiver
(
user_pre_delete
)
def
user_commit_pending
(
sender
,
instance
,
**
kwargs
):
"""Commit pending changes for user on account removal."""
# All user changes
all_changes
=
Change
.
objects
.
last_changes
(
instance
).
filter
(
user
=
instance
,
)
# Filter where project is active
user_translation_ids
=
all_changes
.
values_list
(
'translation'
,
flat
=
True
).
distinct
()
# Commit changes where user is last author
for
translation
in
Translation
.
objects
.
filter
(
pk__in
=
user_translation_ids
):
last_author
=
translation
.
change_set
.
content
()[
0
].
author
if
last_author
==
instance
:
translation
.
commit_pending
(
None
)
weblate/trans/signals.py
View file @
4db04e69
...
...
@@ -25,3 +25,4 @@ vcs_post_push = Signal(providing_args=['subproject'])
vcs_post_update
=
Signal
(
providing_args
=
[
'subproject'
])
vcs_pre_commit
=
Signal
(
providing_args
=
[
'translation'
])
vcs_post_commit
=
Signal
(
providing_args
=
[
'translation'
])
user_pre_delete
=
Signal
()
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