Exemplo n.º 1
0
def get_table(view: str) -> Table:
    table = Table(g.table_headers[view])
    if view == 'file':
        table.header = ['date'] + table.header
        file_stats = get_file_stats()
        for entity in Entity.get_by_class('file', nodes=True):
            date = 'N/A'
            if entity.id in file_stats:
                date = format_date(
                    datetime.datetime.utcfromtimestamp(
                        file_stats[entity.id]['date']))
            table.rows.append([
                date,
                link(entity),
                entity.print_standard_type(),
                convert_size(file_stats[entity.id]['size']) if entity.id
                in file_stats else 'N/A', file_stats[entity.id]['ext']
                if entity.id in file_stats else 'N/A', entity.description
            ])
    elif view == 'reference_system':
        for system in g.reference_systems.values():
            table.rows.append([
                link(system), system.count if system.count else '',
                external_url(system.website_url),
                external_url(system.resolver_url), system.placeholder,
                link(g.nodes[system.precision_default_id])
                if system.precision_default_id else '', system.description
            ])
    else:
        classes = ['place'] if view == 'place' else g.view_class_mapping[view]
        entities = Entity.get_by_class(classes, nodes=True)
        table.rows = [get_base_table_data(item) for item in entities]
    return table
Exemplo n.º 2
0
def get_table(view: str) -> Table:
    header = g.table_headers[view]
    if view == 'file':
        header = ['date'] + header
        if session['settings']['image_processing'] \
                and current_user.settings['table_show_icons']:
            header.insert(1, _('icon'))
    table = Table(header)
    if view == 'file':
        if not g.file_stats:
            g.file_stats = get_file_stats()
        for entity in Entity.get_by_class('file', nodes=True):
            date = 'N/A'
            if entity.id in g.file_stats:
                date = format_date(
                    datetime.datetime.utcfromtimestamp(
                        g.file_stats[entity.id]['date']))
            data = [
                date,
                link(entity),
                link(entity.standard_type), g.file_stats[entity.id]['size']
                if entity.id in g.file_stats else 'N/A',
                g.file_stats[entity.id]['ext']
                if entity.id in g.file_stats else 'N/A', entity.description
            ]
            if session['settings']['image_processing'] \
                    and current_user.settings['table_show_icons']:
                data.insert(1, file_preview(entity.id))
            table.rows.append(data)

    elif view == 'reference_system':
        for system in g.reference_systems.values():
            table.rows.append([
                link(system), system.count if system.count else '',
                external_url(system.website_url),
                external_url(system.resolver_url), system.placeholder,
                link(g.nodes[system.precision_default_id])
                if system.precision_default_id else '', system.description
            ])
    else:
        classes = 'place' if view == 'place' else g.view_class_mapping[view]
        entities = Entity.get_by_class(classes, nodes=True, aliases=True)
        table.rows = [get_base_table_data(entity) for entity in entities]
    return table