Exemplo n.º 1
0
def budget_2020_sion(app, org_sion, budget_2020_sion_data):
    """Load budget 2020 sion record."""
    budget = Budget.create(data=budget_2020_sion_data,
                           delete_pid=False,
                           dbcommit=True,
                           reindex=True)
    flush_index(BudgetsSearch.Meta.index)
    return budget
Exemplo n.º 2
0
def budget_2019_martigny(app, org_martigny, budget_2019_martigny_data):
    """Load budget 2019 martigny record."""
    budget = Budget.create(data=budget_2019_martigny_data,
                           delete_pid=False,
                           dbcommit=True,
                           reindex=True)
    flush_index(BudgetsSearch.Meta.index)
    return budget
Exemplo n.º 3
0
def test_budgets_es_mapping(es, db, org_martigny, budget_2017_martigny_data):
    """Test acquisition budget elasticsearch mapping."""
    search = BudgetsSearch()
    mapping = get_mapping(search.Meta.index)
    assert mapping
    budget = Budget.create(budget_2017_martigny_data,
                           dbcommit=True,
                           reindex=True,
                           delete_pid=True)
    assert mapping == get_mapping(search.Meta.index)
    budget.delete(force=True, dbcommit=True, delindex=True)
Exemplo n.º 4
0
def budget_is_active_changed(sender, record=None, *args, **kwargs):
    """Reindex related account if is_active field changes."""
    if isinstance(record, Budget):
        ori_record = Budget.get_record_by_pid(record.pid)
        if ori_record['is_active'] != record['is_active']:
            # the `is_active` flag changed, we need to reindex all accounts
            # related to this budget
            uuids = []
            search = AcqAccountsSearch()\
                .filter('term', budget__pid=record.pid)\
                .source().scan()
            for hit in search:
                uuids.append(hit.meta.id)
            AcqAccountsIndexer().bulk_index(uuids)
            process_bulk_queue.apply_async()