__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from rest_framework import serializers
from api.serializers import DynamicFieldsModelSerializer
from ...models import Publication
[docs]class PublicationPublicSerializer(DynamicFieldsModelSerializer):
url = serializers.URLField(source="get_absolute_url")
doi = serializers.URLField(source="doi_string")
in_issue = serializers.StringRelatedField()
in_volume = serializers.CharField(source="get_volume")
paper_nr = serializers.CharField(source="get_paper_nr")
accepted_submission = serializers.SerializerMethodField()
acad_field = serializers.StringRelatedField()
specialties = serializers.StringRelatedField(many=True)
topics = serializers.StringRelatedField(many=True)
approaches = serializers.StringRelatedField()
[docs] def get_accepted_submission(self, obj):
return obj.accepted_submission.get_absolute_url()
[docs]class PublicationPublicSearchSerializer(DynamicFieldsModelSerializer):
url = serializers.URLField(source="get_absolute_url")