Skip to content

Commit

Permalink
chore: pushing a suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
  • Loading branch information
joshuaunity committed Nov 1, 2024
1 parent 9a391e9 commit 4bb8394
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions flexmeasures/api/v3_0/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,27 @@ class SensorAPI(FlaskView):
@route("", methods=["GET"])
@use_kwargs(
{
"account": AccountIdField(
data_key="account_id", load_default=AccountIdField.load_current
),
"account": AccountIdField(data_key="account_id", required=False),
"asset": AssetIdField(data_key="asset_id", required=False),
"include_consultancy_clients": fields.Boolean(
required=False, load_default=False
),
"include_public_assets": fields.Boolean(required=False, load_default=False),
"page": fields.Int(
required=False, validate=validate.Range(min=1), default=1
required=False, validate=validate.Range(min=1), load_default=1
),
"per_page": fields.Int(
required=False, validate=validate.Range(min=1), default=10
required=False, validate=validate.Range(min=1), load_default=10
),
"filter": SearchFilterField(required=False, default=None),
"unit": UnitField(required=False, default=None),
"filter": SearchFilterField(required=False, load_default=None),
"unit": UnitField(required=False, load_default=None),
},
location="query",
)
@permission_required_for_context("read", ctx_arg_name="account")
@as_json
def index(
self,
account: Account,
account: Account | None = None,
asset: GenericAsset | None = None,
include_consultancy_clients: bool = False,
include_public_assets: bool = False,
Expand Down Expand Up @@ -156,7 +153,11 @@ def index(
:status 403: INVALID_SENDER
:status 422: UNPROCESSABLE_ENTITY
"""
account_ids: list = [account.id]
if account and asset is None:
account = current_user.account if not current_user.is_anonymous else None

account = account if check_access(account, "read") is None else None
account_ids: list = [account.id] if account else []

if asset is not None:
asset_tree = (
Expand Down

0 comments on commit 4bb8394

Please sign in to comment.