machristie commented on a change in pull request #40:
URL:
https://github.com/apache/airavata-django-portal/pull/40#discussion_r415980685
##########
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,
+
fileContentText=request.data["fileContentText"])
+ else:
+ return Response(status=HTTP_403_FORBIDDEN)
+
+ return self._create_response(request=request, path=path)
+
+
def delete(self, request, path="/", format=None):
- data_products_helper.delete_dir(request, path)
+ if data_products_helper.dir_exists(request, path):
+ data_products_helper.delete_dir(request, path)
+ else:
+ data_products_helper.delete_user_file(request, path)
+
return Response(status=204)
def _create_response(self, request, path, uploaded=None):
- directories, files = data_products_helper.listdir(request, path)
- data = {
- 'directories': directories,
- 'files': files
- }
- if uploaded is not None:
- data['uploaded'] = uploaded
- data['parts'] = self._split_path(path)
- serializer = self.serializer_class(data, context={'request': request})
- return Response(serializer.data)
+ if data_products_helper.dir_exists(request, path):
+ directories, files = data_products_helper.listdir(request, path)
+ data = {
+ 'isDir': True,
Review comment:
Okay, understood.
----------------------------------------------------------------
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]