diff --git a/templates/account.html b/templates/account.html index a3061e0..b6272e0 100644 --- a/templates/account.html +++ b/templates/account.html @@ -29,4 +29,10 @@ {% else %}
This account does not have any transactions yet
{% endif %} + {% endblock %} diff --git a/vanth/pages/accounts.py b/vanth/pages/accounts.py index 723fe68..fc45523 100644 --- a/vanth/pages/accounts.py +++ b/vanth/pages/accounts.py @@ -1,10 +1,14 @@ +import logging + import flask +import werkzeug.utils import vanth.celery import vanth.pages.tools import vanth.platform.ofxaccount import vanth.platform.ofxsource +LOGGER = logging.getLogger() blueprint = flask.Blueprint('accounts', __name__) @blueprint.route('/accounts/', methods=['GET']) @@ -40,3 +44,18 @@ def post_account(arguments): def post_update(arguments): vanth.celery.update_account.delay(**arguments) return flask.redirect('/accounts/') + +@blueprint.route('/transactions/', methods=['POST']) +@vanth.pages.tools.parse({ + 'account_uuid' : str, +}) +def post_transactions(arguments): + if 'transactions' not in flask.request.files: + return flask.render_template('error.html', error="You did not include the content of the file in your upload") + transactions = flask.request.files['transactions'] + if transactions.filename == '': + return flask.redirect('/accounts/{}/'.format(arguments['account_uuid'])) + filename = werkzeug.utils.secure_filename(transactions.filename) + LOGGER.info("Saving uploaded file %s to %s", transactions.filename, filename) + transactions.save(filename) + return flask.redirect('/accounts/{}/'.format(arguments['account_uuid']))