Exemple #1
0
def _save_or_update_json_response(cmd):
    try:
        budismo = cmd()
    except CommandExecutionException:
        return JsonResponse({'errors': cmd.errors})
    short_form=facade.budismo_short_form()
    return JsonResponse(short_form.fill_with_model(budismo))
Exemple #2
0
def index():
    cmd = facade.list_budismos_cmd()
    budismos = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    short_form = facade.budismo_short_form()

    def short_budismo_dict(budismo):
        budismo_dct = short_form.fill_with_model(budismo)
        budismo_dct['edit_path'] = router.to_path(edit_path, budismo_dct['id'])
        budismo_dct['delete_path'] = router.to_path(delete_path, budismo_dct['id'])
        return budismo_dct

    short_budismos = [short_budismo_dict(budismo) for budismo in budismos]
    context = {'budismos': short_budismos,
               'new_path': router.to_path(new)}
    return TemplateResponse(context)
Exemple #3
0
def index():
    cmd = facade.list_budismos_cmd()
    budismo_list = cmd()
    short_form=facade.budismo_short_form()
    budismo_short = [short_form.fill_with_model(m) for m in budismo_list]
    return JsonResponse(budismo_short)