Skip to content

Commit

Permalink
Merge pull request #9 from nens/gmw_list
Browse files Browse the repository at this point in the history
added extra info to measuringpoint endpoint
  • Loading branch information
JJFlorian authored Mar 20, 2024
2 parents b817256 + 9abaaa5 commit ae77333
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gmn/serializers.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit ae77333

Please sign in to comment.