def generic_get_entity(entity_type, ident): try: if entity_type == 'container': return enrich_container_entity(api.get_container(ident)) elif entity_type == 'creator': return enrich_creator_entity(api.get_creator(ident)) elif entity_type == 'file': return enrich_file_entity(api.get_file(ident, expand="releases")) elif entity_type == 'fileset': return enrich_fileset_entity( api.get_fileset(ident, expand="releases")) elif entity_type == 'webcapture': return enrich_webcapture_entity( api.get_webcapture(ident, expand="releases")) elif entity_type == 'release': return enrich_release_entity( api.get_release(ident, expand="container,files,filesets,webcaptures")) elif entity_type == 'work': return enrich_work_entity(api.get_work(ident)) else: raise NotImplementedError except ApiException as ae: abort(ae.status) except ApiValueError: abort(400)
def work_history(ident): try: entity = api.get_work(ident) history = api.get_work_history(ident) except ApiException as ae: abort(ae.status) return render_template('entity_history.html', entity_type="work", entity=entity, history=history)
def generic_get_entity(entity_type: str, ident: str, enrich: bool = True) -> Any: try: if entity_type == "container" and enrich: return enrich_container_entity(api.get_container(ident)) elif entity_type == "container": return api.get_container(ident) elif entity_type == "creator" and enrich: return enrich_creator_entity(api.get_creator(ident)) elif entity_type == "creator": return api.get_creator(ident) elif entity_type == "file" and enrich: return enrich_file_entity(api.get_file(ident, expand="releases")) elif entity_type == "file": return api.get_file(ident, expand="releases") elif entity_type == "fileset" and enrich: return enrich_fileset_entity( api.get_fileset(ident, expand="releases")) elif entity_type == "fileset": return api.get_fileset(ident) elif entity_type == "webcapture" and enrich: return enrich_webcapture_entity( api.get_webcapture(ident, expand="releases")) elif entity_type == "webcapture": return api.get_webcapture(ident) elif entity_type == "release" and enrich: return enrich_release_entity( api.get_release( ident, expand="container,creators,files,filesets,webcaptures")) elif entity_type == "release": return api.get_release(ident) elif entity_type == "work" and enrich: return enrich_work_entity(api.get_work(ident)) elif entity_type == "work": return api.get_work(ident) else: raise NotImplementedError except ApiException as ae: abort(ae.status) except ApiValueError: abort(400)
def work_view(ident): try: entity = api.get_work(ident) releases = api.get_work_releases(ident) except ApiException as ae: abort(ae.status) if entity.state == "redirect": return redirect('/work/{}'.format(entity.redirect)) if entity.state == "deleted": return render_template('deleted_entity.html', entity=entity, entity_type="work") return render_template('work_view.html', work=entity, releases=releases)
def work_edit_view(ident): try: entity = api.get_work(ident) except ApiException as ae: abort(ae.status) return render_template('entity_edit.html')