def validate_file_transaction_upload(request, **kwargs): transaction = get_transaction_by_id(request) if not transaction: raise_operation_error(request, "Can't add document contract to nonexistent transaction", status=404) update_logging_context(request, {"document_id": "__new__"}) if request.registry.docservice_url and request.content_type == "application/json": model = type(transaction).documents.model_class return validate_data(request, model)
def post(self): """Contract Transaction Document Upload""" document = upload_file_to_transaction(self.request) _transaction = get_transaction_by_id(self.request) _transaction.documents.append(document) if save_contract(self.request): self.LOGGER.info( "Created contract transaction document {}".format(document.id), extra=context_unpack( self.request, {"MESSAGE_ID": "contract_transaction_document_create"}, {"document_id": document.id} ), ) self.request.response.status = 201 return {"data": document.serialize("view")}
def get(self): _transaction = get_transaction_by_id(self.request) return {'data': _transaction.serialize("view")}
def validate_transaction_existence(request, **kwargs): transaction = get_transaction_by_id(request) if not transaction: raise_operation_error(request, "Transaction does not exist", status=404)