Skip to content

Commit

Permalink
Clone muted checks when clone stores
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2-1 committed Feb 2, 2017
1 parent b823ea8 commit 810ea58
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pootle/apps/pootle_translationproject/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
from django.contrib.auth import get_user_model

from pootle.core.models import Revision
from pootle.core.signals import update_data
from pootle_statistics.models import SubmissionTypes
from pootle_store.constants import SOURCE_WINS
from pootle_store.diff import StoreDiff
from pootle_store.models import QualityCheck


User = get_user_model()
Expand Down Expand Up @@ -101,8 +103,27 @@ def clone_store(self, store, target_dir, update_cache=True):
cloned.state = store.state
cloned.filetype = store.filetype
cloned.save()
self.clone_muted_checks(store, cloned)
return cloned

def clone_muted_checks(self, source_store, target_store):
"""Mute false positive checks in target store."""

false_positive_checks = QualityCheck.objects.filter(
unit__store=source_store,
false_positive=True
).values('unit__unitid_hash', 'category', 'name')

for check in false_positive_checks:
QualityCheck.objects.filter(
unit__store=target_store,
unit__unitid_hash=check['unit__unitid_hash'],
category=check['category'],
name=check['name'],
).update(false_positive=True)
update_data.send(
target_store.__class__, instance=target_store)

def create_tp(self, language, project=None):
"""Create a TP for a given language"""
tp_qs = (
Expand Down

0 comments on commit 810ea58

Please sign in to comment.