def _save_or_update_json_response(cmd): try: artigo = cmd() except CommandExecutionException: return JsonResponse({'errors': cmd.errors}) short_form=facade.artigo_short_form() return JsonResponse(short_form.fill_with_model(artigo))
def index(): cmd = facade.list_artigos_cmd() artigos = cmd() edit_path = router.to_path(edit) delete_path = router.to_path(delete) short_form = facade.artigo_short_form() def short_artigo_dict(artigo): artigo_dct = short_form.fill_with_model(artigo) artigo_dct['edit_path'] = router.to_path(edit_path, artigo_dct['id']) artigo_dct['delete_path'] = router.to_path(delete_path, artigo_dct['id']) return artigo_dct short_artigos = [short_artigo_dict(artigo) for artigo in artigos] context = {'artigos': short_artigos, 'new_path': router.to_path(new)} return TemplateResponse(context)
def index(): cmd = facade.list_artigos_cmd() artigo_list = cmd() short_form=facade.artigo_short_form() artigo_short = [short_form.fill_with_model(m) for m in artigo_list] return JsonResponse(artigo_short)