biweeklybudget.flaskapp.views.projects module

class biweeklybudget.flaskapp.views.projects.BoMItemAjax[source]

Bases: flask.views.MethodView

Render the GET /ajax/projects/bom_item/<int:id> JSON view.

get(id)[source]
methods = {'GET'}
class biweeklybudget.flaskapp.views.projects.BoMItemFormHandler[source]

Bases: biweeklybudget.flaskapp.views.formhandlerview.FormHandlerView

Handle POST /forms/bom_item

methods = {'POST'}
submit(data)[source]

Handle form submission; create or update models in the DB. Raises an Exception for any errors.

Parameters:data (dict) – submitted form data
Returns:message describing changes to DB (i.e. link to created record)
Return type:str
validate(data)[source]

Validate the form data. Return None if it is valid, or else a hash of field names to list of error strings for each field.

Parameters:data (dict) – submitted form data
Returns:None if no errors, or hash of field name to errors for that field
class biweeklybudget.flaskapp.views.projects.BoMItemView[source]

Bases: flask.views.MethodView

Render the GET /project/<int:project_id> view using the bomitem.html template.

get(project_id)[source]
methods = {'GET'}
class biweeklybudget.flaskapp.views.projects.BoMItemsAjax[source]

Bases: biweeklybudget.flaskapp.views.searchableajaxview.SearchableAjaxView

Handle GET /ajax/projects/<int:project_id>/bom_items 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].

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

Query with searching applied

Return type:

sqlalchemy.orm.query.Query

get(project_id)[source]

Render and return JSON response for GET /ajax/projects/<int:project_id>/bom_items

methods = {'GET'}
class biweeklybudget.flaskapp.views.projects.ProjectAjax[source]

Bases: flask.views.MethodView

Render the GET /ajax/projects/<int:project_id> JSON view.

get(project_id)[source]
methods = {'GET'}
class biweeklybudget.flaskapp.views.projects.ProjectsAjax[source]

Bases: biweeklybudget.flaskapp.views.searchableajaxview.SearchableAjaxView

Handle GET /ajax/projects 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].

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

Query with searching applied

Return type:

sqlalchemy.orm.query.Query

get()[source]

Render and return JSON response for GET /ajax/projects

methods = {'GET'}
class biweeklybudget.flaskapp.views.projects.ProjectsFormHandler[source]

Bases: biweeklybudget.flaskapp.views.formhandlerview.FormHandlerView

Handle POST /forms/projects

methods = {'POST'}
submit(data)[source]

Handle form submission; create or update models in the DB. Raises an Exception for any errors.

Parameters:data (dict) – submitted form data
Returns:message describing changes to DB (i.e. link to created record)
Return type:str
validate(data)[source]

Validate the form data. Return None if it is valid, or else a hash of field names to list of error strings for each field.

Parameters:data (dict) – submitted form data
Returns:None if no errors, or hash of field name to errors for that field
class biweeklybudget.flaskapp.views.projects.ProjectsView[source]

Bases: flask.views.MethodView

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

get()[source]
methods = {'GET'}