diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 253d2e99f..0f883801a 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -3,7 +3,7 @@ FlexMeasures Changelog ********************** -v0.14.0 | June XX, 2023 +v0.14.0 | June 15, 2023 ============================ New features @@ -13,6 +13,7 @@ New features * Allow setting multiple :abbr:`SoC (state of charge)` maxima and minima constraints for the `StorageScheduler`, using the new ``soc-minima`` and ``soc-maxima`` fields when calling `/sensors//schedules/trigger` (POST) through the API (within the ``flex-model`` field) [see `PR #680 `_] * New CLI command ``flexmeasures add report`` to calculate a custom report from sensor data and save the results to the database, with the option to export them to a CSV or Excel file [see `PR #659 `_] * New CLI commands ``flexmeasures show reporters`` and ``flexmeasures show schedulers`` to list available reporters and schedulers, respectively, including any defined in registered plugins [see `PR #686 `_ and `PR #708 `_] +* Allow creating public assets through the CLI, which are available to all users [see `PR #727 `_] Bugfixes ----------- diff --git a/documentation/cli/change_log.rst b/documentation/cli/change_log.rst index 5809aae72..c1790976e 100644 --- a/documentation/cli/change_log.rst +++ b/documentation/cli/change_log.rst @@ -4,6 +4,15 @@ FlexMeasures CLI Changelog ********************** +since v0.14.0 | June 15, 2023 +================================= + +* Allow setting a storage efficiency using the new ``--storage-efficiency`` option to the ``flexmeasures add schedule for-storage`` CLI command. +* Add CLI command ``flexmeasures add report`` to calculate a custom report from sensor data and save the results to the database, with the option to export them to a CSV or Excel file. +* Add CLI command ``flexmeasures show reporters`` to list available reporters, including any defined in registered plugins. +* Add CLI command ``flexmeasures show schedulers`` to list available schedulers, including any defined in registered plugins. +* Make ``--account-id`` optional in ``flexmeasures add asset`` to support creating public assets, which are available to all users. + since v0.13.0 | May 1, 2023 ================================= diff --git a/flexmeasures/cli/data_add.py b/flexmeasures/cli/data_add.py index 65add6474..0fa0dce2a 100755 --- a/flexmeasures/cli/data_add.py +++ b/flexmeasures/cli/data_add.py @@ -133,7 +133,12 @@ def new_account(name: str, roles: str): @with_appcontext @click.option("--username", required=True) @click.option("--email", required=True) -@click.option("--account-id", type=int, required=True) +@click.option( + "--account-id", + type=int, + required=True, + help="Add user to this account. Follow up with the account's ID.", +) @click.option("--roles", help="e.g. anonymous,Prosumer,CPO") @click.option( "--timezone", @@ -286,7 +291,12 @@ def add_asset_type(**args): type=LongitudeField(), help="Longitude of the asset's location", ) -@click.option("--account-id", type=int, required=True) +@click.option( + "--account-id", + type=int, + required=False, + help="Add asset to this account. Follow up with the account's ID. If not set, the asset will become public (which makes it accessible to all users).", +) @click.option( "--asset-type-id", "generic_asset_type_id", @@ -298,6 +308,11 @@ def add_asset(**args): """Add an asset.""" check_errors(GenericAssetSchema().validate(args)) generic_asset = GenericAsset(**args) + if generic_asset.account_id is None: + click.secho( + "Creating a PUBLIC asset, as the account_id is not given ...", + **MsgStyle.WARN, + ) db.session.add(generic_asset) db.session.commit() click.secho( @@ -319,7 +334,7 @@ def add_initial_structure(): "--name", required=True, type=str, - help="Name of the source (usually an organisation)", + help="Name of the source (usually an organization)", ) @click.option( "--model", diff --git a/flexmeasures/data/schemas/generic_assets.py b/flexmeasures/data/schemas/generic_assets.py index 469c29951..6600a89cd 100644 --- a/flexmeasures/data/schemas/generic_assets.py +++ b/flexmeasures/data/schemas/generic_assets.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json from marshmallow import validates, validates_schema, ValidationError, fields @@ -66,7 +68,11 @@ def validate_generic_asset_type(self, generic_asset_type_id: int): ) @validates("account_id") - def validate_account(self, account_id: int): + def validate_account(self, account_id: int | None): + if account_id is None and ( + running_as_cli() or user_has_admin_access(current_user, "update") + ): + return account = Account.query.get(account_id) if not account: raise ValidationError(f"Account with Id {account_id} doesn't exist.")