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 2019/05/29 22:34:11 UTC
[airavata-django-portal] 03/04: AIRAVATA-3016 Remove unneeded code
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 87e0ba3fd0bbfe577355cd1029e80aeea4f167b6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed May 29 18:32:32 2019 -0400
AIRAVATA-3016 Remove unneeded code
---
django_airavata/apps/api/urls.py | 4 -
django_airavata/apps/api/views.py | 79 +-----------
.../js/components/project/AddFileButton.vue | 136 ---------------------
.../js/containers/ProjectListContainer.vue | 3 -
4 files changed, 4 insertions(+), 218 deletions(-)
diff --git a/django_airavata/apps/api/urls.py b/django_airavata/apps/api/urls.py
index 6b80b19..798492e 100644
--- a/django_airavata/apps/api/urls.py
+++ b/django_airavata/apps/api/urls.py
@@ -45,10 +45,6 @@ router.register(r'parsers', views.ParserViewSet, base_name='parser')
app_name = 'django_airavata_api'
urlpatterns = [
url(r'^', include(router.urls)),
- # TODO: remove these
- # url(r'^get-ufiles$', views.get_user_files, name='get_user_files'),
- # url(r'^upload-ufiles$', views.upload_user_file, name='upload_user_file'),
- # url(r'^delete-ufiles$', views.delete_user_file, name='delete_user_file'),
url(r'^upload$', views.upload_input_file, name='upload_input_file'),
url(r'^download', views.download_file, name='download_file'),
url(r'^delete-file$', views.delete_file, name='delete_file'),
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index c3e652c..305552e 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -47,8 +47,6 @@ from . import (
thrift_utils
)
-# from django_airavata.apps.workspace.models import User_Files
-
READ_PERMISSION_TYPE = '{}:READ'
@@ -829,64 +827,6 @@ class DataProductView(APIView):
data_product, context={'request': request})
return Response(serializer.data)
-# TODO: remove
-# @login_required
-# def get_user_files(request):
-
-# dirs = [] # a list with file_name and file_dpu for each file
-# for o in User_Files.objects.values_list('file_name', 'file_dpu'):
-# file_details = {}
-# file_details['file_name'] = o[0]
-# file_details['file_dpu'] = o[1]
-# dirs.append(file_details)
-
-# return JsonResponse({'uploaded': True, 'user-files': dirs})
-
-
-# @login_required
-# def upload_user_file(request):
-# username = request.user.username
-# input_file = request.FILES['file']
-# file_details = {}
-
-# # To avoid duplicate file names
-
-# if User_Files.objects.filter(file_name=input_file.name).exists():
-# resp = JsonResponse({'uploaded': False, 'error': "File already exists"})
-# resp.status_code = 400
-# return resp
-
-# else:
-
-# data_product = datastore.save_user(username, input_file)
-# data_product_uri = request.airavata_client.registerDataProduct(
-# request.authz_token, data_product)
-# d = User_Files(file_name=input_file.name, file_dpu=data_product_uri)
-# d.save()
-# file_details['file_name'] = d.file_name
-# file_details['file_dpu'] = d.file_dpu
-# return JsonResponse({'uploaded': True,
-# 'upload-file': file_details})
-
-
-# @login_required
-# def delete_user_file(request):
-# data_product_uri = request.body.decode('utf-8')
-# try:
-# data_product = request.airavata_client.getDataProduct(
-# request.authz_token, data_product_uri)
-
-# except Exception as e:
-# log.warning("Failed to load DataProduct for {}"
-# .format(data_product_uri), exc_info=True)
-# raise Http404("data product does not exist")(e)
-
-# # remove file_details entry from database and delete from datastore
-# User_Files.objects.filter(file_dpu=data_product_uri).delete()
-# datastore.delete(data_product)
-
-# return JsonResponse({'deleted': True})
-
@login_required
def upload_input_file(request):
@@ -1390,32 +1330,21 @@ class UserStoragePathView(APIView):
serializer_class = serializers.UserStoragePathSerializer
def get(self, request, path="/", format=None):
- # TODO: don't need to relativize path any longer?
- user_storage_path = path
- if user_storage_path.startswith("/"):
- user_storage_path = "." + user_storage_path
- # TODO: check if path is directory or file
return self._create_response(request, path)
def post(self, request, path="/", format=None):
- user_storage_path = path
- if user_storage_path.startswith("/"):
- user_storage_path = "." + user_storage_path
- if not data_products_helper.dir_exists(request, user_storage_path):
- data_products_helper.create_user_dir(request, user_storage_path)
+ if not data_products_helper.dir_exists(request, path):
+ data_products_helper.create_user_dir(request, path)
data_product = None
if 'file' in request.FILES:
user_file = request.FILES['file']
data_product = data_products_helper.save(
- request, user_storage_path, user_file)
+ request, path, user_file)
return self._create_response(request, path, uploaded=data_product)
def delete(self, request, path="/", format=None):
- user_storage_path = path
- if user_storage_path.startswith("/"):
- user_storage_path = "." + user_storage_path
- data_products_helper.delete_dir(request, user_storage_path)
+ data_products_helper.delete_dir(request, path)
return Response(status=204)
def _create_response(self, request, path, uploaded=None):
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/project/AddFileButton.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/project/AddFileButton.vue
deleted file mode 100644
index 2bab8d7..0000000
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/project/AddFileButton.vue
+++ /dev/null
@@ -1,136 +0,0 @@
-<template>
- <div>
- <b-btn v-b-modal="'modal-add-file'" variant="primary" @click="getUserFiles">
- <slot>
- Add Files <i class="fa fa-plus" aria-hidden="true"></i>
- </slot>
- </b-btn>
-
- <b-modal id="modal-add-file" scrollable hide-footer title="User Files" ref="modalAddFile">
-
- <b-form-checkbox
- v-model="selected"
- v-for="userfile in userfiles"
- :key="userfile.file_dpu"
- :value="userfile.file_dpu">
-
- <label class="file-option">{{ userfile.file_name}}</label>
-
- </b-form-checkbox>
-
- <footer id="modal-add-file___BV_modal_footer_" class="modal-footer">
-
- <div class="upload-btn-wrapper">
-
- <b-btn class="upload_btn" variant="success">Upload</b-btn>
-
- <input type="file" id="file" class="inputfile" ref="file" multiple v-on:change="handleFileUpload()"/>
-
- </div>
-
- <b-btn variant="danger" @click="handleFileDelete">Delete</b-btn>
- <b-btn variant="primary" @click="closeModal">Close</b-btn>
-
- </footer>
-
- </b-modal>
- </div>
-</template>
-
-<script>
-
-import { utils as apiUtils } from "django-airavata-api";
-
- export default {
- name: 'add-file-button',
- data () {
- return {
- userfiles:[],
- selected: [],
- files:'',
- value:''
-
- }
- },
- components: {
- },
- methods: {
- handleFileUpload(){
-
- //multiple file upload
-
- for (const entry of this.$refs.file.files) {
-
- let formData=new FormData();
- formData.append('file',entry);
- apiUtils.FetchUtils.post(
- "/api/upload-ufiles",
- formData
- ).then(res => (this.userfiles.push(res['file_details'])));
-
- }
-
- window.location.reload()
-
- },
-
- handleFileDelete: function () {
-
-
- //post to delete multiple user files
-
- for (const entry of this.selected) {
-
- apiUtils.FetchUtils.post(
- "/api/delete-ufiles",
- entry
- ).then(res => (this.value = res['deleted']));
-
- }
-
- window.location.reload()
-
- },
- getUserFiles(){
- return apiUtils.FetchUtils.get(
- "/api/get-ufiles"
- ).then(res => (this.userfiles =res['user-files']));
-
- },
- closeModal(){
- this.$refs['modalAddFile'].hide()
- }
-
- },
- computed: {
-
- },
-
- }
-
-</script>
-
-<style scoped>
-
- .upload-btn-wrapper {
- position: relative;
- overflow: hidden;
- display: inline-block;
- }
-
- .upload-btn-wrapper input[type=file] {
- font-size: 100px;
- position: absolute;
- left: 0;
- top: 0;
- opacity: 0;
- }
-
- .modal-body {
- float: left;
- flex-flow: column;
- flex-direction: column;
- }
-
-
-</style>
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/ProjectListContainer.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/ProjectListContainer.vue
index 4567015..5ffd528 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/ProjectListContainer.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/ProjectListContainer.vue
@@ -6,7 +6,6 @@
</div>
<div id="col-new-project" class="col">
<project-button-new @new-project="onNewProject"/>
- <add-file-button class="mt-1"></add-file-button>
</div>
</div>
<div class="row">
@@ -29,7 +28,6 @@ import ProjectList from '../components/project/ProjectList.vue'
import { services } from 'django-airavata-api'
import { components as comps } from 'django-airavata-common-ui'
-import AddFileButton from "../components/project/AddFileButton";
export default {
props: ['initialProjectsData'],
@@ -42,7 +40,6 @@ export default {
components: {
'project-list': ProjectList,
'project-button-new': ProjectButtonNew,
- 'add-file-button':AddFileButton,
'pager': comps.Pager,
},