Uninett / nav

Network Administration Visualized
GNU General Public License v3.0
194 stars 39 forks source link

Refactor maintenance task views to improve display of deleted components #3230

Closed lunkwill42 closed 2 days ago

lunkwill42 commented 2 days ago

This fixes #3228, but it was not feasible without a significant refactoring of the maintenance task UI codebase.

The codebase originally stems from a time before Django was added to NAV, and was significantly convoluted compared to what it needs to be. This PR makes it slightly less so, but there is still some way to go:

There was a lot of processing and custom validation code for the component fields of the maintenance task forms, which ended up producing large hierarchies of dicts and lists (some of which were fed directly to templates), instead of re-using ORM functionality. While much of the processing would be best encapsulated in Django Forms, this refactor mostly concerns itself with using ORM objects where we can.

The ultimate goal was really only to be able to display deleted components in a better way, by utilizing a new component description field. This is achieved in this PR by replacing the template render data witch actual lists of Django model objects, and by replacing the missing objects with a special MissingComponent class.

Please do ask for clarifications if necessary.

sonarcloud[bot] commented 2 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

github-actions[bot] commented 2 days ago

πŸ¦™ MegaLinter status: βœ… SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
βœ… PYTHON black 991 0 12.97s
βœ… PYTHON ruff 987 0 0.1s

See detailed report in MegaLinter reports

_MegaLinter is graciously provided by OX Security_

github-actions[bot] commented 2 days ago

Test results

β€‡β€ˆβ€‡β€‡8 filesβ€„β€ƒβ€‡β€ˆβ€‡β€‡8 suites   8m 11s ⏱️ 2β€ˆ140 tests 2β€ˆ129 βœ…β€ƒ0 πŸ’€β€ƒ11 ❌ 4β€ˆ012 runsβ€Šβ€ƒ3β€ˆ990 βœ…β€ƒ0 πŸ’€β€ƒ22 ❌

For more details on these failures, see this check.

Results for commit 26389a57.

codecov[bot] commented 2 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 60.37%. Comparing base (27b12b5) to head (26389a5).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3230 +/- ## ========================================== - Coverage 60.39% 60.37% -0.02% ========================================== Files 605 605 Lines 43687 43665 -22 Branches 48 48 ========================================== - Hits 26383 26362 -21 + Misses 17292 17291 -1 Partials 12 12 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

lunkwill42 commented 2 days ago

Branch name and history are off, closing to create a new PR