def _save_or_update_json_response(cmd): try: autoajuda = cmd() except CommandExecutionException: return JsonResponse({'errors': cmd.errors}) short_form=facade.autoajuda_short_form() return JsonResponse(short_form.fill_with_model(autoajuda))
def index(): cmd = facade.list_autoajudas_cmd() autoajudas = cmd() edit_path = router.to_path(edit) delete_path = router.to_path(delete) short_form = facade.autoajuda_short_form() def short_autoajuda_dict(autoajuda): autoajuda_dct = short_form.fill_with_model(autoajuda) autoajuda_dct['edit_path'] = router.to_path(edit_path, autoajuda_dct['id']) autoajuda_dct['delete_path'] = router.to_path(delete_path, autoajuda_dct['id']) return autoajuda_dct short_autoajudas = [short_autoajuda_dict(autoajuda) for autoajuda in autoajudas] context = {'autoajudas': short_autoajudas, 'new_path': router.to_path(new)} return TemplateResponse(context)
def index(): cmd = facade.list_autoajudas_cmd() autoajuda_list = cmd() short_form=facade.autoajuda_short_form() autoajuda_short = [short_form.fill_with_model(m) for m in autoajuda_list] return JsonResponse(autoajuda_short)