Beispiel #1
0
def extract_doc_adapter(request, doc_type, doc_id):
    doc = get_doc_by_id(request.registry.db, doc_type, doc_id)
    doc_type_lower = doc_type[0].lower() + doc_type[1:]
    if doc is None:
        request.errors.add("url", "%s_id" % doc_type_lower, "Not Found")
        request.errors.status = 404
        raise error_handler(request)

    method = getattr(request, "%s_from_data" % doc_type_lower)
    return method(doc)
def extract_doc_adapter(request, doc_type, doc_id):
    doc = get_doc_by_id(request.registry.db, doc_type, doc_id)
    doc_type_lower = doc_type[0].lower() + doc_type[1:]
    if doc is None:
        request.errors.add("url", "%s_id" % doc_type_lower, "Not Found")
        request.errors.status = 404
        raise error_handler(request)
    # obsolete lowercase doc_type in agreements
    if doc is not None and doc.get("doc_type") == "agreement":
        request.errors.add("url", "agreement_id", "Archived")
        request.errors.status = 410
        raise error_handler(request)

    method = getattr(request, "%s_from_data" % doc_type_lower)
    return method(doc)
Beispiel #3
0
def extract_doc_adapter(request, doc_type, doc_id):
    doc_type_singular = doc_type[:
                                 -1]  # lower, without last symbol  "frameworks" --> "framework"
    doc = get_doc_by_id(request.registry.databases[doc_type],
                        doc_type_singular.capitalize(), doc_id)
    if doc is None:
        request.errors.add("url", "%s_id" % doc_type_singular, "Not Found")
        request.errors.status = 404
        raise error_handler(request)
    # obsolete lowercase doc_type in agreements
    if doc is not None and doc.get("doc_type") == "agreement":
        request.errors.add("url", "agreement_id", "Archived")
        request.errors.status = 410
        raise error_handler(request)

    method = getattr(request, "%s_from_data" % doc_type_singular)
    return method(doc)
Beispiel #4
0
def get_framework_by_id(db, framework_id):
    return get_doc_by_id(db, "Framework", framework_id)
Beispiel #5
0
def get_submission_by_id(db, submission_id):
    return get_doc_by_id(db, "Submission", submission_id)
def get_agreement_by_id(db, agreement_id):
    return get_doc_by_id(db, "Agreement", agreement_id)