diff --git a/templates/accounts.html b/templates/accounts.html index 6e64ee2..c719ca9 100644 --- a/templates/accounts.html +++ b/templates/accounts.html @@ -21,11 +21,13 @@ Name Institution - - User ID - + + User ID + Password + Account ID + Account Type Checking diff --git a/vanth/pages/accounts.py b/vanth/pages/accounts.py index 1d0f67e..96a2935 100644 --- a/vanth/pages/accounts.py +++ b/vanth/pages/accounts.py @@ -13,12 +13,21 @@ def get_accounts(): @blueprint.route('/account/', methods=['POST']) def post_account(): + account_id = flask.request.form.get('account_id') account_type = flask.request.form.get('account_type') institution = flask.request.form.get('institution') name = flask.request.form.get('name') password = flask.request.form.get('password') - userid = flask.request.form.get('userid') + user_id = flask.request.form.get('user_id') - vanth.platform.ofxaccount.create(flask.session['user_id'], name, account_type, institution, password, userid) + vanth.platform.ofxaccount.create({ + 'owner' : flask.session['user_id'], + 'account_id' : account_id, + 'institution' : institution, + 'name' : name, + 'password' : password, + 'type' : account_type, + 'user_id' : user_id, + }) return flask.redirect('/accounts/') diff --git a/vanth/platform/ofxaccount.py b/vanth/platform/ofxaccount.py index 2b1bf95..3b00b44 100644 --- a/vanth/platform/ofxaccount.py +++ b/vanth/platform/ofxaccount.py @@ -31,22 +31,14 @@ def get(user_id): 'uuid' : result[vanth.tables.OFXAccount.c.uuid], } for result in results] -def create(user_id, name, account_type, institution, password, account_user): +def create(values): engine = chryso.connection.get() - source_name = sqlalchemy.select([ + values['source'] = sqlalchemy.select([ vanth.tables.OFXSource.c.uuid - ]).where(vanth.tables.OFXSource.c.name == institution) + ]).where(vanth.tables.OFXSource.c.name == values.pop('institution')) - _uuid = uuid.uuid4() - statement = vanth.tables.OFXAccount.insert().values( # pylint: disable=no-value-for-parameter - uuid = _uuid, - name = name, - user_id = account_user, - password = password, - type = account_type, - source = source_name, - owner = user_id, - ) + values['uuid'] = uuid.uuid4() + statement = vanth.tables.OFXAccount.insert().values(**values) # pylint: disable=no-value-for-parameter engine.execute(statement) - return _uuid + return values['uuid']