Example #1
0
def _save_or_update_json_response(cmd, _resp):
    try:
        curso = cmd()
    except CommandExecutionException:
        _resp.status_code = 500
        return JsonResponse(cmd.errors)
    curso_form = curso_facade.curso_form()
    return JsonResponse(curso_form.fill_with_model(curso))
Example #2
0
def index():
    cmd = curso_facade.list_cursos_cmd()
    cursos = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    curso_form = curso_facade.curso_form()

    def localize_curso(curso):
        curso_dct = curso_form.fill_with_model(curso)
        curso_dct['edit_path'] = router.to_path(edit_path, curso_dct['id'])
        curso_dct['delete_path'] = router.to_path(delete_path, curso_dct['id'])
        return curso_dct

    localized_cursos = [localize_curso(curso) for curso in cursos]
    context = {'cursos': localized_cursos,
               'new_path': router.to_path(new)}
    return TemplateResponse(context, 'cursos/curso_home.html')
Example #3
0
def index():
    cmd = curso_facade.list_cursos_cmd()
    curso_list = cmd()
    curso_form = curso_facade.curso_form()
    curso_dcts = [curso_form.fill_with_model(m) for m in curso_list]
    return JsonResponse(curso_dcts)
Example #4
0
def index(curso_id):
    curso = curso_facade.get_curso_cmd(curso_id)()
    curso_form = curso_facade.curso_form()
    context = {'save_path': router.to_path(save, curso_id), 'curso': curso_form.fill_with_model(curso)}
    return TemplateResponse(context, 'cursos/curso_form.html')