From 9abaaa533a9ab1a15b4024ac0726d80d5894be3e Mon Sep 17 00:00:00 2001 From: Florian Knappers <73856313+JJFlorian@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:37:40 +0100 Subject: [PATCH] added extra info to measuringpoint endpoint --- gmn/serializers.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gmn/serializers.py b/gmn/serializers.py index 69821aa..b222022 100644 --- a/gmn/serializers.py +++ b/gmn/serializers.py @@ -1,6 +1,7 @@ from rest_framework import serializers from api.mixins import RequiredFieldsMixin, UrlFieldMixin +from gmw import models as gmw_models from . import models as gmn_models @@ -14,6 +15,22 @@ class Meta: class MeasuringpointSerializer( UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer ): + gmw_uuid = serializers.SerializerMethodField() + monitoringtube_uuid = serializers.SerializerMethodField() + location = serializers.SerializerMethodField() + class Meta: model = gmn_models.Measuringpoint fields = "__all__" + + def get_location(self, obj): + return gmw_models.GMW.objects.get(bro_id=obj.gmw_bro_id).standardized_location + + def get_gmw_uuid(self, obj): + return gmw_models.GMW.objects.get(bro_id=obj.gmw_bro_id).uuid + + def get_monitoringtube_uuid(self, obj): + gmw_uuid = self.get_gmw_uuid(obj) + return gmw_models.MonitoringTube.objects.get( + gmw=gmw_uuid, tube_number=obj.tube_number + ).uuid