biweeklybudget.flaskapp.views.ofx module

class biweeklybudget.flaskapp.views.ofx.OfxAccounts[source]

Bases: flask.views.MethodView

Handle GET /api/ofx/accounts endpoint.

This returns the JSON-ified return value from get_accounts() and will usually be called from get_accounts().

methods = {'GET'}
class biweeklybudget.flaskapp.views.ofx.OfxAjax[source]

Bases: biweeklybudget.flaskapp.views.searchableajaxview.SearchableAjaxView

Handle GET /ajax/ofx endpoint.

_filterhack(qs, s, args)[source]

DataTables 1.10.12 has built-in support for filtering based on a value in a specific column; when this is done, the filter value is set in columns[N][search][value] where N is the column number. However, the python datatables package used here only supports the global search[value] input, not the per-column one.

However, the DataTable search is implemented by passing a callable to table.searchable() which takes two arguments, the current Query that’s being built, and the user’s search[value] input; this must then return a Query object with the search applied.

In python datatables 0.4.9, this code path is triggered on if callable(self.search_func) and search.get("value", None):

As such, we can “trick” the table to use per-column searching (currently only if global searching is not being used) by examining the per-column search values in the request, and setting the search function to one (this method) that uses those values instead of the global search[value].

  • qs (sqlalchemy.orm.query.Query) – Query currently being built
  • s (str) – user search value
  • args (dict) – args

Query with searching applied

Return type:



Render and return JSON response for GET /ajax/ofx

methods = {'GET'}
class biweeklybudget.flaskapp.views.ofx.OfxStatementPost[source]

Bases: flask.views.MethodView

Handle POST /api/ofx/statement endpoint.

This is a ReST API bridge between update_statement_ofx() on the client side and update_statement_ofx() on the server side.

methods = {'POST'}

Handle POST to /api/ofx/statement (from update_statement_ofx()) to upload a new OFX Statement (via update_statement_ofx()).

The POSTed JSON should have the following keys:

  • acct_id (int) the Account ID the Statement is for
  • mtime (str) base64-encoded, pickled representation of the file modification time of the OFX file
  • filename (str) the file name of the OFX file
  • ofx (str) base64-encoded, pickled representation of the ofxparse.ofxparse.Ofx instance representing the Statement

Returns a JSON object with the following fields:

  • success (bool) whether the operation was successful
  • message (str) message describing success or error message

For successful operations, the JSON object will contain the following additional fields:

  • count_new (int) count of new transactions added
  • count_updated (int) count of transactions updated
  • statement_id (int) ID of the newly-added statement

HTTP Status Codes:

  • 201 - Statement successfully added
  • 500 - DuplicateFileException
  • 400 - Any other error/exception
class biweeklybudget.flaskapp.views.ofx.OfxTransAjax[source]

Bases: flask.views.MethodView

Handle GET /ajax/ofx/<int:acct_id>/<str:fitid> endpoint.

get(acct_id, fitid)[source]
methods = {'GET'}
class biweeklybudget.flaskapp.views.ofx.OfxTransView[source]

Bases: flask.views.MethodView

Render the GET /ofx/<int:acct_id>/<str:fitid> view using the ofx.html template.

get(acct_id, fitid)[source]
methods = {'GET'}
class biweeklybudget.flaskapp.views.ofx.OfxView[source]

Bases: flask.views.MethodView

Render the GET /ofx view using the ofx.html template.

methods = {'GET'}