Skip to content

Commit

Permalink
Merge pull request #219 from sennetconsortium/libpitt/205-collections
Browse files Browse the repository at this point in the history
Add simple blueprint collections/attributes to handle TSV uploads - #205
  • Loading branch information
maxsibilla authored Dec 7, 2023
2 parents 83d422c + 3cc39f0 commit aa36d29
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/routes/entity_CRUD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from lib import get_globus_url
from lib.datacite_doi_helper import DataCiteDoiHelper
from lib.neo4j_helper import Neo4jHelper

from routes.validation import set_file_details

entity_CRUD_blueprint = Blueprint('entity_CRUD', __name__)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1176,6 +1176,32 @@ def upload_data_status():
return jsonify(results)


@entity_CRUD_blueprint.route('/collections/attributes', methods=['POST'])
def collections_attributes():
result: dict = {
'error': None
}
if is_json_request():
data = request.json
else:
data = request.values

attribute = data.get('attribute')

file_upload = check_upload(attribute)
if file_upload.get('code') is StatusCodes.OK:
file = file_upload.get('description')
file_id = file.get('id')
file = file.get('file')
pathname = file_id + os.sep + file.filename
result = set_file_details(pathname)
records = get_csv_records(result.get('fullpath'))
return rest_response(StatusCodes.OK, 'Collection Attributes',
records, False)
else:
return json.dumps(file_upload)


def _get_status_code__by_priority(codes):
if StatusCodes.SERVER_ERR in codes:
return StatusCodes.SERVER_ERR
Expand Down

0 comments on commit aa36d29

Please sign in to comment.