mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-23 13:18:35 +00:00
Merge branch 'feature/update-task-data' of github.com:sartography/cr-connect-workflow into feature/update-task-data
This commit is contained in:
commit
b1a81957ef
@ -296,6 +296,12 @@ paths:
|
|||||||
description: The unique id of a study
|
description: The unique id of a study
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
|
- name: workflow_id
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: The unique id of a workflow instance
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
- name: task_id
|
- name: task_id
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
|
@ -23,6 +23,8 @@ def update_file_from_request(file_model):
|
|||||||
# Verify the extension
|
# Verify the extension
|
||||||
basename, file_extension = os.path.splitext(file.filename)
|
basename, file_extension = os.path.splitext(file.filename)
|
||||||
file_extension = file_extension.lower().strip()[1:]
|
file_extension = file_extension.lower().strip()[1:]
|
||||||
|
print('\n\n\n', 'file_extension = "%s"' % file_extension, '\n\n\n')
|
||||||
|
print('FileType._member_names_', FileType._member_names_)
|
||||||
if file_extension not in FileType._member_names_:
|
if file_extension not in FileType._member_names_:
|
||||||
return ApiErrorSchema().dump(ApiError('unknown_extension',
|
return ApiErrorSchema().dump(ApiError('unknown_extension',
|
||||||
'The file you provided does not have an accepted extension:' +
|
'The file you provided does not have an accepted extension:' +
|
||||||
@ -36,10 +38,10 @@ def update_file_from_request(file_model):
|
|||||||
else:
|
else:
|
||||||
file_data_model.data = file.stream.read()
|
file_data_model.data = file.stream.read()
|
||||||
|
|
||||||
session.add(file_data_model)
|
session.add_all([file_model, file_data_model])
|
||||||
session.add(file_model)
|
|
||||||
session.commit()
|
session.commit()
|
||||||
session.flush() # Assure the id is set on the model before returning it.
|
session.flush() # Assure the id is set on the model before returning it.
|
||||||
|
return FileModelSchema().dump(file_model)
|
||||||
|
|
||||||
|
|
||||||
def get_files(workflow_spec_id=None, study_id=None, workflow_id=None, task_id=None):
|
def get_files(workflow_spec_id=None, study_id=None, workflow_id=None, task_id=None):
|
||||||
@ -73,16 +75,14 @@ def add_file(workflow_spec_id=None, study_id=None, workflow_id=None, task_id=Non
|
|||||||
workflow_id=workflow_id,
|
workflow_id=workflow_id,
|
||||||
task_id=task_id
|
task_id=task_id
|
||||||
)
|
)
|
||||||
update_file_from_request(file_model)
|
return update_file_from_request(file_model)
|
||||||
return FileModelSchema().dump(file_model)
|
|
||||||
|
|
||||||
|
|
||||||
def update_file_data(file_id):
|
def update_file_data(file_id):
|
||||||
file_model = session.query(FileModel).filter_by(id=file_id).with_for_update().first()
|
file_model = session.query(FileModel).filter_by(id=file_id).with_for_update().first()
|
||||||
if file_model is None:
|
if file_model is None:
|
||||||
return ApiErrorSchema().dump(ApiError('no_such_file', 'The file id you provided does not exist')), 404
|
return ApiErrorSchema().dump(ApiError('no_such_file', 'The file id you provided does not exist')), 404
|
||||||
update_file_from_request(file_model)
|
return update_file_from_request(file_model)
|
||||||
return FileModelSchema().dump(file_model)
|
|
||||||
|
|
||||||
|
|
||||||
def get_file_data(file_id):
|
def get_file_data(file_id):
|
||||||
|
@ -9,9 +9,16 @@ from crc import db
|
|||||||
|
|
||||||
class FileType(enum.Enum):
|
class FileType(enum.Enum):
|
||||||
bpmn = "bpmm"
|
bpmn = "bpmm"
|
||||||
svg = "svg"
|
|
||||||
dmn = "dmn"
|
dmn = "dmn"
|
||||||
# docx = "docx"
|
docx = "docx"
|
||||||
|
gif = 'gif'
|
||||||
|
jpg = 'jpg'
|
||||||
|
pdf = 'pdf'
|
||||||
|
png = 'png'
|
||||||
|
svg = "svg"
|
||||||
|
xlsx = 'xlsx'
|
||||||
|
zip = 'zip'
|
||||||
|
image = 'image'
|
||||||
|
|
||||||
|
|
||||||
class FileDataModel(db.Model):
|
class FileDataModel(db.Model):
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""empty message
|
"""empty message
|
||||||
|
|
||||||
Revision ID: 8db96620031b
|
Revision ID: f9c4e92a8afe
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2020-02-04 09:54:36.297614
|
Create Date: 2020-02-04 12:49:57.265041
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '8db96620031b'
|
revision = 'f9c4e92a8afe'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
@ -51,7 +51,7 @@ def upgrade():
|
|||||||
sa.Column('name', sa.String(), nullable=True),
|
sa.Column('name', sa.String(), nullable=True),
|
||||||
sa.Column('version', sa.Integer(), nullable=True),
|
sa.Column('version', sa.Integer(), nullable=True),
|
||||||
sa.Column('last_updated', sa.DateTime(timezone=True), nullable=True),
|
sa.Column('last_updated', sa.DateTime(timezone=True), nullable=True),
|
||||||
sa.Column('type', sa.Enum('bpmn', 'svg', 'dmn', name='filetype'), nullable=True),
|
sa.Column('type', sa.Enum('bpmn', 'dmn', 'docx', 'gif', 'jpg', 'pdf', 'png', 'svg', 'xlsx', 'zip', 'image', name='filetype'), nullable=True),
|
||||||
sa.Column('primary', sa.Boolean(), nullable=True),
|
sa.Column('primary', sa.Boolean(), nullable=True),
|
||||||
sa.Column('content_type', sa.String(), nullable=True),
|
sa.Column('content_type', sa.String(), nullable=True),
|
||||||
sa.Column('workflow_spec_id', sa.String(), nullable=True),
|
sa.Column('workflow_spec_id', sa.String(), nullable=True),
|
Loading…
x
Reference in New Issue
Block a user