Commit 683fea9a authored by Michal Čihař's avatar Michal Čihař

Cleanup checks when deleting units

parent d780b795
......@@ -317,7 +317,20 @@ class Translation(models.Model):
pass
# Delete not used units
Unit.objects.filter(translation = self, id__in = oldunits).delete()
units_to_delete = Unit.objects.filter(translation = self, id__in = oldunits)
deleted_checksums = units_to_delete.values_list('checksum', flat = True)
units_to_delete.delete()
# Cleanup checks for deleted units
for checksum in deleted_checksums:
units = Unit.objects.filter(translation__language = self.language, translation__subproject__project = self.subproject.project, checksum = checksum)
if units.count() == 0:
# Last unit referencing to these checks
Checks.objects.filter(project = self.subproject.project, language = self.language, checksum = checksum).delete()
else:
# There are other units as well, but some checks (eg. consistency) needs update now
for unit in units:
unit.check()
# Update revision and stats
self.update_stats(blob_hash)
......
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