Esempio n. 1
0
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# inspirehep is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

from invenio_records_rest.serializers.response import search_responsify

from inspirehep.records.marshmallow.base import wrap_schema_class_with_metadata
from inspirehep.records.marshmallow.jobs import JobsPublicSchema
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import JSONSerializer

jobs_json = JSONSerializer(wrap_schema_class_with_metadata(JobsPublicSchema),
                           index_name="records-jobs")

jobs_json_response = record_responsify(jobs_json, "application/json")

jobs_json_response_search = search_responsify(jobs_json, "application/json")
Esempio n. 2
0
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# inspirehep is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

from invenio_records_rest.serializers.response import search_responsify

from inspirehep.records.marshmallow.base import wrap_schema_class_with_metadata
from inspirehep.records.marshmallow.experiments import ExperimentsPublicSchema
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import JSONSerializer

experiments_json = JSONSerializer(
    wrap_schema_class_with_metadata(ExperimentsPublicSchema),
    index_name="records-experiments",
)

experiments_json_response = record_responsify(experiments_json,
                                              "application/json")

experiments_json_response_search = search_responsify(experiments_json,
                                                     "application/json")
Esempio n. 3
0
        ),
        (None, wrap_schema_class_with_metadata(LiteraturePublicListSchema)),
    ]
)

literature_json = ConditionalMultiSchemaJSONSerializer(
    [
        (
            lambda _: is_superuser_or_cataloger_logged_in(),
            wrap_schema_class_with_metadata(LiteratureAdminSchema),
        ),
        (None, wrap_schema_class_with_metadata(LiteraturePublicSchema)),
    ]
)

literature_json_response = record_responsify(literature_json, "application/json")
literature_json_response_search = search_responsify(
    literature_json_search, "application/json"
)

literature_detail = JSONSerializer(
    wrap_schema_class_with_metadata(LiteratureDetailSchema)
)
literature_list = JSONSerializerLiteratureSearch(
    LiteratureListWrappedSchema, index_name="records-hep"
)

literature_json_detail_response = record_responsify(
    literature_detail, "application/vnd+inspire.record.ui+json"
)
literature_json_list_response = search_responsify(
Esempio n. 4
0
from inspirehep.records.marshmallow.institutions.ui import (
    InstitutionsDetailSchema,
    InstitutionsListSchema,
)
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import ConditionalMultiSchemaJSONSerializer, JSONSerializer

institutions_json = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        wrap_schema_class_with_metadata(InstitutionsAdminSchema),
    ),
    (None, wrap_schema_class_with_metadata(InstitutionsPublicSchema)),
])

institutions_json_response = record_responsify(institutions_json,
                                               "application/json")

institutions_json_response_search = search_responsify(institutions_json,
                                                      "application/json")

institutions_json_detail = JSONSerializer(
    wrap_schema_class_with_metadata(InstitutionsDetailSchema))
institutions_json_detail_response = record_responsify(
    institutions_json_detail, "application/vnd+inspire.record.ui+json")

institutions_json_list = JSONSerializer(
    wrap_schema_class_with_metadata(InstitutionsListSchema),
    index_name="records-institutions",
)
institutions_json_list_response = search_responsify(
    institutions_json_list, "application/vnd+inspire.record.ui+json")
Esempio n. 5
0
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# inspirehep is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

from invenio_records_rest.serializers import RecordSchemaJSONV1

from inspirehep.accounts.api import is_superuser_or_cataloger_logged_in
from inspirehep.records.marshmallow.base import ForbiddenSchema
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import ConditionalMultiSchemaJSONSerializer

records_raw_json = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        RecordSchemaJSONV1,
    ),
    (None, ForbiddenSchema),
])
raw_json_detail_response = record_responsify(
    records_raw_json,
    "application/vnd+inspire.record.raw+json",
)
Esempio n. 6
0
    AuthorsListSchema,
    AuthorsOnlyControlNumberSchema,
    AuthorsPublicSchema,
)
from inspirehep.records.marshmallow.base import wrap_schema_class_with_metadata
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import ConditionalMultiSchemaJSONSerializer, JSONSerializer

authors_json = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        wrap_schema_class_with_metadata(AuthorsAdminSchema),
    ),
    (None, wrap_schema_class_with_metadata(AuthorsPublicSchema)),
])
authors_json_response = record_responsify(authors_json, "application/json")
authors_json_response_search = search_responsify(authors_json,
                                                 "application/json")

authors_json_detail = JSONSerializer(
    wrap_schema_class_with_metadata(AuthorsDetailSchema))
authors_json_detail_response = record_responsify(
    authors_json_detail, "application/vnd+inspire.record.ui+json")

authors_json_list = JSONSerializer(
    wrap_schema_class_with_metadata(AuthorsListSchema))
authors_json_list_response = search_responsify(
    authors_json_list, "application/vnd+inspire.record.ui+json")

authors_control_number_only_json = JSONSerializer(
    wrap_schema_class_with_metadata(AuthorsOnlyControlNumberSchema))
Esempio n. 7
0
    SeminarsDetailSchema,
    SeminarsListSchema,
)
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import ConditionalMultiSchemaJSONSerializer, JSONSerializer

seminars_json = ConditionalMultiSchemaJSONSerializer(
    [
        (
            lambda _: is_superuser_or_cataloger_logged_in(),
            wrap_schema_class_with_metadata(SeminarsAdminSchema),
        ),
        (None, wrap_schema_class_with_metadata(SeminarsPublicSchema)),
    ]
)
seminars_json_response = record_responsify(seminars_json, "application/json")
seminars_json_response_search = search_responsify(seminars_json, "application/json")

seminars_json_detail = JSONSerializer(
    wrap_schema_class_with_metadata(SeminarsDetailSchema)
)
seminars_json_detail_response = record_responsify(
    seminars_json_detail, "application/vnd+inspire.record.ui+json"
)

seminars_json_list = JSONSerializer(
    wrap_schema_class_with_metadata(SeminarsListSchema), index_name="records-seminars"
)
seminars_json_list_response = search_responsify(
    seminars_json_list, "application/vnd+inspire.record.ui+json"
)
Esempio n. 8
0
from inspirehep.records.marshmallow.experiments.ui import (
    ExperimentsDetailSchema,
    ExperimentsListSchema,
)
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import ConditionalMultiSchemaJSONSerializer, JSONSerializer

experiments_json = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        wrap_schema_class_with_metadata(ExperimentsAdminSchema),
    ),
    (None, wrap_schema_class_with_metadata(ExperimentsPublicSchema)),
])

experiments_json_response = record_responsify(experiments_json,
                                              "application/json")

experiments_json_response_search = search_responsify(experiments_json,
                                                     "application/json")

experiments_json_detail = JSONSerializer(
    wrap_schema_class_with_metadata(ExperimentsDetailSchema))
experiments_json_detail_response = record_responsify(
    experiments_json_detail, "application/vnd+inspire.record.ui+json")

experiments_json_list = JSONSerializer(
    wrap_schema_class_with_metadata(ExperimentsListSchema),
    index_name="records-experiments",
)
experiments_json_list_response = search_responsify(
    experiments_json_list, "application/vnd+inspire.record.ui+json")
Esempio n. 9
0
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# inspirehep is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

from invenio_records_rest.serializers.response import search_responsify

from inspirehep.records.marshmallow.base import wrap_schema_class_with_metadata
from inspirehep.records.marshmallow.institutions import InstitutionsPublicSchema
from inspirehep.records.serializers.response import record_responsify
from inspirehep.serializers import JSONSerializer

institutions_json = JSONSerializer(
    wrap_schema_class_with_metadata(InstitutionsPublicSchema),
    index_name="records-institutions",
)

institutions_json_response = record_responsify(institutions_json,
                                               "application/json")

institutions_json_response_search = search_responsify(institutions_json,
                                                      "application/json")
Esempio n. 10
0
        template_path = os.path.join(directory_path,
                                     "templates/cv_html_template.html")
        template = cv_jinja_env.get_template(template_path)

        return template

    def serialize(self, pid, record, links_factory=None, **kwargs):
        data = self.transform_record(pid, record, links_factory, **kwargs)
        return self.cv_template().render(
            records=[data], host=current_app.config["SERVER_NAME"])

    def preprocess_record(self, pid, record, links_factory=None, **kwargs):
        return record

    def serialize_search(self,
                         pid_fetcher,
                         search_result,
                         links=None,
                         item_links_factory=None):
        records = (self.dump(hit["_source"])
                   for hit in search_result["hits"]["hits"])
        return self.cv_template().render(
            records=records, host=current_app.config["SERVER_NAME"])


literature_cv_html = CVHTMLSerializer(schema_class=CVSchema)
literature_cv_html_response = record_responsify(literature_cv_html,
                                                "text/vnd+inspire.html+html")
literature_cv_html_response_search = search_responsify(
    literature_cv_html, "text/vnd+inspire.html+html")
Esempio n. 11
0
conferences_json = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        wrap_schema_class_with_metadata(ConferencesAdminSchema),
    ),
    (None, wrap_schema_class_with_metadata(ConferencesPublicSchema)),
])
conferences_json_search = ConditionalMultiSchemaJSONSerializer([
    (
        lambda _: is_superuser_or_cataloger_logged_in(),
        wrap_schema_class_with_metadata(ConferencesAdminSchema),
    ),
    (None, wrap_schema_class_with_metadata(ConferencesPublicListSchema)),
])
conferences_json_response = record_responsify(conferences_json,
                                              "application/json")
conferences_json_response_search = search_responsify(conferences_json_search,
                                                     "application/json")

conferences_json_detail = JSONSerializer(
    wrap_schema_class_with_metadata(ConferencesDetailSchema))
conferences_json_detail_response = record_responsify(
    conferences_json_detail, "application/vnd+inspire.record.ui+json")

conferences_json_list = JSONSerializer(
    wrap_schema_class_with_metadata(ConferencesListSchema),
    index_name="records-conferences",
)
conferences_json_list_response = search_responsify(
    conferences_json_list, "application/vnd+inspire.record.ui+json")