当前位置: 首页>>代码示例>>Python>>正文


Python EntityMapper.get_display_files方法代码示例

本文整理汇总了Python中openatlas.models.entity.EntityMapper.get_display_files方法的典型用法代码示例。如果您正苦于以下问题:Python EntityMapper.get_display_files方法的具体用法?Python EntityMapper.get_display_files怎么用?Python EntityMapper.get_display_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openatlas.models.entity.EntityMapper的用法示例。


在下文中一共展示了EntityMapper.get_display_files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_display_files [as 别名]
 def __call__(self, field, **kwargs):
     file_stats = None
     class_ = 'place' if field.id in ['residence', 'begins_in', 'ends_in'] else field.id
     if class_ == 'place':
         aliases = current_user.settings['table_show_aliases']
         entities = EntityMapper.get_by_system_type('place', nodes=True, aliases=aliases)
     elif class_ == 'reference':
         entities = EntityMapper.get_by_system_type('bibliography') + \
                    EntityMapper.get_by_system_type('edition') + \
                    EntityMapper.get_by_system_type('external reference')
     elif class_ == 'file':
         entities = EntityMapper.get_display_files()
         file_stats = get_file_stats()
     else:
         entities = EntityMapper.get_by_codes(class_)
     selection = ''
     table = Table(Table.HEADERS[class_])
     for entity in entities:
         # Todo: don't show self e.g. at source
         if field.data and entity.id == int(field.data):
             selection = entity.name
         data = get_base_table_data(entity, file_stats)
         data[0] = """<a onclick="selectFromTable(this,'{name}', {entity_id})">{entity_name}</a>
                     """.format(name=field.id,
                                entity_id=entity.id,
                                entity_name=truncate_string(entity.name, span=False))
         data[0] = '<br />'.join([data[0]] + [
             truncate_string(alias) for id_, alias in entity.aliases.items()])
         table.rows.append(data)
     html = """
         <input id="{name}-button" name="{name}-button" class="table-select {required}"
             type="text" placeholder="{change_label}" onfocus="this.blur()" readonly="readonly"
             value="{selection}">
         <a id="{name}-clear" class="button" {clear_style}
             onclick="clearSelect('{name}');">{clear_label}</a>
         <div id="{name}-overlay" class="overlay">
         <div id="{name}-dialog" class="overlay-container">{table}</div></div>
         <script>$(document).ready(function () {{createOverlay("{name}", "{title}");}});</script>
         """.format(name=field.id,
                    title=_(field.id.replace('_', ' ')),
                    change_label=uc_first(_('change')),
                    clear_label=uc_first(_('clear')),
                    table=table.display(field.id),
                    selection=selection,
                    clear_style='' if selection else ' style="display: none;" ',
                    required=' required' if field.flags.required else '')
     return super(TableSelect, self).__call__(field, **kwargs) + html
开发者ID:stefaneichert,项目名称:openAtlas,代码行数:49,代码来源:forms.py

示例2: __call__

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_display_files [as 别名]
 def __call__(self, field, **kwargs):
     selection = ''
     class_ = field.id
     if class_ in ['residence', 'begins_in', 'ends_in']:
         class_ = 'place'
     header = app.config['TABLE_HEADERS'][class_]
     table = {'id': field.id, 'header': header, 'data': []}
     file_stats = None
     if class_ == 'place':
         entities = EntityMapper.get_by_system_type('place')
     elif class_ == 'reference':
         entities = EntityMapper.get_by_system_type('bibliography') + \
                    EntityMapper.get_by_system_type('edition') + \
                    EntityMapper.get_by_system_type('external reference')
     elif class_ == 'file':
         entities = EntityMapper.get_display_files()
         file_stats = get_file_stats()
     else:
         entities = EntityMapper.get_by_codes(class_)
     for entity in entities:
         # Todo: don't show self e.g. at source
         if field.data and entity.id == int(field.data):
             selection = entity.name
         data = get_base_table_data(entity, file_stats)
         data[0] = """<a onclick="selectFromTable(this,'{name}', {entity_id})">{entity_name}</a>
                     """.format(name=field.id,
                                entity_id=entity.id,
                                entity_name=truncate_string(entity.name, span=False))
         table['data'].append(data)
     html = """
         <input id="{name}-button" name="{name}-button" class="table-select {required}"
             type="text" placeholder="{change_label}" onfocus="this.blur()" readonly="readonly"
             value="{selection}">
         <a id="{name}-clear" class="button" {clear_style}
             onclick="clearSelect('{name}');">{clear_label}</a>
         <div id="{name}-overlay" class="overlay">
         <div id="{name}-dialog" class="overlay-container">{pager}</div></div>
         <script>$(document).ready(function () {{createOverlay("{name}", "{title}");}});</script>
         """.format(name=field.id,
                    title=_(field.id.replace('_', ' ')),
                    change_label=uc_first(_('change')),
                    clear_label=uc_first(_('clear')),
                    pager=pager(table),
                    selection=selection,
                    clear_style='' if selection else ' style="display: none;" ',
                    required=' required' if field.flags.required else '')
     return super(TableSelect, self).__call__(field, **kwargs) + html
开发者ID:craws,项目名称:OpenAtlas,代码行数:49,代码来源:forms.py


注:本文中的openatlas.models.entity.EntityMapper.get_display_files方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。