Removed unused forms.
This commit is contained in:
parent
aa1550afe3
commit
cdd776c7b8
@ -19,8 +19,6 @@ from flask.ext.restful import Resource, fields, reqparse, marshal_with_field
|
|||||||
|
|
||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from forms.accounts import AccountForm
|
|
||||||
|
|
||||||
from accountant import session_scope, session_aware
|
from accountant import session_scope, session_aware
|
||||||
|
|
||||||
from . import auth
|
from . import auth
|
||||||
@ -154,27 +152,18 @@ class AccountResource(Resource):
|
|||||||
assert (id not in kwargs or kwargs.id is None
|
assert (id not in kwargs or kwargs.id is None
|
||||||
or kwargs.id == account_id)
|
or kwargs.id == account_id)
|
||||||
|
|
||||||
account_form = AccountForm()
|
try:
|
||||||
|
account = Account.get(session, account_id)
|
||||||
|
except NoResultFound:
|
||||||
|
return None, 404
|
||||||
|
|
||||||
if account_form.validate():
|
# SQLAlchemy objects ignore __dict__.update() with merge.
|
||||||
try:
|
for k, v in kwargs.items():
|
||||||
account = Account.get(session, account_id)
|
setattr(account, k, v)
|
||||||
except NoResultFound:
|
|
||||||
return None, 404
|
|
||||||
|
|
||||||
# SQLAlchemy objects ignore __dict__.update() with merge.
|
session.merge(account)
|
||||||
for k, v in kwargs.items():
|
|
||||||
setattr(account, k, v)
|
|
||||||
|
|
||||||
session.merge(account)
|
return account
|
||||||
|
|
||||||
return account
|
|
||||||
else:
|
|
||||||
return json.dumps({
|
|
||||||
'ok': False,
|
|
||||||
'error_type': 'validation',
|
|
||||||
'errors': account_form.errors
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(AccountListResource, '/accounts')
|
api_api.add_resource(AccountListResource, '/accounts')
|
||||||
|
@ -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()
|
|
Loading…
Reference in New Issue
Block a user