- Add dynamic fields to DocumentVersion in case the Catalog requires it.
This commit is contained in:
@@ -43,6 +43,9 @@ upload_parser.add_argument('valid_from', location='form', type=validate_date, re
|
||||
help='Valid from date for the document (ISO format)')
|
||||
upload_parser.add_argument('user_metadata', location='form', type=validate_json, required=False,
|
||||
help='User metadata for the document (JSON format)')
|
||||
upload_parser.add_argument('catalog_properties', location='form', type=validate_json, required=False,
|
||||
help='The catalog configuration to be passed along (JSON format). Validity is against catalog requirements '
|
||||
'is not checked, and is the responsibility of the calling client.')
|
||||
|
||||
add_document_response = document_ns.model('AddDocumentResponse', {
|
||||
'message': fields.String(description='Status message'),
|
||||
@@ -82,6 +85,7 @@ class AddDocument(Resource):
|
||||
'user_context': args.get('user_context'),
|
||||
'valid_from': args.get('valid_from'),
|
||||
'user_metadata': args.get('user_metadata'),
|
||||
'catalog_properties': args.get('catalog_properties'),
|
||||
}
|
||||
|
||||
new_doc, new_doc_vers = create_document_stack(api_input, file, filename, extension, tenant_id)
|
||||
@@ -111,7 +115,11 @@ add_url_model = document_ns.model('AddURL', {
|
||||
'user_context': fields.String(required=False, description='User context for the document'),
|
||||
'valid_from': fields.String(required=False, description='Valid from date for the document'),
|
||||
'user_metadata': fields.String(required=False, description='User metadata for the document'),
|
||||
'system_metadata': fields.String(required=False, description='System metadata for the document')
|
||||
'system_metadata': fields.String(required=False, description='System metadata for the document'),
|
||||
'catalog_properties': fields.String(required=False, description='The catalog configuration to be passed along (JSON '
|
||||
'format). Validity is against catalog requirements '
|
||||
'is not checked, and is the responsibility of the '
|
||||
'calling client.'),
|
||||
})
|
||||
|
||||
add_url_response = document_ns.model('AddURLResponse', {
|
||||
@@ -148,6 +156,7 @@ class AddURL(Resource):
|
||||
'user_context': args.get('user_context'),
|
||||
'valid_from': args.get('valid_from'),
|
||||
'user_metadata': args.get('user_metadata'),
|
||||
'catalog_properties': args.get('catalog_properties'),
|
||||
}
|
||||
|
||||
new_doc, new_doc_vers = create_document_stack(api_input, file_content, filename, extension, tenant_id)
|
||||
@@ -227,6 +236,7 @@ class DocumentResource(Resource):
|
||||
|
||||
edit_document_version_model = document_ns.model('EditDocumentVersion', {
|
||||
'user_context': fields.String(required=True, description='New user context for the document version'),
|
||||
'catalog_properties': fields.String(required=True, description='New catalog properties for the document version'),
|
||||
})
|
||||
|
||||
|
||||
@@ -239,7 +249,7 @@ class DocumentVersionResource(Resource):
|
||||
def put(self, version_id):
|
||||
"""Edit a document version"""
|
||||
data = request.json
|
||||
updated_version, error = edit_document_version(version_id, data['user_context'])
|
||||
updated_version, error = edit_document_version(version_id, data['user_context'], data.get('catalog_properties'))
|
||||
if updated_version:
|
||||
return {'message': f'Document Version {updated_version.id} updated successfully'}, 200
|
||||
else:
|
||||
@@ -251,7 +261,8 @@ refresh_document_model = document_ns.model('RefreshDocument', {
|
||||
'name': fields.String(required=False, description='New name for the document'),
|
||||
'language': fields.String(required=False, description='Language of the document'),
|
||||
'user_context': fields.String(required=False, description='User context for the document'),
|
||||
'user_metadata': fields.Raw(required=False, description='User metadata for the document')
|
||||
'user_metadata': fields.Raw(required=False, description='User metadata for the document'),
|
||||
'catalog_properties': fields.Raw(required=False, description='Catalog properties for the document'),
|
||||
})
|
||||
|
||||
|
||||
@@ -268,7 +279,7 @@ class RefreshDocument(Resource):
|
||||
current_app.logger.info(f'Refreshing document {document_id} for tenant {tenant_id}')
|
||||
|
||||
try:
|
||||
new_version, result = refresh_document(document_id)
|
||||
new_version, result = refresh_document(document_id, tenant_id)
|
||||
|
||||
if new_version:
|
||||
return {
|
||||
@@ -301,7 +312,7 @@ class RefreshDocumentWithInfo(Resource):
|
||||
|
||||
try:
|
||||
api_input = request.json
|
||||
new_version, result = refresh_document_with_info(document_id, api_input)
|
||||
new_version, result = refresh_document_with_info(document_id, tenant_id, api_input)
|
||||
|
||||
if new_version:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user