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
8ba1a18a
Commit
8ba1a18a
authored
Apr 03, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation
parent
9c8b8a4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
trans/managers.py
trans/managers.py
+23
-0
No files found.
trans/managers.py
View file @
8ba1a18a
...
...
@@ -118,6 +118,9 @@ class UnitManager(models.Manager):
return
dbunit
def
filter_type
(
self
,
rqtype
):
'''
Basic filtering based on unit state or failed checks.
'''
import
trans.models
if
rqtype
==
'all'
:
return
self
.
all
()
...
...
@@ -145,12 +148,18 @@ class UnitManager(models.Manager):
return
self
.
all
()
def
review
(
self
,
date
,
user
):
'''
Returns units touched by other users since given time.
'''
from
trans.models
import
Change
sample
=
self
.
all
()[
0
]
changes
=
Change
.
objects
.
filter
(
unit__translation
=
sample
.
translation
,
timestamp__gte
=
date
).
exclude
(
user
=
user
)
return
self
.
filter
(
id__in
=
changes
.
values_list
(
'unit__id'
,
flat
=
True
))
def
add_to_source_index
(
self
,
checksum
,
source
,
context
,
translation
,
writer
):
'''
Updates/Adds to source index given unit.
'''
writer
.
update_document
(
checksum
=
unicode
(
checksum
),
source
=
unicode
(
source
),
...
...
@@ -159,6 +168,9 @@ class UnitManager(models.Manager):
)
def
add_to_target_index
(
self
,
checksum
,
target
,
translation
,
writer
):
'''
Updates/Adds to target index given unit.
'''
writer
.
update_document
(
checksum
=
unicode
(
checksum
),
target
=
unicode
(
target
),
...
...
@@ -166,6 +178,9 @@ class UnitManager(models.Manager):
)
def
add_to_index
(
self
,
unit
,
writer_target
=
None
,
writer_source
=
None
):
'''
Updates/Adds to all indices given unit.
'''
if
writer_target
is
None
:
writer_target
=
trans
.
search
.
get_target_writer
(
unit
.
translation
.
language
.
code
)
if
writer_source
is
None
:
...
...
@@ -193,6 +208,11 @@ class UnitManager(models.Manager):
def
search
(
self
,
query
,
source
=
True
,
context
=
True
,
translation
=
True
,
checksums
=
False
):
'''
Performs full text search on defined set of fields.
Returns queryset unless checksums is set.
'''
ret
=
set
()
if
source
or
context
:
with
trans
.
search
.
get_source_searcher
()
as
searcher
:
...
...
@@ -212,6 +232,9 @@ class UnitManager(models.Manager):
return
self
.
filter
(
checksum__in
=
ret
)
def
similar
(
self
,
unit
):
'''
Finds similar units to current unit.
'''
ret
=
set
([
unit
.
checksum
])
with
trans
.
search
.
get_source_searcher
()
as
searcher
:
# Extract up to 10 terms from the source
...
...
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