Move common functionality to destination base class
Best reviewed per file.
Codecov Report
Attention: Patch coverage is 69.82249% with 51 lines in your changes missing coverage. Please review.
Project coverage is 76.70%. Comparing base (
eaa3a25) to head (713e5d5). Report is 2 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #936 +/- ##
==========================================
- Coverage 77.36% 76.70% -0.66%
==========================================
Files 141 141
Lines 5548 5667 +119
==========================================
+ Hits 4292 4347 +55
- Misses 1256 1320 +64
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
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
I just checked and we don't have a test for trying to PATCH update with medium being empty, that should be added, I think then it would be clearer if the changes work or not
We do have tests for when trying to change the medium that that will lead to an error
We are now way out of scope for a refactor.
I guess the underlying problem is that we cannot lookup and change destinations of a specific media type directly, as part of the url of the endpoint. If we could, we would never need bother with media in the update-serializer.
I just checked and we don't have a test for trying to PATCH update with medium being empty, that should be added, I think then it would be clearer if the changes work or not We do have tests for when trying to change the medium that that will lead to an error
We are now way out of scope for a refactor.
Yes, I agree, I can do this in another PR, but that would have to merged before this then, because it would show if the functionality is staying the same
I don't think it is wise to stress with finishing this PR this week anymore, so start on the patch-PR next week.
I decided to pass in the DestinationConfig instance (if any) to the clean-method so that it will have access to the currently stored settings.
We could change the
__str__function ofDestinationConfigchange to use theget_labelfunction in general. Then we can simplify this
Originally posted by @johannaengland in https://github.com/Uninett/Argus/pull/1118#discussion_r1914806712
I got stuff mostly working with this but the main problem is extracting errors to show in the related fields
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
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
Updating existing destination is still buggy. It allows me to update either the email on its own or the label and email together. it does not allow me to only update the label, or just click update without making any changes. In the cases where it doesnt work this is the server log error:
2025-03-14 11:57:19,231 django.request ERROR Internal Server Error: /destinations/9/htmx-update/
Traceback (most recent call last):
File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/views/decorators/http.py", line 64, in inner
return func(request, *args, **kwargs)
File "/home/simon/repos/Argus/src/argus/htmx/destination/views.py", line 58, in update_htmx
form.save()
File "/home/simon/repos/Argus/src/argus/htmx/destination/forms.py", line 37, in save
self.serializer.save(user=self.request.user)
File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 180, in save
assert not self.errors, (
AssertionError: You cannot call `.save()` on a serializer with invalid data.
2025-03-14 11:57:19,233 django.server INFO "POST /destinations/9/htmx-update/ HTTP/1.1" 200 814