class SeasonSerializer(serializers.HyperlinkedModelSerializer): circuits = NestedHyperlinkedRelatedField(many=True, read_only=True, view_name='circuits-detail', parent_lookup_kwargs={ 'league_pk': 'season__league__pk', 'season_pk': 'season__pk' }) rounds = NestedHyperlinkedRelatedField(many=True, read_only=True, view_name='rounds-detail', parent_lookup_kwargs={ 'league_pk': 'season__league__pk', 'season_pk': 'season__pk' }) brackets = NestedHyperlinkedRelatedField(many=True, read_only=True, view_name='brackets-detail', parent_lookup_kwargs={ 'league_pk': 'season__league__pk', 'season_pk': 'season__pk' }) class Meta: model = Season fields = [ 'name', 'regular_start', 'regular_end', 'tournament_start', 'tournament_end', 'circuits', 'rounds', 'brackets' ]
class ExperimentSerializer(serializers.HyperlinkedModelSerializer): url = NestedHyperlinkedIdentityField( view_name="experiments-detail", parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_field="number", ) description = serializers.CharField(max_length=MAX_BODY_TEXT_LENGTH, allow_blank=True, required=False) terms = serializers.CharField(max_length=MAX_BODY_TEXT_LENGTH, allow_blank=True, required=False) issues = NestedHyperlinkedRelatedField( many=True, queryset=Issue.objects.all(), view_name="issues-detail", parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_url_kwarg="number", lookup_field="number", required=False, ) check_ins = NestedHyperlinkedRelatedField( many=True, queryset=CheckIn.objects.all(), view_name="check-ins-detail", parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_url_kwarg="number", lookup_field="number", required=False, ) def create(self, validated_data): context_kwargs = self.context["view"].kwargs lab = Lab.objects.get(pk=context_kwargs["lab_pk"]) instance = Experiment.objects.create(**validated_data, lab=lab) return instance class Meta: model = Experiment fields = [ "number", "id", "url", "state", "title", "description", "terms", "created", "end_date", "issues", "lab", "deleted", "check_ins", ] read_only_fields = ["lab", "created", "check_ins"]
class IssueCommentSerializer(serializers.HyperlinkedModelSerializer): issue = NestedHyperlinkedRelatedField( view_name="issues-detail", read_only=True, parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_url_kwarg="number", ) url = NestedHyperlinkedIdentityField( view_name="issue-comments-detail", parent_lookup_kwargs={ "lab_pk": "issue__lab__pk", "issue_number": "issue__number", }, ) def create(self, validated_data): context_kwargs = self.context["view"].kwargs issue = Issue.objects.get(lab=context_kwargs["lab_pk"], number=context_kwargs["issue_number"]) instance = IssueComment.objects.create(**validated_data, issue=issue) # instance.issue = return instance class Meta: model = IssueComment fields = ["id", "url", "issue", "body", "created", "deleted"] read_only_fields = ["created"]
class SketchImageSerializer(serializers.ModelSerializer): sketch = NestedHyperlinkedRelatedField( read_only=True, view_name='workload-sketch-detail', parent_lookup_kwargs={ 'workload_pk': 'workload__pk' } ) sketch_pk = serializers.IntegerField(write_only=True) def create(self, validated_data): image = next(self.context.get('view').request.FILES.values()) sketch_id = validated_data.pop('sketch_pk', None) sketch = SketchImage.objects.create(image=image, sketch_id=sketch_id) sketch.save() return sketch def update(self, instance, validated_data): image = next(self.context.get('view').request.FILES.values()) instance.image = image or instance.image instance.save() return instance class Meta: model = SketchImage fields = '__all__'
class PublicationSerializer(ModelSerializer): _href = serializers.HyperlinkedIdentityField( view_name='publications-detail') publisher = DetailRelatedField( help_text=_('The publisher that created this publication.'), queryset=models.Publisher.objects.all()) distributions = serializers.HyperlinkedRelatedField( help_text=_('This publication is currently being served as' 'defined by these distributions.'), many=True, read_only=True, view_name='distributions-detail', ) repository_version = NestedHyperlinkedRelatedField( view_name='versions-detail', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, read_only=True, ) class Meta: model = models.Publication fields = ModelSerializer.Meta.fields + ( 'publisher', 'distributions', 'repository_version', )
class ZaakTypenRelatieSerializer(FlexFieldsSerializerMixin, SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { 'catalogus_pk': 'zaaktype_van__maakt_deel_uit_van__pk', 'zaaktype_pk': 'zaaktype_van__pk', } gerelateerde = NestedHyperlinkedRelatedField( read_only=True, source='zaaktype_naar', view_name='api:zaaktype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'maakt_deel_uit_van__pk', }, ) class Meta: model = ZaakTypenRelatie ref_name = model.__name__ source_mapping = { 'aardRelatie': 'aard_relatie', } fields = ( 'url', 'gerelateerde', 'aardRelatie', 'toelichting', ) extra_kwargs = { 'url': { 'view_name': 'api:zaaktypenrelatie-detail' }, }
class ZaakObjectTypeSerializer(SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { "catalogus_pk": "is_relevant_voor__catalogus__pk", "zaaktype_pk": "is_relevant_voor__pk", } isRelevantVoor = NestedHyperlinkedRelatedField( read_only=True, source="is_relevant_voor", view_name="api:zaaktype-detail", parent_lookup_kwargs={"catalogus_pk": "catalogus__pk"}, ) class Meta: model = ZaakObjectType source_mapping = { "ingangsdatumObject": "datum_begin_geldigheid", "einddatumObject": "datum_einde_geldigheid", "anderObject": "ander_objecttype", "relatieOmschrijving": "relatieomschrijving", } fields = ( "url", "objecttype", "anderObject", "relatieOmschrijving", "ingangsdatumObject", "einddatumObject", "isRelevantVoor", # NOTE: this field is not in the xsd # 'statustype', ) extra_kwargs = {"url": {"view_name": "api:zaakobjecttype-detail"}}
class RolTypeSerializer(FlexFieldsSerializerMixin, SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { 'zaaktype_pk': 'is_van__pk', 'catalogus_pk': 'is_van__maakt_deel_uit_van__pk', } isVan = NestedHyperlinkedRelatedField( read_only=True, source='is_van', view_name='api:zaaktype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'maakt_deel_uit_van__pk', }, ) magZetten = NestedHyperlinkedRelatedField( many=True, read_only=True, source='mag_zetten', view_name='api:statustype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'is_van__maakt_deel_uit_van__pk', 'zaaktype_pk': 'is_van__pk', }, ) class Meta: model = RolType ref_name = model.__name__ source_mapping = { 'ingangsdatumObject': 'datum_begin_geldigheid', 'einddatumObject': 'datum_einde_geldigheid', 'omschrijving': 'roltypeomschrijving', 'omschrijvingGeneriek': 'roltypeomschrijving_generiek', 'soortBetrokkene': 'soort_betrokkene', } extra_kwargs = { 'url': {'view_name': 'api:roltype-detail'}, } fields = ( 'url', 'omschrijving', 'omschrijvingGeneriek', 'soortBetrokkene', 'ingangsdatumObject', 'einddatumObject', 'isVan', 'magZetten', )
class BesluitTypeSerializer(NestedHyperlinkedModelSerializer): parent_lookup_kwargs = {'catalogus_uuid': 'catalogus__uuid'} informatieobjecttypes = NestedHyperlinkedRelatedField( many=True, read_only=True, view_name='informatieobjecttype-detail', lookup_field='uuid', parent_lookup_kwargs={ 'catalogus_uuid': 'catalogus__uuid', }, ) zaaktypes = NestedHyperlinkedRelatedField(many=True, read_only=True, view_name='zaaktype-detail', lookup_field='uuid', parent_lookup_kwargs={ 'catalogus_uuid': 'catalogus__uuid', }) class Meta: model = BesluitType extra_kwargs = { 'url': { 'lookup_field': 'uuid', }, 'catalogus': { 'lookup_field': 'uuid', }, } fields = ( 'url', 'catalogus', 'zaaktypes', 'omschrijving', 'omschrijving_generiek', 'besluitcategorie', 'reactietermijn', 'publicatie_indicatie', 'publicatietekst', 'publicatietermijn', 'toelichting', 'informatieobjecttypes', )
class CatalogusSerializer(serializers.HyperlinkedModelSerializer): zaaktypen = NestedHyperlinkedRelatedField( many=True, read_only=True, source='zaaktype_set', view_name='zaaktype-detail', lookup_field='uuid', parent_lookup_kwargs={'catalogus_uuid': 'catalogus__uuid'}, ) besluittypen = NestedHyperlinkedRelatedField( many=True, read_only=True, source='besluittype_set', view_name='besluittype-detail', lookup_field='uuid', parent_lookup_kwargs={'catalogus_uuid': 'catalogus__uuid'}) informatieobjecttypen = NestedHyperlinkedRelatedField( many=True, read_only=True, source='informatieobjecttype_set', view_name='informatieobjecttype-detail', lookup_field='uuid', parent_lookup_kwargs={'catalogus_uuid': 'catalogus__uuid'}) class Meta: model = Catalogus fields = ( 'url', 'domein', 'rsin', 'contactpersoon_beheer_naam', 'contactpersoon_beheer_telefoonnummer', 'contactpersoon_beheer_emailadres', 'zaaktypen', 'besluittypen', 'informatieobjecttypen', ) extra_kwargs = { 'url': { 'lookup_field': 'uuid' }, }
class TermSerializer(serializers.HyperlinkedModelSerializer): courses_offered = NestedHyperlinkedRelatedField( many=True, read_only=True, view_name='course-detail', parent_lookup_kwargs={'term_pk': 'term__pk'}) class Meta: model = models.Term fields = ('url', 'term_code', 'courses_offered')
class ReadOnlyWorkloadSerializer(serializers.ModelSerializer): wall_photo_wrapper = NestedHyperlinkedRelatedField( read_only=True, view_name='workload-wall_photo_wrapper-detail', parent_lookup_kwargs={'workload_pk': 'workload__pk'} ) class Meta: model = Workload fields = '__all__'
class LikeCommentSerializer(serializers.ModelSerializer): comment = NestedHyperlinkedRelatedField( read_only=True, view_name='song-comments-detail', parent_lookup_kwargs={'song_pk': 'song__pk'}) user = serializers.HyperlinkedRelatedField(read_only=True, view_name='user-detail') class Meta: model = LikeComment fields = ['comment', 'user']
class TCourseSerializer(serializers.ModelSerializer): class Meta: model = Teacher fields = ['teacher_id', 'school', 'course'] course = NestedHyperlinkedRelatedField( many=True, read_only=True, # Or add a queryset view_name='teacher-course-detail', parent_lookup_kwargs={'teacher_id': 'teacher_id'} )
class LeagueSerializer(serializers.HyperlinkedModelSerializer): seasons = NestedHyperlinkedRelatedField( many=True, read_only=True, view_name='seasons-detail', parent_lookup_kwargs={'league_pk': 'league__pk'}) class Meta: model = League fields = ['id', 'name', 'modified', 'created', 'seasons']
class SongSerializer(serializers.ModelSerializer): comments = NestedHyperlinkedRelatedField( many=True, read_only=True, view_name='song-comments-detail', parent_lookup_kwargs={'song_pk': 'song__pk'} ) video_uri = serializers.CharField(read_only=True, source='uri') class Meta: model = Song fields = ['url', 'video_uri', 'title', 'play_cnt', 'like_cnt', 'comments']
class RepositoryVersionSerializer(ModelSerializer, NestedHyperlinkedModelSerializer): _href = NestedHyperlinkedIdentityField( view_name='versions-detail', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) _content_href = NestedHyperlinkedIdentityField( view_name='versions-content', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) _added_href = NestedHyperlinkedIdentityField( view_name='versions-added-content', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) _removed_href = NestedHyperlinkedIdentityField( view_name='versions-removed-content', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) number = serializers.IntegerField(read_only=True) content_summary = serializers.DictField(help_text=_( 'A list of counts of each type of content in this version.'), read_only=True) add_content_units = serializers.ListField(help_text=_( 'A list of content units to add to a new repository version'), write_only=True) remove_content_units = serializers.ListField(help_text=_( 'A list of content units to remove from the latest repository version' ), write_only=True) base_version = NestedHyperlinkedRelatedField( required=False, help_text=_( 'A repository version whose content will be used as the initial set of content ' 'for the new repository version'), queryset=models.RepositoryVersion.objects.all(), view_name='versions-detail', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) class Meta: model = models.RepositoryVersion fields = ModelSerializer.Meta.fields + ( '_href', '_content_href', '_added_href', '_removed_href', 'number', 'content_summary', 'add_content_units', 'remove_content_units', 'base_version')
class TeamSummarySerializer(serializers.HyperlinkedModelSerializer): _href = serializers.HyperlinkedIdentityField(view_name='team-detail') circuit = NestedHyperlinkedRelatedField( many=False, read_only=True, view_name='circuits-detail', parent_lookup_kwargs={ 'league_pk': 'league__pk', 'season_pk': 'season__pk' } ) class Meta: model = Team fields = ['name', '_href', 'circuit', 'is_active', 'circuit_abbrev']
class MeasurementScoreSerializer(serializers.HyperlinkedModelSerializer): url = NestedHyperlinkedIdentityField(view_name='score-detail', parent_lookup_kwargs={ 'measurement': 'measurement__id', 'repo': 'measurement__repository__id' }) measurement = NestedHyperlinkedRelatedField( read_only=True, view_name='measurement-detail', parent_lookup_kwargs={'repo': 'repository__id'}) class Meta: model = MeasurementScore fields = (URL, 'measurement', 'name', 'grade', 'grade_value')
class RolTypeSerializer(NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { 'zaaktype_uuid': 'zaaktype__uuid', 'catalogus_uuid': 'zaaktype__catalogus__uuid', } zaaktype = NestedHyperlinkedRelatedField( read_only=True, view_name='zaaktype-detail', lookup_field='uuid', parent_lookup_kwargs={ 'catalogus_uuid': 'catalogus__uuid', }, ) mogelijke_betrokkenen = MogelijkeBetrokkeneSerializer( many=True, source='mogelijkebetrokkene_set') # magZetten = NestedHyperlinkedRelatedField( # many=True, # read_only=True, # source='mag_zetten', # view_name='api:statustype-detail', # parent_lookup_kwargs={ # 'catalogus_uuid': 'zaaktype__catalogus__uuid', # 'zaaktype_uuid': 'zaaktype__uuid', # }, # ) class Meta: model = RolType fields = ( 'url', 'zaaktype', 'omschrijving', 'omschrijving_generiek', 'mogelijke_betrokkenen', # 'ingangsdatumObject', # 'einddatumObject', # 'soortBetrokkene', # 'magZetten', ) extra_kwargs = { 'url': { 'lookup_field': 'uuid' }, }
class ZaakInformatieobjectTypeArchiefregimeSerializer( FlexFieldsSerializerMixin, SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): """ RSTIOTARC-basis Afwijkende archiveringskenmerken van informatieobjecten van een INFORMATIEOBJECTTYPE bij zaken van een ZAAKTYPE op grond van resultaten van een RESULTAATTYPE bij dat ZAAKTYPE. """ parent_lookup_kwargs = { 'catalogus_pk': 'zaak_informatieobject_type__zaaktype__maakt_deel_uit_van__pk', 'zaaktype_pk': 'zaak_informatieobject_type__zaaktype__pk', } gerelateerde = NestedHyperlinkedRelatedField( read_only=True, source='zaak_informatieobject_type', view_name='api:informatieobjecttype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'informatie_object_type__maakt_deel_uit_van__pk', 'pk': 'informatie_object_type__pk' }, ) class Meta: model = ZaakInformatieobjectTypeArchiefregime ref_name = model.__name__ source_mapping = { 'rstzdt.selectielijstklasse': 'selectielijstklasse', 'rstzdt.archiefnominatie': 'archiefnominatie', 'rstzdt.archiefactietermijn': 'archiefactietermijn', } fields = ( 'url', 'gerelateerde', 'rstzdt.selectielijstklasse', 'rstzdt.archiefnominatie', 'rstzdt.archiefactietermijn', ) extra_kwargs = { 'url': { 'view_name': 'api:rstiotarc-detail' }, }
class EigenschapSerializer(NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { 'zaaktype_uuid': 'is_van__uuid', 'catalogus_uuid': 'is_van__catalogus__uuid', } specificatie = EigenschapSpecificatieSerializer( read_only=True, source='specificatie_van_eigenschap') # referentie = EigenschapReferentieSerializer(read_only=True, source='referentie_naar_eigenschap') zaaktype = NestedHyperlinkedRelatedField( read_only=True, source='is_van', view_name='zaaktype-detail', lookup_field='uuid', parent_lookup_kwargs={ 'catalogus_uuid': 'catalogus__uuid', }, ) class Meta: model = Eigenschap fields = ( 'url', 'naam', 'definitie', 'specificatie', 'toelichting', 'ingangsdatum_object', 'einddatum_object', 'zaaktype', ) extra_kwargs = { 'url': { 'lookup_field': 'uuid', }, 'ingangsdatum_object': { 'source': 'datum_begin_geldigheid', }, 'einddatum_object': { 'source': 'datum_einde_geldigheid', }, 'naam': { 'source': 'eigenschapnaam', } }
class ResultaatTypeSerializer(serializers.HyperlinkedModelSerializer): zaaktype = NestedHyperlinkedRelatedField( read_only=True, view_name='zaaktype-detail', lookup_field='uuid', parent_lookup_kwargs={ 'catalogus_uuid': 'catalogus__uuid', }, label=_('is van') ) brondatum_archiefprocedure = BrondatumArchiefprocedureSerializer( label=_("Brondatum archiefprocedure"), required=False, help_text=("Specificatie voor het bepalen van de brondatum voor de " "start van de Archiefactietermijn (=brondatum) van het zaakdossier.") ) class Meta: model = ResultaatType fields = ( 'url', 'zaaktype', 'omschrijving', 'resultaattypeomschrijving', 'omschrijving_generiek', 'selectielijstklasse', 'toelichting', 'archiefnominatie', 'archiefactietermijn', 'brondatum_archiefprocedure', ) extra_kwargs = { 'url': { 'lookup_field': 'uuid', }, 'omschrijving_generiek': { 'read_only': True, 'help_text': _("Waarde van de omschrijving-generiek referentie (attribuut `omschrijving`)"), } } def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['archiefnominatie'].help_text += '\n\n{}'.format(add_choice_values_help_text(Archiefnominatie))
class WallPhotoWrapperLocationSerializer(serializers.Serializer): lng = serializers.FloatField() lat = serializers.FloatField() street_address = serializers.CharField() self = NestedHyperlinkedRelatedField( read_only=True, source='*', view_name='wrapper-location-detail', parent_lookup_kwargs={'wall_photo_wrapper_pk': 'photo_wrapper__pk', 'workload_pk': 'photo_wrapper__workload__pk'} ) def update(self, instance, validated_data): instance.lat = validated_data.get('lat', instance.lat) instance.lng = validated_data.get('lng', instance.lng) instance.street_address = validated_data.get('street_address', instance.street_address) return instance
class ComponentMeasurementSerializer(serializers.HyperlinkedModelSerializer): url = NestedHyperlinkedIdentityField(view_name='component-detail', parent_lookup_kwargs={ 'measurement': 'measurement__id', 'repo': 'measurement__repository__id' }) measurement = NestedHyperlinkedRelatedField( read_only=True, view_name='measurement-detail', parent_lookup_kwargs={'repo': 'repository__id'}) class Meta: model = ComponentMeasurement fields = (URL, 'measurement', 'node', 'parent', 'useful_lines', 'threshold_violations', 'full_name')
class CheckInSerializer(serializers.HyperlinkedModelSerializer): url = NestedHyperlinkedIdentityField( view_name="check-ins-detail", parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_field="number", ) retrospective = serializers.CharField(max_length=MAX_BODY_TEXT_LENGTH, allow_blank=True, required=False) experiments = NestedHyperlinkedRelatedField( many=True, queryset=Experiment.objects.all(), view_name="experiments-detail", parent_lookup_kwargs={"lab_pk": "lab__pk"}, lookup_url_kwarg="number", lookup_field="number", required=False, ) def create(self, validated_data) -> CheckIn: context_kwargs = self.context["view"].kwargs lab = Lab.objects.get(pk=context_kwargs["lab_pk"]) instance = CheckIn.objects.create(**validated_data, lab=lab) instance.experiments.set( Experiment.objects.filter( lab__pk=context_kwargs["lab_pk"], deleted=False, state="ACTIVE", )) return instance class Meta: model = CheckIn fields = [ "number", "id", "url", "complete", "retrospective", "experiments", "created", "lab", "deleted", ] read_only_fields = ["lab", "created"]
class RepositoryPublishURLSerializer(serializers.Serializer): repository = serializers.HyperlinkedRelatedField( help_text=_('A URI of the repository to be synchronized.'), required=False, label=_('Repository'), queryset=models.Repository.objects.all(), view_name='repositories-detail', ) repository_version = NestedHyperlinkedRelatedField( help_text=_('A URI of the repository version to be published.'), required=False, label=_('Repository Version'), queryset=models.RepositoryVersion.objects.all(), view_name='versions-detail', lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'}, ) def validate(self, data): if hasattr(self, 'initial_data'): validate_unknown_fields(self.initial_data, self.fields) repository = data.pop('repository', None) repository_version = data.get('repository_version') if not repository and not repository_version: raise serializers.ValidationError( _("Either the 'repository' or 'repository_version' need to be specified" )) elif not repository and repository_version: return data elif repository and not repository_version: version = models.RepositoryVersion.latest(repository) if version: new_data = {'repository_version': version} new_data.update(data) return new_data else: raise serializers.ValidationError( detail=_('Repository has no version available to publish')) raise serializers.ValidationError( _("Either the 'repository' or 'repository_version' need to be specified " "but not both."))
class EigenschapSerializer(FlexFieldsSerializerMixin, SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): parent_lookup_kwargs = { 'zaaktype_pk': 'is_van__pk', 'catalogus_pk': 'is_van__maakt_deel_uit_van__pk', } specificatie = EigenschapSpecificatieSerializer(read_only=True, source='specificatie_van_eigenschap') referentie = EigenschapReferentieSerializer(read_only=True, source='referentie_naar_eigenschap') isVan = NestedHyperlinkedRelatedField( read_only=True, source='is_van', view_name='api:zaaktype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'maakt_deel_uit_van__pk', }, ) class Meta: model = Eigenschap ref_name = model.__name__ source_mapping = { 'ingangsdatumObject': 'datum_begin_geldigheid', 'einddatumObject': 'datum_einde_geldigheid', 'naam': 'eigenschapnaam', } extra_kwargs = { 'url': {'view_name': 'api:eigenschap-detail'}, } fields = ( 'url', 'naam', 'definitie', 'specificatie', 'referentie', 'toelichting', 'ingangsdatumObject', 'einddatumObject', # This field is unused in the SOAP services. # 'status_type', 'isVan', )
class ZaakTypeInformatieObjectTypeSerializer(FlexFieldsSerializerMixin, SourceMappingSerializerMixin, NestedHyperlinkedModelSerializer): """ ZKTIOT-basis Relatie met informatieobjecttype dat relevant is voor zaaktype. """ parent_lookup_kwargs = { 'catalogus_pk': 'zaaktype__maakt_deel_uit_van__pk', 'zaaktype_pk': 'zaaktype__pk', } gerelateerde = NestedHyperlinkedRelatedField( read_only=True, source='informatie_object_type', view_name='api:informatieobjecttype-detail', parent_lookup_kwargs={ 'catalogus_pk': 'maakt_deel_uit_van__pk', }, ) class Meta: model = ZaakInformatieobjectType ref_name = model.__name__ source_mapping = { 'zdt.volgnummer': 'volgnummer', 'zdt.richting': 'richting', } fields = ( 'url', 'gerelateerde', 'zdt.volgnummer', 'zdt.richting', ) extra_kwargs = { 'url': { 'view_name': 'api:zktiot-detail' }, }
class TeamSerializer(serializers.ModelSerializer): wins = serializers.IntegerField() losses = serializers.IntegerField() circuit = NestedHyperlinkedRelatedField( many=False, read_only=True, view_name='circuits-detail', parent_lookup_kwargs={ 'league_pk': 'league__pk', 'season_pk': 'season__pk' }, ) class Meta: model = Team fields = [ 'name', 'circuit', 'dynasty', 'captain', 'members', 'modified', 'created', 'wins', 'losses' ] depth = 2