def _save_or_update_json_response(cmd): try: categoria = cmd() except CommandExecutionException: return JsonResponse({'errors': cmd.errors}) short_form=facade.categoria_short_form() return JsonResponse(short_form.fill_with_model(categoria))
def index(): cmd = facade.list_categorias_cmd() categorias = cmd() edit_path = router.to_path(edit) delete_path = router.to_path(delete) short_form = facade.categoria_short_form() def short_categoria_dict(categoria): categoria_dct = short_form.fill_with_model(categoria) categoria_dct['edit_path'] = router.to_path(edit_path, categoria_dct['id']) categoria_dct['delete_path'] = router.to_path(delete_path, categoria_dct['id']) return categoria_dct short_categorias = [short_categoria_dict(categoria) for categoria in categorias] context = {'categorias': short_categorias, 'new_path': router.to_path(new)} return TemplateResponse(context)
def index(): cmd = facade.list_categorias_cmd() categoria_list = cmd() short_form=facade.categoria_short_form() categoria_short = [short_form.fill_with_model(m) for m in categoria_list] return JsonResponse(categoria_short)