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
4f23a5ab
Commit
4f23a5ab
authored
Aug 15, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify fetching secondary translations
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
e693dc37
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
21 deletions
+22
-21
weblate/accounts/models.py
weblate/accounts/models.py
+1
-19
weblate/trans/models/unit.py
weblate/trans/models/unit.py
+20
-1
weblate/trans/views/edit.py
weblate/trans/views/edit.py
+1
-1
No files found.
weblate/accounts/models.py
View file @
4f23a5ab
...
...
@@ -38,9 +38,8 @@ from social.apps.django_app.default.models import UserSocialAuth
from
weblate.lang.models
import
Language
from
weblate.trans.models.project
import
Project
from
weblate.trans.models.unit
import
Unit
from
weblate.trans.models.changes
import
Change
from
weblate.trans.util
import
get_site_url
,
get_distinct_translations
from
weblate.trans.util
import
get_site_url
from
weblate.accounts.avatar
import
get_user_display
import
weblate
from
weblate.appsettings
import
ANONYMOUS_USER_NAME
,
SITE_TITLE
...
...
@@ -553,23 +552,6 @@ class Profile(models.Model):
'''
return
self
.
user
.
first_name
def
get_secondary_units
(
self
,
unit
):
'''
Returns list of secondary units.
'''
secondary_langs
=
self
.
secondary_languages
.
exclude
(
id
=
unit
.
translation
.
language
.
id
)
project
=
unit
.
translation
.
subproject
.
project
return
get_distinct_translations
(
Unit
.
objects
.
filter
(
checksum
=
unit
.
checksum
,
translated
=
True
,
translation__subproject__project
=
project
,
translation__language__in
=
secondary_langs
,
)
)
@
receiver
(
user_logged_in
)
def
set_lang
(
sender
,
**
kwargs
):
...
...
weblate/trans/models/unit.py
View file @
4f23a5ab
...
...
@@ -33,7 +33,9 @@ from weblate.trans.models.changes import Change
from
weblate.trans.search
import
update_index_unit
,
fulltext_search
,
more_like
from
weblate.trans.filelock
import
FileLockException
from
weblate.trans.util
import
is_plural
,
split_plural
,
join_plural
from
weblate.trans.util
import
(
is_plural
,
split_plural
,
join_plural
,
get_distinct_translations
)
import
weblate
FLAG_TEMPLATE
=
'<span title="%s" class="flag-icon ui-icon ui-icon-%s"></span>'
...
...
@@ -1048,3 +1050,20 @@ class Unit(models.Model):
subproject
=
self
.
translation
.
subproject
)
return
self
.
_source_info
def
get_secondary_units
(
self
,
user
):
'''
Returns list of secondary units.
'''
secondary_langs
=
user
.
profile
.
secondary_languages
.
exclude
(
id
=
self
.
translation
.
language
.
id
)
project
=
self
.
translation
.
subproject
.
project
return
get_distinct_translations
(
Unit
.
objects
.
filter
(
checksum
=
self
.
checksum
,
translated
=
True
,
translation__subproject__project
=
project
,
translation__language__in
=
secondary_langs
,
)
)
weblate/trans/views/edit.py
View file @
4f23a5ab
...
...
@@ -578,7 +578,7 @@ def translate(request, project, subproject, lang):
# Show secondary languages for logged in users
if
request
.
user
.
is_authenticated
():
secondary
=
request
.
user
.
profile
.
get_secondary_units
(
unit
)
secondary
=
unit
.
get_secondary_units
(
request
.
user
)
else
:
secondary
=
None
...
...
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