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


Python EntityMapper.get_by_codes方法代码示例

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


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

示例1: build_table_form

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [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())
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:27,代码来源:util.py

示例2: actor_index

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
def actor_index():
    header = app.config['TABLE_HEADERS']['actor'] + ['description']
    table = {'id': 'actor', 'header': header, 'data': []}
    for actor in EntityMapper.get_by_codes('actor'):
        data = get_base_table_data(actor)
        data.append(truncate_string(actor.description))
        table['data'].append(data)
    return render_template('actor/index.html', table=table)
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:10,代码来源:actor.py

示例3: reference_index

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
def reference_index():
    header = app.config['TABLE_HEADERS']['reference'] + ['description']
    table = {'id': 'reference', 'header': header, 'data': []}
    for reference in EntityMapper.get_by_codes('reference'):
        data = get_base_table_data(reference)
        data.append(truncate_string(reference.description))
        table['data'].append(data)
    return render_template('reference/index.html', table=table)
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:10,代码来源:reference.py

示例4: event_index

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
def event_index():
    header = app.config['TABLE_HEADERS']['event'] + ['description']
    table = {'id': 'event', 'header': header, 'data': []}
    for event in EntityMapper.get_by_codes('event'):
        data = get_base_table_data(event)
        data.append(truncate_string(event.description))
        table['data'].append(data)
    return render_template('event/index.html', table=table)
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:10,代码来源:event.py

示例5: test_export

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
    def test_export(self):
        with app.app_context():
            self.login()
            # Projects
            rv = self.app.get(url_for('import_project_insert'))
            assert b'Name *' in rv.data
            rv = self.app.post(url_for('import_project_insert'), data={'name': 'Project Import'})
            project_id = rv.location.split('/')[-1]
            rv = self.app.get(url_for('import_project_update', id_=project_id))
            assert b'Name *' in rv.data
            rv = self.app.post(url_for('import_project_update', id_=project_id),
                               follow_redirects=True, data={'name': 'Yup', 'description': 'whoa!'})
            assert b'whoa!' in rv.data
            rv = self.app.post(url_for('import_project_insert'), data={'name': 'Yup'},
                               follow_redirects=True)
            assert b'The name is already in use.' in rv.data
            rv = self.app.get(url_for('import_index'))
            assert b'Yup' in rv.data

            # Import data
            rv = self.app.get(url_for('import_data', class_code='E21', project_id=project_id))
            assert b'File *' in rv.data
            with open(os.path.dirname(__file__) + '/../static/import/example.csv', 'rb') as file:
                rv = self.app.post(
                    url_for('import_data', class_code='E18', project_id=project_id),
                    data={'file': file, 'duplicate': True}, follow_redirects=True)
            assert b'King Arthur' in rv.data
            with open(os.path.dirname(__file__) + '/../static/import/example.xlsx', 'rb') as file:
                rv = self.app.post(
                    url_for('import_data', class_code='E18', project_id=project_id),
                    data={'file': file, 'duplicate': True}, follow_redirects=True)
            assert b'IDs already in database' in rv.data
            with open(os.path.dirname(__file__) + '/../static/favicon.ico', 'rb') as file:
                rv = self.app.post(
                    url_for('import_data', class_code='E18', project_id=project_id),
                    data={'file': file}, follow_redirects=True)
            assert b'File type not allowed' in rv.data
            rv = self.app.get(url_for('import_project_view', id_=project_id))
            assert b'King Arthur' in rv.data

            # View an imported entity
            with app.test_request_context():
                app.preprocess_request()
                place_id = EntityMapper.get_by_codes('place')[0].id
            rv = self.app.get(url_for('actor_view', id_=place_id))
            assert b'Yup' in rv.data

            rv = self.app.get(url_for('import_project_delete', id_=project_id),
                              follow_redirects=True)
            assert b'Project deleted' in rv.data
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:52,代码来源:test_import.py

示例6: __call__

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [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

示例7: __call__

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [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

示例8: __call__

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [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
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:39,代码来源:forms.py

示例9: test_place

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
    def test_place(self):
        with app.app_context():
            self.login()
            rv = self.app.get(url_for('place_insert'))
            assert b'+ Place' in rv.data
            with app.test_request_context():
                app.preprocess_request()
                unit_node = NodeMapper.get_hierarchy_by_name('Administrative Unit')
                unit_sub1 = g.nodes[unit_node.subs[0]]
                unit_sub2 = g.nodes[unit_node.subs[1]]
                reference_id = EntityMapper.insert('E31', 'Ancient Books', 'edition').id
                place_node = NodeMapper.get_hierarchy_by_name('Place')
                source_id = EntityMapper.insert('E33', 'Tha source').id
            data = {'name': 'Asgard', 'alias-0': 'Valhöll',
                    unit_node.id: '[' + str(unit_sub1.id) + ',' + str(unit_sub2.id) + ']'}
            rv = self.app.post(url_for('place_insert', origin_id=reference_id), data=data,
                               follow_redirects=True)
            assert b'Asgard' in rv.data
            gis_points = """[{"type":"Feature", "geometry":{"type":"Point", "coordinates":[9,17]},
                    "properties":{"name":"Valhalla","description":"","shapeType":"centerpoint"}}]"""
            data['gis_points'] = gis_points
            data['gis_polygons'] = """[{"geometry":{
                "coordinates":[[[9.75307425847859,17.8111792731339],
                [9.75315472474904,17.8110005175436],[9.75333711496205,17.8110873417098],
                [9.75307425847859,17.8111792731339]]],"type":"Polygon"},
                "properties":{"count":4,"description":"","id":8,"name":"",
                "objectDescription":"","objectId":185,"shapeType":"Shape",
                "siteType":"Settlement","title":""},"type":"Feature"}]"""
            data[place_node.id] = place_node.subs
            data['continue_'] = 'yes'
            rv = self.app.post(
                url_for('place_insert', origin_id=source_id), data=data, follow_redirects=True)
            assert b'Tha source' in rv.data

            with app.test_request_context():
                app.preprocess_request()
                places = EntityMapper.get_by_codes('place')
                place_id = places[0].id
                place2 = places[1]
                location = place2.get_linked_entity('P53')
                actor = EntityMapper.insert('E21', 'Milla Jovovich')
                actor.link('P74', location)
            assert b'Tha source' in rv.data
            rv = self.app.get(url_for('place_index'))
            assert b'Asgard' in rv.data
            rv = self.app.get(url_for('place_update', id_=place_id))
            assert b'Valhalla' in rv.data
            data['continue_'] = ''
            data['alias-1'] = 'Val-hall'
            rv = self.app.post(
                url_for('place_update', id_=place_id), data=data, follow_redirects=True)
            assert b'Val-hall' in rv.data
            with app.test_request_context():
                app.preprocess_request()
                event = EntityMapper.insert('E8', 'Valhalla rising')
                event.link('P7', location)
                event.link('P24', location)
            rv = self.app.get(url_for('place_view', id_=place2.id))
            assert rv.data and b'Valhalla rising' in rv.data

            # Test invalid geom
            data['gis_polygons'] = """[{"type": "Feature", "geometry":
                {"type": "Polygon", "coordinates": [
                [[298.9893436362036, -5.888919049309554], [299.00444983737543, -5.9138487869408545],
                 [299.00650977389887, -5.893358673645309], [298.9848804404028, -5.9070188333813585],
                 [298.9893436362036, -5.888919049309554]]]},
                "properties": {"name": "", "description": "", "shapeType": "shape"}}]"""
            rv = self.app.post(
                url_for('place_insert', origin_id=source_id), data=data, follow_redirects=True)
            assert b'An invalid geometry was entered' in rv.data

            # Place types
            rv = self.app.get(url_for('node_move_entities', id_=unit_sub1.id))
            assert b'Asgard' in rv.data

            # Test move entities of multiple node if link to new node exists
            rv = self.app.post(url_for('node_move_entities', id_=unit_sub1.id),
                               data={unit_node.id: unit_sub2.id, 'selection': location.id},
                               follow_redirects=True)
            assert b'Entities where updated' in rv.data

            # Test move entities of multiple node if link to new node doesn't exists
            rv = self.app.post(url_for('node_move_entities', id_=unit_sub2.id),
                               data={unit_node.id: unit_sub1.id, 'selection': location.id},
                               follow_redirects=True)
            assert b'Entities where updated' in rv.data

            # Subunits
            with app.app_context():
                self.app.get(url_for('place_insert', origin_id=place_id))
                rv = self.app.post(url_for('place_insert', origin_id=place_id),
                                   data={'name': "It's not a bug, it's a feature!"})
                feat_id = rv.location.split('/')[-1]
                self.app.get(url_for('place_insert', origin_id=feat_id))
                self.app.get(url_for('place_update', id_=feat_id))
                self.app.post(url_for('place_update', id_=feat_id),
                              data={'name': "It's not a bug, it's a feature!"})
                rv = self.app.post(url_for('place_insert', origin_id=feat_id),
                                   data={'name':  "I'm a stratigraphic unit"})
                stratigraphic_id = rv.location.split('/')[-1]
#.........这里部分代码省略.........
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:103,代码来源:test_place.py

示例10: test_event

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
    def test_event(self):
        with app.app_context():
            self.login()

            # Create entities for event
            rv = self.app.post(url_for('place_insert'), data={'name': 'My house'})
            residence_id = rv.location.split('/')[-1]
            with app.test_request_context():
                app.preprocess_request()
                actor_id = EntityMapper.insert('E21', 'Game master').id
                file_id = EntityMapper.insert('E31', 'One forsaken file entity', 'file').id
                source_id = EntityMapper.insert('E33', 'Necronomicon', 'source content').id
                reference_id = EntityMapper.insert('E31', 'Ancient Books', 'edition').id

            # Insert
            rv = self.app.get(url_for('event_insert', code='E7'))
            assert b'+ Activity' in rv.data
            data = {
                'name': 'First event ever First event ever First event ever First event ever First',
                'place': residence_id}
            rv = self.app.post(url_for('event_insert', code='E7', origin_id=reference_id),
                               data=data, follow_redirects=True)
            assert b'First event ever' in rv.data
            with app.test_request_context():
                app.preprocess_request()
                activity_id = EntityMapper.get_by_codes('event')[0].id

            self.app.post(url_for('event_insert', code='E7', origin_id=actor_id), data=data)
            self.app.post(url_for('event_insert', code='E7', origin_id=file_id), data=data)
            self.app.post(url_for('event_insert', code='E7', origin_id=source_id), data=data)

            rv = self.app.post(
                url_for('event_insert', code='E8'),
                data={
                    'name': 'Test event',
                    'given_place': '[' + str(residence_id) + ']',
                    'place': residence_id,
                    'event': activity_id,
                    'date_begin_year': '1949',
                    'date_begin_month': '10',
                    'date_begin_day': '8',
                    'date_end_year': '1951'})
            event_id = rv.location.split('/')[-1]
            rv = self.app.get(url_for('event_view', id_=event_id))
            assert b'Test event' in rv.data
            # Add another event and test if events are seen at place
            self.app.post(url_for('event_insert', code='E8'),
                          data={'name': 'Dusk', 'given_place': '[' + str(residence_id) + ']'})
            rv = self.app.get(url_for('place_view', id_=residence_id))
            assert b'Test event' in rv.data
            rv = self.app.get(url_for('actor_view', id_=actor_id))
            assert b'Game master' in rv.data
            rv = self.app.post(
                url_for('event_insert', code='E8'), follow_redirects=True,
                data={'name': 'Test event', 'continue_': 'yes'})
            assert b'An entry has been created' in rv.data
            rv = self.app.get(url_for('event_index'))
            assert b'Test event' in rv.data
            self.app.get(url_for('event_view', id_=activity_id))

            # Update
            rv = self.app.get(url_for('event_update', id_=activity_id))
            assert b'Test event' in rv.data
            rv = self.app.get(url_for('event_update', id_=event_id))
            assert b'First event ever' in rv.data
            data = {'name': 'Event updated'}
            rv = self.app.post(
                url_for('event_update', id_=event_id), data=data, follow_redirects=True)
            assert b'Event updated' in rv.data

            # Test super event validation
            data = {'name': 'Event Horizon', 'event': event_id}
            rv = self.app.post(
                url_for('event_update', id_=event_id), data=data, follow_redirects=True)
            assert b'error' in rv.data

            # Delete
            rv = self.app.get(url_for('event_delete', id_=event_id), follow_redirects=True)
            assert b'The entry has been deleted.' in rv.data
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:81,代码来源:test_event.py

示例11: test_source

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
    def test_source(self):
        with app.app_context():
            self.login()

            # Source insert
            rv = self.app.get(url_for('source_insert'))
            assert b'+ Source' in rv.data
            with app.test_request_context():
                app.preprocess_request()
                origin_id = EntityMapper.insert('E21', 'David Duchovny').id
                actor_id = EntityMapper.insert('E21', 'Gillian Anderson Gillian Anderson ').id
                reference_id = EntityMapper.insert('E84', 'Ancient Books', 'information carrier').id
                file_id = EntityMapper.insert('E31', 'The X-Files', 'file').id

            rv = self.app.post(url_for('source_insert', origin_id=origin_id),
                               data={'name': 'Test source'}, follow_redirects=True)
            assert b'An entry has been created' in rv.data
            with app.test_request_context():
                app.preprocess_request()
                source_id = EntityMapper.get_by_codes('source')[0].id
            rv = self.app.post(url_for('source_insert', origin_id=reference_id),
                               data={'name': 'Test source'}, follow_redirects=True)
            assert b'Ancient Books' in rv.data
            rv = self.app.post(url_for('source_insert', origin_id=file_id),
                               data={'name': 'Test source'}, follow_redirects=True)
            assert b'An entry has been created' in rv.data and b'The X-Files' in rv.data
            data = {'name': 'Test source', 'continue_': 'yes'}
            rv = self.app.post(url_for('source_insert'), data=data, follow_redirects=True)
            assert b'An entry has been created' in rv.data
            rv = self.app.get(url_for('source_index'))
            assert b'Test source' in rv.data

            # Link source
            rv = self.app.post(url_for('reference_insert', code='edition', origin_id=source_id),
                               data={'name': 'Test reference'}, follow_redirects=True)
            assert b'Test source' in rv.data
            self.app.get(url_for('source_add', origin_id=actor_id))
            data = {'values': source_id}
            rv = self.app.post(url_for('source_add', origin_id=actor_id), data=data,
                               follow_redirects=True)
            assert b'Gillian Anderson' in rv.data

            self.app.get(url_for('source_add2', origin_id=actor_id, id_=source_id,
                                 class_name='actor'))
            rv = self.app.post(url_for('source_add2', id_=source_id, class_name='actor'),
                               data={'values': actor_id}, follow_redirects=True)
            assert b'Gillian Anderson' in rv.data
            rv = self.app.get(url_for('source_view', id_=source_id))
            assert b'Gillian Anderson' in rv.data
            rv = self.app.get(url_for('source_add2', id_=source_id, class_name='place'))
            assert b'Add Place' in rv.data

            # Update source
            rv = self.app.get(url_for('source_update', id_=source_id))
            assert b'Test source' in rv.data
            data = {'name': 'Source updated', 'description': 'some description'}
            rv = self.app.post(url_for('source_update', id_=source_id), data=data,
                               follow_redirects=True)
            assert b'Source updated' in rv.data
            rv = self.app.get(url_for('source_view', id_=source_id))
            assert b'some description' in rv.data

            # Delete source
            rv = self.app.get(url_for('source_delete', id_=source_id), follow_redirects=True)
            assert b'The entry has been deleted.' in rv.data
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:67,代码来源:test_source.py

示例12: source_index

# 需要导入模块: from openatlas.models.entity import EntityMapper [as 别名]
# 或者: from openatlas.models.entity.EntityMapper import get_by_codes [as 别名]
def source_index():
    table = {'id': 'source', 'header': app.config['TABLE_HEADERS']['source'], 'data': []}
    for source in EntityMapper.get_by_codes('source'):
        data = get_base_table_data(source)
        table['data'].append(data)
    return render_template('source/index.html', table=table)
开发者ID:DigitisingPatternsOfPower,项目名称:OpenAtlas,代码行数:8,代码来源:source.py


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