dashboard.blueprints.main package¶
Module contents¶
- dashboard.blueprints.main.register_bp(app)¶
Submodules¶
dashboard.blueprints.main.views module¶
- dashboard.blueprints.main.views.analysis(analysis_id=None)¶
Default view for analysis
- dashboard.blueprints.main.views.downloadCSV()¶
- dashboard.blueprints.main.views.index()¶
Main landing page
- dashboard.blueprints.main.views.metricData()¶
This is a generic view for querying the database and allows selection of any combination of metrics and returns the data.
The form is submitted on any change, this allows dynamic updating of the selection boxes displayed in the html (i.e. if SPINS study is selected the sites selector is filtered to only show sites relevent to SPINS).
We only actually query and return the data if the query_complete is defined as true - this is done by client-side javascript.
A lot of this could have been done client side but I think we all prefer writing python to javascript.
- dashboard.blueprints.main.views.metricDataAsJson(output='http')¶
Query the database for metrics. Handles both GET (generated by client side javascript for creating graphs) and POST (generated by the metricData form view) requests
- Can be accessed at:
This will return all data in the database (probs not what you want).
Filters can be defined in the http request object (http://flask.pocoo.org/docs/0.12/api/#incoming-request-data) this is a global flask object that is automatically created whenever a URL is requested. e.g.:
<url>/metricDataAsJson?studies=15&sessions=1739,1744&metrictypes=84 creates a request object
- request.args = {studies: 15,
sessions: [1739, 1744], metrictypes: 84}
If byname is defined (and evaluates True) in the request.args then filters can be defined by name instead of by database id e.g. <url>/metricDataAsJson?byname=True&studies=ANDT&sessions=ANDT_CMH_101_01
Function works slightly differently if the request method is POST (such as that generated by metricData()). In that case the field names are expected to be the primary keys from the database as these are used to create the form.
- dashboard.blueprints.main.views.search_data(search_string=None)¶
Implements the site’s search bar.
- dashboard.blueprints.main.views.study(study_id=None, active_tab=None)¶
This is the main view for a single study. The page is a tabulated view, I would have done this differently given another chance.