本文整理汇总了Python中openatlas.models.entity.EntityMapper.get_by_system_type方法的典型用法代码示例。如果您正苦于以下问题:Python EntityMapper.get_by_system_type方法的具体用法?Python EntityMapper.get_by_system_type怎么用?Python EntityMapper.get_by_system_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openatlas.models.entity.EntityMapper
的用法示例。
在下文中一共展示了EntityMapper.get_by_system_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_table_form
# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_system_type [as 别名]
def build_table_form(class_name, linked_entities):
""" Returns a form with a list of entities with checkboxes"""
from flask_wtf.csrf import generate_csrf
from openatlas.models.entity import EntityMapper
header = app.config['TABLE_HEADERS'][class_name] + ['']
table = {'id': class_name, 'header': header, 'data': []}
linked_ids = [entity.id for entity in linked_entities]
file_stats = get_file_stats() if class_name == 'file' else None
if class_name == 'file':
entities = EntityMapper.get_by_system_type('file')
elif class_name == 'place':
entities = EntityMapper.get_by_system_type('place')
else:
entities = EntityMapper.get_by_codes(class_name)
for entity in entities:
if entity.id in linked_ids:
continue # Don't show already linked entries
input_ = '<input id="{id}" name="values" type="checkbox" value="{id}">'.format(id=entity.id)
table['data'].append(get_base_table_data(entity, file_stats) + [input_])
if not table['data']:
return uc_first(_('no entries'))
return """<form class="table" method="post">
<input id="csrf_token" name="csrf_token" type="hidden" value="{token}">
{pager} <button name="form-submit" id="form-submit" type="submit">{add}</button>
</form>""".format(add=uc_first(_('add')), pager=pager(table), token=generate_csrf())
示例2: __call__
# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_system_type [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
示例3: __call__
# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_system_type [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
示例4: __call__
# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_system_type [as 别名]
def __call__(self, field, **kwargs):
if field.data and type(field.data) is str:
field.data = ast.literal_eval(field.data)
selection = ''
class_ = field.id if field.id != 'given_place' else 'place'
table = {'id': field.id, 'header': app.config['TABLE_HEADERS'][class_], 'data': []}
# Make checkbox column sortable and show selected on top
table['headers'] = 'headers: { ' + str(len(table['header'])) + ': { sorter: "checkbox" } }'
table['sort'] = 'sortList: [[' + str(len(table['header'])) + ',0],[0,0]]'
if class_ == 'place':
entities = EntityMapper.get_by_system_type('place')
else:
entities = EntityMapper.get_by_codes(class_)
for entity in entities:
selection += entity.name + '<br/>' if field.data and entity.id in field.data else ''
data = get_base_table_data(entity)
data[0] = truncate_string(entity.name) # Replace entity link with entity name
html = """<input type="checkbox" id="{id}" {checked} value="{name}"
class="multi-table-select">""".format(
id=str(entity.id), name=entity.name,
checked='checked = "checked"' if field.data and entity.id in field.data else '')
data.append(html)
table['data'].append(data)
html = """
<span id="{name}-button" class="button">{change_label}</span><br />
<div id="{name}-selection" class="selection" style="text-align:left;">{selection}</div>
<div id="{name}-overlay" class="overlay">
<div id="{name}-dialog" class="overlay-container">{pager}</div></div>
<script>
$(document).ready(function () {{createOverlay("{name}", "{title}", true);}});
</script>""".format(
name=field.id,
change_label=uc_first(_('change')),
title=_(field.id.replace('_', ' ')),
selection=selection,
pager=pager(table, remove_rows=False))
return super(TableMultiSelect, self).__call__(field, **kwargs) + html