def validate_document_data(request, **kwargs): context = request.context if 'documents' in request.context else request.context.__parent__ model = type(context).documents.model_class data = validate_data(request, model, "document") document = request.validated['document'] if document.documentType not in (model._document_types_url_only + model._document_types_offline): check_document(request, request.validated['document'], 'body') first_document = get_first_document(request) if first_document: set_first_document_fields(request, first_document, document) if not document.documentOf: document.documentOf = get_type(context).__name__.lower() if document.documentType not in (model._document_types_url_only + model._document_types_offline): document_route = request.matched_route.name.replace("collection_", "") document = update_document_url(request, document, document_route, {}) request.validated['document'] = document return data
def validate_item_data(request, error_handler, **kwargs): update_logging_context(request, {'item_id': '__new__'}) context = request.context if 'items' in request.context else request.context.__parent__ model = type(context).items.model_class validate_data(request, model, "item")