Citation Auto Generation (Serializer Classes)
Citation records (and other records) are auto-filled with additional content through the Serializer classes from django rest framework. All auto-generation and validation steps are centralised in the Serializer classes, with very little functionality being required from the Views classes except for rendering changes.
- The process for updating a record is as follows:
UI/API view registers a change to a record.
Serializer is instantiated and the data is validated.
- Serializer is then used to create/update records (
serializer.save) Provided data is filtered to remove unknown arguments (mostly from the API)
The
fill_data_parametersserializer method fills in new parameters, and instantiates sub-records (i.e institutions, funders, parties)The publication workflow is executed if required.
The update is made via the
create/update instancefunctions that route changes through the Kafka system if it is in use.
- Serializer is then used to create/update records (
See below for a list of the functions used to fill content in the records.
- citations.serializers.mint_doi_for_data(data: dict, id: str) dict | None[source]
‘Data’ is the partially serialized content for the record to be published.
Expand all creators (proper serialization)
Expand all funders
Expand all references
Send data to publish record
This function is considered a ‘core’ function because it relies on access to the models of this application.
- citations.serializers.institution_mappings(institution_id: str, project_id: str = 'cmip7') str[source]
Apply known institution mappings given the institution_id which is most likely the acronym.
- citations.serializers.title_from_facets(data: dict, raise_exceptions: bool = True) str | list | None[source]
Validate by generating the expected title from the facets.
Facet title generation is project_id specific. If the project_id is not contained in the data, this function should not be run, but will return a None value.
- citations.serializers.obtain_all_references(data: dict) dict[source]
Obtain Citation references from the EMD (ESGVOC)
Prevent adding a reference if it already exists.
- citations.serializers.assemble_license_info(data: dict) str[source]
Determine the paragraph of text to use for the license.
- citations.serializers.abstract_from_esgvoc(data: dict)[source]
Determine the paragraph of abstract text from esgvoc parameters.
- citations.serializers.chain_new_objects(data: dict, serializer: ModelSerializer, model: type[Model], filter_kwargs: list, optionals: list = None, allow_update: bool = False) str[source]
Create new model instances if required, or return the ID of the existing instance.
This includes locating the existing record based on some filter kwargs (normally just the ID) to identify the existing instance.
- class citations.serializers.GenericSerializerMixin(*args, **kwargs)[source]
-
- filter_data(validated_data: dict) dict[source]
Filter out unrecognised parameters.
Also runs the fill_data_parameters method to auto-generate content.