Skip to content

Commit

Permalink
chore: work in progress
Browse files Browse the repository at this point in the history
Signed-off-by: joshuaunity <[email protected]>
  • Loading branch information
joshuaunity committed Oct 4, 2024
1 parent dc241a9 commit d22cdfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions flexmeasures/api/v3_0/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,12 @@ class AssetAPI(FlaskView):
@use_kwargs(
{
"account": AccountIdField(data_key="account_id", load_default=None),
},
location="query",
)
@use_kwargs(
{
"all_accessible": fields.Bool(
data_key="all_accessible", load_default=False
),
},
location="query",
)
@use_kwargs(
{
"include_public": fields.Bool(
data_key="include_public", load_default=False
),
"page": fields.Int(
required=False, validate=validate.Range(min=1), load_default=1
),
Expand All @@ -91,6 +84,7 @@ def index(
self,
account: Account | None,
all_accessible: bool,
include_public: bool,
page: int | None = None,
per_page: int | None = None,
filter: list[str] | None = None,
Expand Down Expand Up @@ -157,7 +151,7 @@ def index(
filter_statement = GenericAsset.account_id.in_([a.id for a in accounts])

# add public assets if the request asks for all the accessible assets
if all_accessible:
if all_accessible or include_public:
filter_statement = filter_statement | GenericAsset.account_id.is_(None)

num_records = db.session.scalar(
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/crud/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ <h3>Assets</h3>
let filter = data["search"]["value"];
let url = `{{url_for("AssetAPI:index")}}?page=${
Math.floor(data["start"] / data["length"]) + 1
}&per_page=${data["length"]}&all_accessible=true&account_id=${
}&per_page=${data["length"]}&include_public=false&account_id=${
{{ account.id }}
}`;
if (filter.length > 0) {
Expand Down

0 comments on commit d22cdfe

Please sign in to comment.