Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JJFlorian committed Mar 28, 2024
1 parent c72dee6 commit ca64375
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions gmw/serializers.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
from rest_framework import serializers
from django.core.exceptions import ObjectDoesNotExist

from rest_framework import serializers

from api.mixins import RequiredFieldsMixin, UrlFieldMixin
from gmn import models as gmn_models

from . import models as gmw_models
from gmn import models as gmn_models


class GMWSerializer(UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer):
linked_gmns = serializers.SerializerMethodField()

class Meta:
model = gmw_models.GMW
fields = "__all__"

def get_linked_gmns(self, obj):
try:
try:
linked_gmns = set(
measuringpoint.gmn.uuid
for measuringpoint in gmn_models.Measuringpoint.objects.filter(gmw_bro_id=obj.bro_id)
for measuringpoint in gmn_models.Measuringpoint.objects.filter(
gmw_bro_id=obj.bro_id
)
)
return list(linked_gmns)

except ObjectDoesNotExist:
return None


class MonitoringTubeSerializer(
UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer
):
Expand Down

0 comments on commit ca64375

Please sign in to comment.