Skip to content

Commit

Permalink
Have the checker retrieval in a single place
Browse files Browse the repository at this point in the history
Now all checker retrieval is in TranslationProject.checker. This
also allows to pass the target language to the checkers.

Fixes #5209.
  • Loading branch information
unho committed Sep 14, 2016
1 parent 39174e6 commit 6ffb3b3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
7 changes: 0 additions & 7 deletions pootle/apps/pootle_misc/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,6 @@ def clean_plurr_placeholder(string):
return plurr_plural_suffix_regex.sub('', string)


def get_checker(unit):
if settings.POOTLE_QUALITY_CHECKER:
return import_func(settings.POOTLE_QUALITY_CHECKER)()

return unit.store.translation_project.checker


def get_category_id(code):
return CATEGORY_IDS.get(code)

Expand Down
4 changes: 2 additions & 2 deletions pootle/apps/pootle_store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from pootle.core.utils.aggregate import max_column
from pootle.core.utils.timezone import datetime_min, make_aware
from pootle_format.models import Format
from pootle_misc.checks import check_names, get_checker
from pootle_misc.checks import check_names
from pootle_misc.util import import_func
from pootle_statistics.models import (Submission, SubmissionFields,
SubmissionTypes)
Expand Down Expand Up @@ -664,7 +664,7 @@ def update_qualitychecks(self, keep_false_positives=False):

return False

checker = get_checker(self)
checker = self.store.translation_project.checker
qc_failures = checker.run_filters(self, categorised=True)
checks_to_add = []
for name in qc_failures.iterkeys():
Expand Down
5 changes: 1 addition & 4 deletions pootle/core/checks/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import logging
import time

from django.conf import settings
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.lru_cache import lru_cache

from pootle.core.mixins.treeitem import CachedMethods
from pootle_misc.checks import run_given_filters
from pootle_misc.util import import_func
from pootle_store.constants import OBSOLETE
from pootle_store.models import QualityCheck, Store, Unit
from pootle_store.unit import UnitProxy
Expand Down Expand Up @@ -220,12 +218,11 @@ def get_checker(self, tp_pk):
"""Return the site QualityChecker or the QualityCheck associated with
the a Unit's TP otherwise.
"""
if settings.POOTLE_QUALITY_CHECKER:
return import_func(settings.POOTLE_QUALITY_CHECKER)()
try:
return TranslationProject.objects.get(id=tp_pk).checker
except TranslationProject.DoesNotExist:
# There seems to be a risk of dangling Stores with no TP
logger.error("Missing TP (pk '%s'). No checker retrieved.", tp_pk)
return None

def expire_store_cache(self, store_pk=None):
Expand Down

0 comments on commit 6ffb3b3

Please sign in to comment.