Commit 8ba1a18a authored by Michal Čihař's avatar Michal Čihař

Documentation

parent 9c8b8a4e
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment