Skip to content

Commit

Permalink
Fix: public sensors to show (#830)
Browse files Browse the repository at this point in the history
Fix two bugs dealing with public assets.


* fix: public sensors have None owner

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: changelog entry

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: searching for annotations on public assets

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: more explicit if-statement

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: add second fix to changelog

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x authored and victorgarcia98 committed Aug 22, 2023
1 parent bc291b1 commit 1564eda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Bugfixes

* Use the `source` to filter beliefs in the `AggregatorReporter` and fix the case of having multiple sources [see `PR #819 <https://github.com/FlexMeasures/flexmeasures/pull/819>`_]
* Disable HiGHS logs on the standard output when `LOGGING_LEVEL=INFO` [see `PR #824 <https://github.com/FlexMeasures/flexmeasures/pull/824>`_ and `PR #826 <https://github.com/FlexMeasures/flexmeasures/pull/826>`_]
* Fix showing sensor data on the asset page of public assets, and searching for annotations on public assets [see `PR #830 <https://github.com/FlexMeasures/flexmeasures/pull/830>`_]


v0.15.0 | August 9, 2023
Expand Down
6 changes: 4 additions & 2 deletions flexmeasures/data/models/generic_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def search_annotations(
) -> Union[List[Annotation], pd.DataFrame]:
"""Return annotations assigned to this asset, and optionally, also those assigned to the asset's account.
The returned annotations do not include any annotations on public accounts.
:param annotations_after: only return annotations that end after this datetime (exclusive)
:param annotations_before: only return annotations that start before this datetime (exclusive)
"""
Expand All @@ -226,7 +228,7 @@ def search_annotations(
sources=parsed_sources,
annotation_type=annotation_type,
).all()
if include_account_annotations:
if include_account_annotations and self.owner is not None:
annotations += self.owner.search_annotations(
annotations_after=annotations_after,
annotations_before=annotations_before,
Expand Down Expand Up @@ -459,7 +461,7 @@ def sensors_to_show(self) -> list["Sensor" | list["Sensor"]]: # noqa F821

# Only allow showing sensors from assets owned by the user's organization,
# except in play mode, where any sensor may be shown
accounts = [self.owner]
accounts = [self.owner] if self.owner is not None else None
if current_app.config.get("FLEXMEASURES_MODE") == "play":
from flexmeasures.data.models.user import Account

Expand Down

0 comments on commit 1564eda

Please sign in to comment.