def _save_or_update_json_response(cmd): try: clothing = cmd() except CommandExecutionException: return JsonResponse({'errors': cmd.errors}) short_form=facade.clothing_short_form() return JsonResponse(short_form.fill_with_model(clothing))
def index(): cmd = facade.list_clothings_cmd() clothings = cmd() edit_path = router.to_path(edit) delete_path = router.to_path(delete) short_form = facade.clothing_short_form() def short_clothing_dict(clothing): clothing_dct = short_form.fill_with_model(clothing) clothing_dct['edit_path'] = router.to_path(edit_path, clothing_dct['id']) clothing_dct['delete_path'] = router.to_path(delete_path, clothing_dct['id']) return clothing_dct short_clothings = [short_clothing_dict(clothing) for clothing in clothings] context = {'clothings': short_clothings, 'new_path': router.to_path(new)} return TemplateResponse(context)
def index(): cmd = facade.list_clothings_cmd() clothing_list = cmd() short_form=facade.clothing_short_form() clothing_short = [short_form.fill_with_model(m) for m in clothing_list] return JsonResponse(clothing_short)