You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2023/02/22 19:51:28 UTC

[airavata-django-portal] branch develop updated: AIRAVATA-3682 Bug fix: check if data product exists in user storage before trying to determine if writable

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 4cb78711 AIRAVATA-3682 Bug fix: check if data product exists in user storage before trying to determine if writable
4cb78711 is described below

commit 4cb78711a6117300b70e0a96f097568def5b93d1
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Feb 22 14:51:20 2023 -0500

    AIRAVATA-3682 Bug fix: check if data product exists in user storage before trying to determine if writable
---
 django_airavata/apps/api/serializers.py | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 2bfefff5..1f5f97ae 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -575,17 +575,20 @@ class DataProductSerializer(
 
     def get_userHasWriteAccess(self, data_product: DataProductModel):
         request = self.context['request']
-        file_metadata = user_storage.get_data_product_metadata(request, data_product=data_product)
-        # In remote API mode, "userHasWriteAccess" is returned so we just pass it through here
-        if "userHasWriteAccess" in file_metadata:
-            return file_metadata["userHasWriteAccess"]
+        if user_storage.exists(request, data_product):
+            file_metadata = user_storage.get_data_product_metadata(request, data_product=data_product)
+            # In remote API mode, "userHasWriteAccess" is returned so we just pass it through here
+            if "userHasWriteAccess" in file_metadata:
+                return file_metadata["userHasWriteAccess"]
+            else:
+                path = file_metadata["path"]
+                shared_path = view_utils.is_shared_path(path)
+                if shared_path:
+                    # Only admins can edit files/directories in a shared directory
+                    return request.is_gateway_admin
+                return True
         else:
-            path = file_metadata["path"]
-            shared_path = view_utils.is_shared_path(path)
-            if shared_path:
-                # Only admins can edit files/directories in a shared directory
-                return request.is_gateway_admin
-            return True
+            return False
 
 
 # TODO move this into airavata_sdk?