Commit 857e50e8 authored by Michal Čihař's avatar Michal Čihař

Update failing check flag using signal

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c10cf920
......@@ -74,3 +74,28 @@ def update_string_pririties(sender, instance, **kwargs):
priority=instance.priority
)
units.update(priority=instance.priority)
def get_related_units(unitdata):
'''
Returns queryset with related units.
'''
related_units = Unit.objects.filter(
contentsum=unitdata.contentsum,
translation__subproject__project=unitdata.project,
)
if unitdata.language is not None:
related_units = related_units.filter(
translation__language=unitdata.language
)
return related_units
@receiver(post_save, sender=Check)
def update_failed_check(sender, instance, **kwargs):
"""
Update related unit failed check flag.
"""
if instance.ignore:
for unit in get_related_units(instance):
unit.update_has_failing_check(False)
......@@ -290,7 +290,7 @@ class Comment(models.Model, RelatedUnitMixin):
CHECK_CHOICES = [(x, CHECKS[x].name) for x in CHECKS]
class Check(models.Model, RelatedUnitMixin):
class Check(models.Model):
contentsum = models.CharField(max_length=40, db_index=True)
project = models.ForeignKey('Project')
language = models.ForeignKey(Language, null=True, blank=True)
......@@ -329,7 +329,3 @@ class Check(models.Model, RelatedUnitMixin):
'''
self.ignore = True
self.save()
# Update related unit flags
for unit in self.get_related_units():
unit.update_has_failing_check(False)
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