Commit 269920bd authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents d1cb4e3b afec0c03
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import datetime
from south.db import db
from south.v2 import SchemaMigration
......
This diff is collapsed.
......@@ -86,6 +86,7 @@ class Translation(models.Model):
translated = models.IntegerField(default=0, db_index=True)
fuzzy = models.IntegerField(default=0, db_index=True)
total = models.IntegerField(default=0, db_index=True)
failing_checks = models.IntegerField(default=0, db_index=True)
enabled = models.BooleanField(default=True, db_index=True)
......@@ -534,6 +535,10 @@ class Translation(models.Model):
# Update revision and stats
self.update_stats()
# Cleanup checks cache if there were some deleted units
if len(deleted_checksums) > 0:
self.invalidate_cache()
# Store change entry
if request is None:
user = None
......@@ -591,6 +596,9 @@ class Translation(models.Model):
self.total = self.unit_set.count()
self.fuzzy = self.unit_set.filter(fuzzy=True).count()
self.translated = self.unit_set.filter(translated=True).count()
self.failing_checks = self.filter_checks(
'allchecks', translation
).count()
self.save()
self.store_hash()
......
......@@ -168,6 +168,8 @@ class UnitManager(models.Manager):
return translation.fuzzy
elif rqtype == 'untranslated':
return translation.total - translation.translated
elif rqtype == 'allchecks':
return translation.failing_checks
# Try to get value from cache
cache_key = 'counts-%s-%s-%s' % (
......@@ -793,6 +795,7 @@ class Unit(models.Model):
# Delete all checks if only message with this source is fuzzy
if not same_source.exists():
self.checks().delete()
self.translation.invalidate_cache()
return
# If there is no consistency checking, we can return
......
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