예제 #1
0
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)
예제 #2
0
def file_history(ident):
    try:
        entity = api.get_file(ident)
        history = api.get_file_history(ident)
    except ApiException as ae:
        abort(ae.status)
    return render_template('entity_history.html',
                           entity_type="file",
                           entity=entity,
                           history=history)
예제 #3
0
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)
예제 #4
0
def file_view(ident):
    try:
        entity = api.get_file(ident)
    except ApiException as ae:
        abort(ae.status)
    if entity.state == "redirect":
        return redirect('/file/{}'.format(entity.redirect))
    elif entity.state == "deleted":
        return render_template('deleted_entity.html',
                               entity=entity,
                               entity_type="file")
    else:
        try:
            entity.releases = []
            for r in entity.release_ids:
                entity.releases.append(api.get_release(r))
        except ApiException as ae:
            abort(ae.status)
    return render_template('file_view.html', file=entity)
예제 #5
0
def file_edit_view(ident):
    try:
        entity = api.get_file(ident)
    except ApiException as ae:
        abort(ae.status)
    return render_template('entity_edit.html')