Cache whether entry is translated

This commit is contained in:
Michal Čihař 2012-02-28 10:13:43 +01:00
parent b35b9d2463
commit a1ba86dcf1

View File

@ -211,6 +211,7 @@ class Unit(models.Model):
source = models.TextField() source = models.TextField()
target = models.TextField(default = '', blank = True) target = models.TextField(default = '', blank = True)
fuzzy = models.BooleanField(default = False) fuzzy = models.BooleanField(default = False)
translated = models.BooleanField(default = False)
objects = UnitManager() objects = UnitManager()
@ -219,12 +220,14 @@ class Unit(models.Model):
flags = '' # FIXME flags = '' # FIXME
target = join_plural(unit.target.strings) target = join_plural(unit.target.strings)
fuzzy = unit.isfuzzy() fuzzy = unit.isfuzzy()
if not force and location == self.location and flags == self.flags and target == self.target and fuzzy == self.fuzzy: translated = unit.istranslated()
if not force and location == self.location and flags == self.flags and target == self.target and fuzzy == self.fuzzy and translated == self.translated:
return return
self.location = location self.location = location
self.flags = flags self.flags = flags
self.target = target self.target = target
self.fuzzy = fuzzy self.fuzzy = fuzzy
self.translated = translated
self.save(force_insert = force) self.save(force_insert = force)
def is_plural(self): def is_plural(self):