flexmeasures.ui.views.assets.utils
Functions
- flexmeasures.ui.views.assets.utils.add_child_asset(asset: GenericAsset, assets: list) list
Add a child asset to the current assets list. This function is used to add a child asset to the current asset in the list of assets. Args:
asset: The current asset to be used as parent assets: The list of assets
- flexmeasures.ui.views.assets.utils.get_asset_by_id_or_raise_notfound(asset_id: str) GenericAsset
find an show existing asset or raise NotFound
- flexmeasures.ui.views.assets.utils.get_list_assets_chart(asset: GenericAsset, base_asset: GenericAsset, parent_depth=0, child_depth=0, look_for_child=False, is_head=False) list[dict]
Recursively builds a tree of assets from a given asset and its parents and children up to a certain depth.
- Args:
asset: The asset to start the recursion from base_asset: The asset that is the base of the chart parent_depth: The current depth of the parents hierarchy child_depth: The current depth of the children hierarchy look_for_child: If True, start looking for children of the current asset is_head: If True, the current asset is the head of the chart
- Returns:
A list of dictionaries representing the assets in the tree
- flexmeasures.ui.views.assets.utils.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.views.assets.utils.serialize_asset(asset: GenericAsset, is_head=False) dict
- flexmeasures.ui.views.assets.utils.user_can_create_children(asset: GenericAsset) bool
- flexmeasures.ui.views.assets.utils.user_can_delete(asset: GenericAsset) bool
- flexmeasures.ui.views.assets.utils.user_can_update(asset: GenericAsset) bool