From cdd776c7b8044ddcc9df0b870e028c3e934850b7 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 12 Jun 2015 12:01:16 +0200 Subject: [PATCH] Removed unused forms. --- accountant/api/views/accounts.py | 29 +++++++++-------------------- forms/__init__.py | 0 forms/accounts.py | 9 --------- 3 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 forms/__init__.py delete mode 100644 forms/accounts.py diff --git a/accountant/api/views/accounts.py b/accountant/api/views/accounts.py index 21df50f..71e012e 100644 --- a/accountant/api/views/accounts.py +++ b/accountant/api/views/accounts.py @@ -19,8 +19,6 @@ from flask.ext.restful import Resource, fields, reqparse, marshal_with_field from sqlalchemy.orm.exc import NoResultFound -from forms.accounts import AccountForm - from accountant import session_scope, session_aware from . import auth @@ -154,27 +152,18 @@ class AccountResource(Resource): assert (id not in kwargs or kwargs.id is None or kwargs.id == account_id) - account_form = AccountForm() + try: + account = Account.get(session, account_id) + except NoResultFound: + return None, 404 - if account_form.validate(): - try: - account = Account.get(session, account_id) - except NoResultFound: - return None, 404 + # SQLAlchemy objects ignore __dict__.update() with merge. + for k, v in kwargs.items(): + setattr(account, k, v) - # SQLAlchemy objects ignore __dict__.update() with merge. - for k, v in kwargs.items(): - setattr(account, k, v) + session.merge(account) - session.merge(account) - - return account - else: - return json.dumps({ - 'ok': False, - 'error_type': 'validation', - 'errors': account_form.errors - }) + return account api_api.add_resource(AccountListResource, '/accounts') diff --git a/forms/__init__.py b/forms/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/forms/accounts.py b/forms/accounts.py deleted file mode 100644 index 3bb40da..0000000 --- a/forms/accounts.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask_wtf import Form -from wtforms import DecimalField, IntegerField, StringField - -class AccountIdForm(Form): - id = IntegerField() - -class AccountForm(AccountIdForm): - name = StringField() - authorized_overdraft = DecimalField()