flexmeasures.ui.utils.view_utils
Utilities for views
Functions
- flexmeasures.ui.utils.view_utils.asset_icon_name(asset_type_name: str) str
Icon name for this asset type.
This can be used for UI html templates made with Jinja. ui.__init__ makes this function available as the filter “asset_icon”.
- For example:
<i class={{ asset_type.name | asset_icon }}></i>
- becomes (for a battery):
<i class=”icon-battery”></i>
- flexmeasures.ui.utils.view_utils.available_units() list[str]
Return a list of all available units from sensors currently in the database.
- flexmeasures.ui.utils.view_utils.clear_session(keys_to_clear: list[str] | None = None)
Clear out session variables.
If keys_to_clear is provided, only clear out those specific session variables. Otherwise, clear out all session variables except for some special ones (e.g. Flask-Security’s, CSRF token, and our own session variables).
- flexmeasures.ui.utils.view_utils.fall_back_to_flask_template(render_function)
In case the render_function is raising an error, fall back to using flask.render_template.
- flexmeasures.ui.utils.view_utils.get_git_description() tuple[str, int, str]
Get information about the SCM (git) state if possible (if a .git directory exists).
Returns the latest git version (tag) as a string, the number of commits since then as an int and the current commit hash as string.
- flexmeasures.ui.utils.view_utils.render_flexmeasures_template(html_filename: str, **variables)
Render template and add all expected template variables, plus the ones given as **variables.