async def index(request): request_dict = RequestSanicDict(request) data = request_dict.parse_all_to_dict() request_object = ProductListRequestObject.from_dict(data) repo = ProductRepositoryOrator(db=request.app.db) use_case = ProductListUseCase(repo=repo) response = use_case.execute(request_object=request_object) template = request.app.env.get_template('index.html') html_content = template.render(response=response.value, app=request.app) return html(html_content)
async def detail(request, identifier): request_dict = RequestSanicDict(request) data = request_dict.parse_all_to_dict() data["id"] = identifier request_object = ProductDetailRequestObject.from_dict(data) repo = ProductRepositoryOrator(db=request.app.db) use_case = ProductDetailUseCase(repo=repo) response = use_case.execute(request_object=request_object) template = request.app.env.get_template('detail-product.html') html_content = template.render(app=request.app, item=response.value) return html(html_content)
async def index(request): request_dict = RequestSanicDict(request) validator = JSONSchemaValidator() adict = request_dict.query_to_dict() adict = validator.get_default_param(adict) repo_init = _init_repo(db_manager=request.app.db, tracer=request.app.tracer) use_cases = ListAllAreaUsecase(repo=repo_init) request_object = ListAllAreaRequestObject.from_dict(adict, validator=validator) response_object = await use_cases.execute(request_object) return json(response_object.value, status=Config.STATUS_CODES[response_object.type])
async def index(request): request_dict = RequestSanicDict(request) validator = JSONSchemaValidator() adict = request_dict.query_to_dict() adict = validator.get_default_param(adict) repo_init = _init_repo(db_manager=request.app.db_orator) use_cases = ListExpeditionUsecase(repo=repo_init) request_object = ListAreaRequestObject.from_dict(adict, validator=validator) response_object = use_cases.execute(request_object) print("*************SYNC*******************") print(response_object.type) print(response_object.value['message']) print("*************SYNC***************") return json(response_object.value, status=Config.STATUS_CODES[response_object.type])
async def index(request): request_dict = RequestSanicDict(request) validator = JSONSchemaValidator() adict = request_dict.query_to_dict() adict = validator.get_default_param(adict) repo_init = AreaRepositoryPSQL(db=request.app.db, tracer=request.app.tracer) use_cases = ListAllOnlyAreaUsecase(repo=repo_init) request_object = ListAllAreaRequestObject.from_dict(adict, validator=validator) response_object = await use_cases.execute(request_object) print("==============ASYNC===============") print(response_object.type) print(response_object.value['message']) print("==============ASYNC===============") return json(response_object.value, status=Config.STATUS_CODES[response_object.type])
async def add(request): flash = dict() request_dict = RequestSanicDict(request) if request.method == 'POST': data = request_dict.parse_all_to_dict() request_object = ProductCreateRequestObject.from_dict(data) repo = ProductRepositoryOrator(db=request.app.db) use_case = ProductCreateUseCase(repo=repo) response = use_case.execute(request_object=request_object) if response.type == 'SUCCESS': return redirect(request.app.url_for("productsV1.index")) flash = { 'icon': 'danger', 'title': 'Errors!', 'message': response.message } template = request.app.env.get_template('add-product.html') html_content = template.render(app=request.app, flash=flash) return html(html_content)