示例#1
0
def _save_or_update_json_response(cmd, _resp):
    try:
        venda = cmd()
    except CommandExecutionException:
        _resp.status_code = 500
        return JsonResponse(cmd.errors)
    venda_form = venda_facade.venda_form()
    return JsonResponse(venda_form.fill_with_model(venda))
示例#2
0
def index(venda_id):
    venda = venda_facade.get_venda_cmd(venda_id)()
    venda_form = venda_facade.venda_form()
    context = {
        'save_path': router.to_path(save, venda_id),
        'venda': venda_form.fill_with_model(venda)
    }
    return TemplateResponse(context, 'vendas/venda_form.html')
示例#3
0
def _save_or_update_json_response(cmd, _resp):
    try:
        venda = cmd()
    except CommandExecutionException:
        _resp.status_code = 500
        return JsonResponse(cmd.errors)
    venda_form = venda_facade.venda_form()
    return JsonResponse(venda_form.fill_with_model(venda))
示例#4
0
def index():
    cmd = venda_facade.list_vendas_cmd()
    vendas = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    venda_form = venda_facade.venda_form()

    def localize_venda(venda):
        venda_dct = venda_form.fill_with_model(venda)
        venda_dct['edit_path'] = router.to_path(edit_path, venda_dct['id'])
        venda_dct['delete_path'] = router.to_path(delete_path, venda_dct['id'])
        return venda_dct

    localized_vendas = [localize_venda(venda) for venda in vendas]
    context = {'vendas': localized_vendas, 'new_path': router.to_path(new)}
    return TemplateResponse(context, 'vendas/venda_home.html')
示例#5
0
def index():
    cmd = venda_facade.list_vendas_cmd()
    vendas = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    venda_form = venda_facade.venda_form()

    def localize_venda(venda):
        venda_dct = venda_form.fill_with_model(venda)
        venda_dct['edit_path'] = router.to_path(edit_path, venda_dct['id'])
        venda_dct['delete_path'] = router.to_path(delete_path, venda_dct['id'])
        return venda_dct

    localized_vendas = [localize_venda(venda) for venda in vendas]
    context = {'vendas': localized_vendas,
               'new_path': router.to_path(new)}
    return TemplateResponse(context, 'vendas/venda_home.html')
示例#6
0
def index(venda_id):
    venda = venda_facade.get_venda_cmd(venda_id)()
    venda_form = venda_facade.venda_form()
    context = {'save_path': router.to_path(save, venda_id), 'venda': venda_form.fill_with_model(venda)}
    return TemplateResponse(context, 'vendas/venda_form.html')
示例#7
0
def index():
    cmd = venda_facade.list_vendas_cmd()
    venda_list = cmd()
    venda_form = venda_facade.venda_form()
    venda_dcts = [venda_form.fill_with_model(m) for m in venda_list]
    return JsonResponse(venda_dcts)
示例#8
0
def index():
    cmd = venda_facade.list_vendas_cmd()
    venda_list = cmd()
    venda_form = venda_facade.venda_form()
    venda_dcts = [venda_form.fill_with_model(m) for m in venda_list]
    return JsonResponse(venda_dcts)