Exemplo n.º 1
0
def _check_export_size(domain, export_instances, export_filters):
    count = 0
    for instance in export_instances:
        count += get_export_size(instance, export_filters)
    if count > MAX_EXPORTABLE_ROWS and not PAGINATED_EXPORTS.enabled(domain):
        raise ExportAsyncException(
            _("This export contains %(row_count)s rows. Please change the "
              "filters to be less than %(max_rows)s rows.") % {
                'row_count': count,
                'max_rows': MAX_EXPORTABLE_ROWS
            }
        )
Exemplo n.º 2
0
def _get_writer(export_instances):
    """
    Return a new _Writer
    """
    format = Format.XLS_2007
    if len(export_instances) == 1:
        format = export_instances[0].export_format

    legacy_writer = get_writer(format)
    if PAGINATED_EXPORTS.enabled(export_instances[0].domain):
        writer = _PaginatedWriter(legacy_writer)
    else:
        writer = _Writer(legacy_writer)
    return writer
Exemplo n.º 3
0
def get_export_writer(export_instances, temp_path, allow_pagination=True):
    """
    Return a new _Writer
    """
    format = Format.XLS_2007
    if len(export_instances) == 1:
        format = export_instances[0].export_format

    legacy_writer = get_writer(format)
    if allow_pagination and PAGINATED_EXPORTS.enabled(export_instances[0].domain):
        writer = _PaginatedExportWriter(legacy_writer, temp_path)
    else:
        writer = _ExportWriter(legacy_writer, temp_path)
    return writer
Exemplo n.º 4
0
def get_export_writer(export_instances, temp_path, allow_pagination=True):
    """
    Return a new _Writer
    """
    format = Format.XLS_2007
    if len(export_instances) == 1:
        format = export_instances[0].export_format

    legacy_writer = get_writer(format)
    if allow_pagination and PAGINATED_EXPORTS.enabled(export_instances[0].domain):
        writer = _PaginatedExportWriter(legacy_writer, temp_path)
    else:
        writer = _ExportWriter(legacy_writer, temp_path)
    return writer
Exemplo n.º 5
0
def get_export_writer(export_instances, temp_path, allow_pagination=True):
    """
    Return a new _Writer
    """
    format = Format.XLS_2007
    format_data_in_excel = False

    if len(export_instances) == 1:
        format = export_instances[0].export_format
        format_data_in_excel = (export_instances[0].format_data_in_excel
                                and EXCEL_EXPORT_DATA_TYPING.enabled(
                                    export_instances[0].domain))

    legacy_writer = get_writer(format,
                               use_formatted_cells=format_data_in_excel)

    if allow_pagination and PAGINATED_EXPORTS.enabled(
            export_instances[0].domain):
        writer = _PaginatedExportWriter(legacy_writer, temp_path)
    else:
        writer = _ExportWriter(legacy_writer, temp_path)

    return writer