def import_locations_async(domain, file_ref_id, user_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    results = new_locations_import(domain, importer, CouchUser.get_by_user_id(user_id))
    importer.mark_complete()

    if LOCATIONS_IN_UCR.enabled(domain):
        # We must rebuild datasources once the location import is complete in
        # case child locations were not updated, but a parent location was.
        # For example if a state was updated, the county may reference the state
        # and need to have its row updated
        datasources = get_datasources_for_domain(domain, "Location", include_static=True)
        for datasource in datasources:
            rebuild_indicators_in_place.delay(datasource.get_id)

    if getattr(settings, 'CELERY_ALWAYS_EAGER', False):
        # Log results because they are not sent to the view when
        # CELERY_ALWAYS_EAGER is true
        logging.getLogger(__name__).info(
            "import_locations_async %s results: %s -> success=%s",
            file_ref_id,
            " ".join(
                "%s=%r" % (name, getattr(results, name))
                for name in ["messages", "warnings", "errors"]
                if getattr(results, name)
            ),
            results.success,
        )

    return {
        'messages': results
    }
Exemple #2
0
def import_locations_async(domain, file_ref_id, user_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    results = new_locations_import(domain, importer, CouchUser.get_by_user_id(user_id))
    importer.mark_complete()

    if LOCATIONS_IN_UCR.enabled(domain):
        # We must rebuild datasources once the location import is complete in
        # case child locations were not updated, but a parent location was.
        # For example if a state was updated, the county may reference the state
        # and need to have its row updated
        datasources = get_datasources_for_domain(domain, "Location", include_static=True)
        for datasource in datasources:
            rebuild_indicators_in_place.delay(datasource.get_id)

    if getattr(settings, 'CELERY_ALWAYS_EAGER', False):
        # Log results because they are not sent to the view when
        # CELERY_ALWAYS_EAGER is true
        logging.getLogger(__name__).info(
            "import_locations_async %s results: %s -> success=%s",
            file_ref_id,
            " ".join(
                "%s=%r" % (name, getattr(results, name))
                for name in ["messages", "warnings", "errors"]
                if getattr(results, name)
            ),
            results.success,
        )

    return {
        'messages': results
    }
Exemple #3
0
def import_locations_async(domain, file_ref_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    results = new_locations_import(domain, importer)
    importer.mark_complete()

    return {
        'messages': results
    }
Exemple #4
0
def import_locations_async(domain, file_ref_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    task = import_locations_async
    DownloadBase.set_progress(task, 0, 100)
    results = new_locations_import(domain, importer)
    DownloadBase.set_progress(task, 100, 100)
    importer.mark_complete()

    return {'messages': results}
Exemple #5
0
def import_locations_async(domain, file_ref_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    task = import_locations_async
    DownloadBase.set_progress(task, 0, 100)
    results = new_locations_import(domain, importer)
    DownloadBase.set_progress(task, 100, 100)
    importer.mark_complete()

    return {
        'messages': results
    }
Exemple #6
0
def import_locations_async(domain, file_ref_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    results = new_locations_import(domain, importer)
    importer.mark_complete()

    if LOCATIONS_IN_UCR.enabled(domain):
        datasources = get_datasources_for_domain(domain, "Location")
        for datasource in datasources:
            rebuild_indicators_in_place.delay(datasource.get_id)

    return {'messages': results}
Exemple #7
0
def import_locations_async(domain, file_ref_id):
    importer = MultiExcelImporter(import_locations_async, file_ref_id)
    results = new_locations_import(domain, importer)
    importer.mark_complete()

    if LOCATIONS_IN_UCR.enabled(domain):
        # We must rebuild datasources once the location import is complete in
        # case child locations were not updated, but a parent location was.
        # For example if a state was updated, the county may reference the state
        # and need to have its row updated
        datasources = get_datasources_for_domain(domain, "Location", include_static=True)
        for datasource in datasources:
            rebuild_indicators_in_place.delay(datasource.get_id)

    return {
        'messages': results
    }