flexmeasures.ui.crud.assets
Functions
- flexmeasures.ui.crud.assets.get_assets_by_account(account_id: int | str | None) list[GenericAsset]
- flexmeasures.ui.crud.assets.process_internal_api_response(asset_data: dict, asset_id: int | None = None, make_obj=False) GenericAsset | dict
Turn data from the internal API into something we can use to further populate the UI. Either as an asset object or a dict for form filling.
If we add other data by querying the database, we make sure the asset is not in the session afterwards.
- flexmeasures.ui.crud.assets.with_options(form: AssetForm | NewAssetForm) AssetForm | NewAssetForm
Classes
- class flexmeasures.ui.crud.assets.AssetCrudUI
These views help us offer a Jinja2-based UI. The main focus on logic is the API, so these views simply call the API functions, and deal with the response. Some new functionality, like fetching accounts and asset types, is added here.
- get(id: str, **kwargs)
GET from /assets/<id> where id can be ‘new’ (and thus the form for asset creation is shown) The following query parameters are supported (should be used only together):
start_time: minimum time of the events to be shown
end_time: maximum time of the events to be shown
- index(msg='')
GET from /assets
List the user’s assets. For admins, list across all accounts.
- class flexmeasures.ui.crud.assets.AssetForm(*args, **kwargs)
The default asset form only allows to edit the name and location.
- validate_on_submit()
Call
validate()
only if the form is submitted. This is a shortcut forform.is_submitted() and form.validate()
.
- class flexmeasures.ui.crud.assets.NewAssetForm(*args, **kwargs)
Here, in addition, we allow to set asset type and account.