def update_tp_and_store_stats(apps, schema_editor):
    Store = apps.get_model("pootle_store.Store")
    TranslationProject = apps.get_model(
        "pootle_translationproject.TranslationProject")
    for store in Store.objects.iterator():
        logger.info("Set stats for Store: %s" % store.pootle_path)
        StoreDataTool(store).update()
    for tp in TranslationProject.objects.iterator():
        logger.info("Set stats for TP: %s" % tp.pootle_path)
        TPDataTool(tp).update()
Ejemplo n.º 2
0
def fix_empty_wordcounts(apps, schema_editor):
    unit_sources = apps.get_model("pootle_store.UnitSource").objects
    Store = apps.get_model("pootle_store.Store")
    TranslationProject = apps.get_model(
        "pootle_translationproject.TranslationProject")
    unit_sources = unit_sources.filter(source_wordcount=1).filter(
        unit__source_f__regex="^$")
    stores = set(unit_sources.values_list("unit__store", flat=True).distinct())
    tps = set(
        unit_sources.values_list("unit__store__translation_project",
                                 flat=True).distinct())
    unit_sources.update(source_wordcount=0)
    for store in Store.objects.filter(id__in=stores).iterator():
        logger.debug("Updating stats for Store: %s" % store.pootle_path)
        StoreDataTool(store).update()
    for tp in TranslationProject.objects.filter(id__in=tps).iterator():
        logger.debug("Set stats for TP: %s" % tp.pootle_path)
        TPDataTool(tp).update()
Ejemplo n.º 3
0
def test_data_tp_updater(tp0):
    data_tool = TPDataTool(tp0)
    updater = TPDataUpdater(data_tool)
    assert updater.tool.context == tp0
    assert isinstance(tp0.data_tool.updater, TPDataUpdater)
Ejemplo n.º 4
0
def test_data_tp_util(tp0):
    data_tool = TPDataTool(tp0)
    assert data_tool.context == tp0
    assert isinstance(tp0.data_tool, TPDataTool)