Skip to content

Fix/consultants can see button to add subasset - #2851

Open
nhoening wants to merge 4 commits into
mainfrom
fix/consultants-can-see-button-to-add-subasset
Open

nhoening wants to merge 4 commits into
mainfrom
fix/consultants-can-see-button-to-add-subasset

Conversation

@nhoening

@nhoening nhoening commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Description

There was a UI bug for consultants who aren’t admins of their own organisation.
They could not see the “Create asset” button on a client asset.
The reason: FlexMeasures checks whether they can create assets in their own organisation, instead of under the client’s parent asset.

  • Show clients' create asset button to consultants, by using the right permission
  • Added changelog item in documentation/changelog.rst

How to test

  • Be a user with consultant role, but not an admin
  • Go to a client account. You can add a top-level asset, but then (before this PR) no button to add a child asset will be shown. After this PR, it will be shown.

@nhoening nhoening added this to the 1.2.0 milestone Nov 9, 2026
@nhoening
nhoening requested a review from BelhsanHmida November 9, 2026 15:42
@nhoening nhoening self-assigned this Nov 9, 2026
@nhoening nhoening added the UI label Nov 9, 2026
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #35758807 | 📁 Comparing d57bf99 against latest (055d54d)

  🔍 Preview build  

2 files changed
± changelog.html
± api/v3_0.html

@BelhsanHmida BelhsanHmida left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: the fix works, a non-admin consultant now sees "Create asset" on a client asset and can create the child.

But plain members now see the button too (test), while /assets/new and /assets/create still check the organisation, so clicking it gives them a 403. If that's intended, they don't get a clear error: the browser shows raw JSON ("You cannot be authorized for this content or functionality.", "INVALID_SENDER"), since unauthorized_handler answers in JSON when there's no Content-Type, which is the case for any link click.

If it's not intended, gate the button on user_can_create_assets(account=asset.owner), the same check the page uses, and fix the test and changelog wording. Or, if members should create children (the API already allows it), make the GET and POST check user_can_create_children(parent_asset) / check_access(parent_asset, "edit-assets") when a parent is given, like the API does.

@BelhsanHmida BelhsanHmida left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: the fix works, a non-admin consultant now sees "Create asset" on a client asset and can create the child.

But plain members now see the button too (test), while /assets/new and /assets/create still check the organisation, so clicking it gives them a 403. If that's intended, they don't get a clear error: the browser shows raw JSON ("You cannot be authorized for this content or functionality.", "INVALID_SENDER"), since unauthorized_handler answers in JSON when there's no Content-Type, which is the case for any link click.

If it's not intended, gate the button on user_can_create_assets(account=asset.owner), the same check the page uses, and fix the test and changelog wording. Or, if members should create children (the API already allows it), make the GET and POST check user_can_create_children(parent_asset) / check_access(parent_asset, "edit-assets") when a parent is given, like the API does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants