diff --git a/api/controllers/fileUploader.py b/api/controllers/fileUploader.py index c9916f347..939f0125a 100644 --- a/api/controllers/fileUploader.py +++ b/api/controllers/fileUploader.py @@ -7,7 +7,8 @@ from api.models.user import User from api.schemas.file import ( FileSchema, - ManualFileSchema + ManualFileSchema, + CSVUploadSchema ) from flask import current_app as app from api.schemas.errors import UserNotFound @@ -81,10 +82,7 @@ def fileUpload(): file_upload = File(filename=csvName, filetype='csv', uploader=fetch_user) file_upload.save_to_db() - return jsonify( - Response(200).generateMessage({ - 'message': 'CSV Uploaded successfully', - 'unique_id': csvName})) + return jsonify(CSVUploadSchema().dump(file_upload).data) @router.route('/manual_data', methods=['POST']) diff --git a/api/schemas/file.py b/api/schemas/file.py index d721df341..2ec42fbab 100644 --- a/api/schemas/file.py +++ b/api/schemas/file.py @@ -38,3 +38,22 @@ class Meta: include_resource_linkage=True, type_='User' ) + + +class CSVUploadSchema(Schema): + class Meta: + type_ = 'csv-file' + self_view = 'fileUploader.fileUpload' + kwargs = {'id': ''} + + id = fields.Str(required=True, dump_only=True) + filename = fields.Str(required=True) + filetype = fields.Str(required=True) + user_id = fields.Relationship( + self_url='/api/upload/manual_data', + self_url_kwargs={'file_id': ''}, + related_url='/user/register', + related_url_kwargs={'id': ''}, + include_resource_linkage=True, + type_='User' + ) diff --git a/app.json b/app.json index 9efdfd659..e0e8acee3 100644 --- a/app.json +++ b/app.json @@ -23,9 +23,8 @@ } }, "addons": [ - "heroku-postgresql", { - "plan": "hobby-dev" + "plan": "heroku-postgresql" } ] } diff --git a/frontend/app/controllers/create-badges.js b/frontend/app/controllers/create-badges.js index cd860bf4f..eec65d9de 100644 --- a/frontend/app/controllers/create-badges.js +++ b/frontend/app/controllers/create-badges.js @@ -49,7 +49,7 @@ export default Controller.extend({ let csv_ = this.get('store').createRecord('csv-file', { uid, csvFile : csvData, - extension : '.csv' + extension : 'csv' }); csv_.save() .catch(err => { diff --git a/frontend/app/models/csv-file.js b/frontend/app/models/csv-file.js index 93f6a03cd..6e9b93e34 100644 --- a/frontend/app/models/csv-file.js +++ b/frontend/app/models/csv-file.js @@ -5,5 +5,6 @@ const { Model, attr } = DS; export default Model.extend({ uid : attr('string'), csvFile : attr('string'), - extension : attr('string') + extension : attr('string'), + filename : attr('string') }); diff --git a/frontend/app/models/cust-img-file.js b/frontend/app/models/cust-img-file.js index 6566af69d..6403f98d0 100644 --- a/frontend/app/models/cust-img-file.js +++ b/frontend/app/models/cust-img-file.js @@ -5,5 +5,6 @@ const { Model, attr } = DS; export default Model.extend({ uid : attr('string'), imageData : attr('string'), - extension : attr('string') + extension : attr('string'), + filename : attr('string') }); diff --git a/frontend/app/models/text-data.js b/frontend/app/models/text-data.js index cfae92a27..c78db8795 100644 --- a/frontend/app/models/text-data.js +++ b/frontend/app/models/text-data.js @@ -5,5 +5,6 @@ const { Model, attr } = DS; export default Model.extend({ uid : attr('string'), manual_data : attr('string'), - time : attr('date') + time : attr('date'), + filename : attr('string') });