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

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

commit 9d2cd2029b172e782d923573baf1f35a01fcd9c2
Author: lahiruj <[email protected]>
AuthorDate: Tue Jul 22 21:07:53 2025 -0400

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

diff --git a/django_airavata/apps/api/serializers.py 
b/django_airavata/apps/api/serializers.py
index 1f5f97ae..c12f63dc 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/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