machristie commented on a change in pull request #40:
URL: 
https://github.com/apache/airavata-django-portal/pull/40#discussion_r415978434



##########
File path: django_airavata/apps/api/views.py
##########
@@ -1535,7 +1534,7 @@ def put(self, request, path="/", format=None):
             data_products_helper.update_file_content(request=request, 
path=path,
                                                      
fileContentText=request.data["fileContentText"])
         else:
-            return Response(status=HTTP_403_FORBIDDEN)
+            return Response(status=HTTP_404_NOT_FOUND)

Review comment:
       I see you changed this to 404, but really it should be 400 since the 
request is missing required values.

##########
File path: django_airavata/apps/api/views.py
##########
@@ -1520,21 +1523,56 @@ def move_file(file_path, file_name, file_type):
             data_product = tus.move_tus_upload(uploadURL, move_file)
         return self._create_response(request, path, uploaded=data_product)
 
+    # Accept wither to replace file or to replace file content text.
+    def put(self, request, path="/", format=None):
+        # Replace the file if the request has a file upload.
+        if 'file' in request.FILES:
+            self.delete(request=request, path=path, format=format)
+            dir_path, file_name = split_dir_path_and_file_name(path=path)
+            self.post(request=request, path=dir_path, format=format, 
file_name=file_name)
+        # Replace only the file content if the request body has the 
`fileContentText`
+        elif request.data and "fileContentText" in request.data:
+            data_products_helper.update_file_content(request=request, 
path=path,

Review comment:
       You can get the data product URI using 
`data_products_helper.user_file_exists()` then load the data product with 
`request.getDataProduct()`.
   
   However, I think this is fine, at least for now. The challenge is that the 
Airavata API uses data product URIs for user files, but we also need a 
path-based API in the Django portal for traversing and manipulating user 
directories. That's why there are two different kinds of REST endpoints, ones 
using data product URIs and ones using paths. Eventually we should update the 
Airavata API to handle directories as well as files then we can use Airavata 
API identifiers in the Django REST API in all places.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to