This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-portals.git


The following commit(s) were added to refs/heads/main by this push:
     new cb95e045e updated the serializer to handle reservations when it is null
cb95e045e is described below

commit cb95e045e63c62908046ebdcb07ce34fbcd4d000
Author: lahiruj <[email protected]>
AuthorDate: Tue Jul 22 19:24:40 2025 -0400

    updated the serializer to handle reservations when it is null
---
 .../django_airavata/apps/api/serializers.py                   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/airavata-django-portal/django_airavata/apps/api/serializers.py 
b/airavata-django-portal/django_airavata/apps/api/serializers.py
index 1f5f97ae3..c12f63dc5 100644
--- a/airavata-django-portal/django_airavata/apps/api/serializers.py
+++ b/airavata-django-portal/django_airavata/apps/api/serializers.py
@@ -673,7 +673,16 @@ class ComputeResourceReservationSerializer(
 
 class GroupComputeResourcePreferenceSerializer(
         thrift_utils.create_serializer_class(GroupComputeResourcePreference)):
-    reservations = ComputeResourceReservationSerializer(many=True)
+    reservations = serializers.SerializerMethodField()
+
+    # Check if the object (e.g. SLURM type) has the 'reservations' attribute
+    def get_reservations(self, obj):
+        if hasattr(obj, 'reservations'):
+            reservations_data = getattr(obj, 'reservations')
+            if reservations_data is not None:
+                return ComputeResourceReservationSerializer(reservations_data, 
many=True, context=self.context).data
+
+        return []
 
 
 class GroupResourceProfileSerializer(

Reply via email to