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
9c12d63a
Commit
9c12d63a
authored
Nov 23, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly copy suggestions on component move
Fixes #896 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
41a3f7e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
1 deletion
+61
-1
weblate/trans/models/subproject.py
weblate/trans/models/subproject.py
+7
-0
weblate/trans/models/unitdata.py
weblate/trans/models/unitdata.py
+17
-0
weblate/trans/tests/test_models.py
weblate/trans/tests/test_models.py
+37
-1
No files found.
weblate/trans/models/subproject.py
View file @
9c12d63a
...
...
@@ -1359,6 +1359,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
# Detect if VCS config has changed (so that we have to pull the repo)
changed_git
=
True
changed_setup
=
False
changed_project
=
False
if
self
.
id
:
old
=
SubProject
.
objects
.
get
(
pk
=
self
.
id
)
changed_git
=
(
...
...
@@ -1371,6 +1372,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
(
old
.
edit_template
!=
self
.
edit_template
)
or
(
old
.
template
!=
self
.
template
)
)
changed_project
=
(
old
.
project_id
!=
self
.
project_id
)
# Detect slug changes and rename git repo
self
.
check_rename
(
old
)
...
...
@@ -1396,6 +1398,11 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
elif
changed_git
:
self
.
create_translations
()
# Copy suggestions to new project
if
changed_project
:
print
'CHANGED!'
old
.
project
.
suggestion_set
.
copy
(
self
.
project
)
def
_get_percents
(
self
):
'''
Returns percentages of translation status.
...
...
weblate/trans/models/unitdata.py
View file @
9c12d63a
...
...
@@ -76,6 +76,23 @@ class SuggestionManager(models.Manager):
user
.
profile
.
suggested
+=
1
user
.
profile
.
save
()
def
copy
(
self
,
project
):
"""Copies suggestions to new project
This is used on moving component to other project and ensures nothing
is lost. We don't actually look where the suggestion belongs as it
would make the operation really expensive and it should be done in the
cleanup cron job.
"""
for
suggestion
in
self
.
all
():
Suggestion
.
objects
.
create
(
project
=
project
,
target
=
suggestion
.
target
,
contentsum
=
suggestion
.
contentsum
,
user
=
suggestion
.
user
,
language
=
suggestion
.
language
,
)
class
Suggestion
(
models
.
Model
):
contentsum
=
models
.
CharField
(
max_length
=
40
,
db_index
=
True
)
...
...
weblate/trans/tests/test_models.py
View file @
9c12d63a
...
...
@@ -30,7 +30,7 @@ from django.core.exceptions import ValidationError
import
shutil
import
os
from
weblate.trans.models
import
(
Project
,
SubProject
,
Source
,
Unit
,
WhiteboardMessage
,
Check
,
Project
,
SubProject
,
Source
,
Unit
,
WhiteboardMessage
,
Check
,
Suggestion
,
get_related_units
,
)
from
weblate
import
appsettings
...
...
@@ -778,6 +778,42 @@ class SubProjectTest(RepoTestCase):
'en'
)
def
test_change_project
(
self
):
subproject
=
self
.
create_subproject
()
# Create and verify suggestion
Suggestion
.
objects
.
create
(
project
=
subproject
.
project
,
contentsum
=
'x'
,
language
=
subproject
.
translation_set
.
all
()[
0
].
language
,
)
self
.
assertEqual
(
subproject
.
project
.
suggestion_set
.
count
(),
1
)
# Check current path exists
old_path
=
subproject
.
get_path
()
self
.
assertTrue
(
os
.
path
.
exists
(
old_path
))
# Crete target project
second
=
Project
.
objects
.
create
(
name
=
'Test2'
,
slug
=
'test2'
,
web
=
'https://weblate.org/'
)
# Move component
subproject
.
project
=
second
subproject
.
save
()
# Check new path exists
new_path
=
subproject
.
get_path
()
self
.
assertTrue
(
os
.
path
.
exists
(
new_path
))
# Check paths differ
self
.
assertNotEqual
(
old_path
,
new_path
)
# Check suggestion has been copied
self
.
assertEqual
(
subproject
.
project
.
suggestion_set
.
count
(),
1
)
class
TranslationTest
(
RepoTestCase
):
"""
...
...
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