Skip to content

Commit

Permalink
added gmw_well_code to monitoringtube endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JJFlorian committed Mar 28, 2024
1 parent ca64375 commit c1a96b2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gmw/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def get_linked_gmns(self, obj):
class MonitoringTubeSerializer(
UrlFieldMixin, RequiredFieldsMixin, serializers.ModelSerializer
):
gmw_well_code = serializers.SerializerMethodField()

class Meta:
model = gmw_models.MonitoringTube
fields = "__all__"
Expand All @@ -39,3 +41,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field in self.fields.values():
field.required = True

def get_gmw_well_code(self, obj):
try:
return gmw_models.GMW.objects.get(uuid=obj.gmw.uuid).well_code
except ObjectDoesNotExist:
return None

0 comments on commit c1a96b2

Please sign in to comment.