Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent error when setting new default for multiple existing default dashboards #2680

Conversation

johannaengland
Copy link
Contributor

For some reason it happened that for multiple dashboards the is_default field is set to True, which leads to an error when trying to set a new dashboard as the default. This fixes that situation without doing anything about the underlying problem.

@github-actions
Copy link

github-actions bot commented Sep 12, 2023

Test results

     12 files       12 suites   15m 5s ⏱️
3 217 tests 3 217 ✔️ 0 💤 0
9 126 runs  9 126 ✔️ 0 💤 0

Results for commit f5c0427.

♻️ This comment has been updated with latest results.

lunkwill42
lunkwill42 previously approved these changes Sep 15, 2023
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Looks like a useful solution.

The tests were failing because you forgot to consider that dashboards are personal, so when there are multiple users, there will be multiple dashboard objects with the is_default attribute set to True.

(And there are always at least two users in a new NAV install, one representing the anonymous default user, and one representing the admin account)

I've pushed my suggested update to the tests...

@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Merging #2680 (f5c0427) into 5.7.x (8272b58) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            5.7.x    #2680      +/-   ##
==========================================
+ Coverage   55.17%   55.19%   +0.02%     
==========================================
  Files         561      561              
  Lines       40921    40917       -4     
==========================================
+ Hits        22577    22584       +7     
+ Misses      18344    18333      -11     
Files Changed Coverage Δ
python/nav/web/webfront/views.py 35.47% <100.00%> (+3.53%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

lunkwill42
lunkwill42 previously approved these changes Sep 18, 2023
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

🎉

For some reason we ended up with multiple default dashboards
This fix will make setting a new one possible
@sonarcloud
Copy link

sonarcloud bot commented Sep 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@johannaengland johannaengland merged commit b5e9956 into Uninett:5.7.x Sep 20, 2023
12 checks passed
@johannaengland johannaengland deleted the bugfix/fix-multiple-default-dashboards branch September 20, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants