Argus icon indicating copy to clipboard operation
Argus copied to clipboard

Use forms in destination page

Open hmpf opened this issue 1 year ago • 4 comments

Depends on #936

Review file by file

Will be squashed

hmpf avatar Jan 23 '25 12:01 hmpf

Codecov Report

Attention: Patch coverage is 49.15825% with 151 lines in your changes missing coverage. Please review.

Project coverage is 77.07%. Comparing base (eaa3a25) to head (bbebc2e). Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/argus/htmx/destination/views.py 16.94% 98 Missing :warning:
src/argus/notificationprofile/media/base.py 63.10% 38 Missing :warning:
src/argus/notificationprofile/media/email.py 80.95% 8 Missing :warning:
src/argus/notificationprofile/media/__init__.py 42.85% 4 Missing :warning:
src/argus/notificationprofile/serializers.py 89.47% 2 Missing :warning:
...rc/argus/notificationprofile/media/sms_as_email.py 83.33% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1161      +/-   ##
==========================================
- Coverage   77.36%   77.07%   -0.29%     
==========================================
  Files         141      140       -1     
  Lines        5548     5675     +127     
==========================================
+ Hits         4292     4374      +82     
- Misses       1256     1301      +45     

: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.

codecov-commenter avatar Jan 24 '25 11:01 codecov-commenter

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

sonarqubecloud[bot] avatar Mar 14 '25 10:03 sonarqubecloud[bot]

Immediate problem I noticed here: If you try to create a new destination that should fail (has same label or email has a pre-existing destination), it does not give an error message. The form is emptied and a success message appears, like it does when you actually succesfulyl create a destination, but no new destination is added.

Edit: If both fields are indentical to a pre existing email it gives the success message, if only the label is duplicate but email is new, it gives an error An error occured while processing your request, please try again, and the server log shows this:

2025-03-14 11:50:47,762 django.request ERROR    Internal Server Error: /destinations/email/create/
Traceback (most recent call last):
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "unique_label_per_user_and_medium"
DETAIL:  Key (user_id, media_id, label)=(2, email, myemial22) already exists.


The above exception was the direct cause of the following exception:

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 107, in create_destination
    obj, changed = save_forms(request.user, media, label_form, settings_form)
  File "/home/simon/repos/Argus/src/argus/htmx/destination/views.py", line 88, in save_forms
    obj.save()
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/base.py", line 892, in save
    self.save_base(
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/base.py", line 998, in save_base
    updated = self._save_table(
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1161, in _save_table
    results = self._do_insert(
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1202, in _do_insert
    return manager._insert(
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1847, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1836, in execute_sql
    cursor.execute(sql, params)
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 122, in execute
    return super().execute(sql, params)
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/simon/repos/Argus/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "unique_label_per_user_and_medium"
DETAIL:  Key (user_id, media_id, label)=(2, email, myemial22) already exists.

stveit avatar Mar 14 '25 10:03 stveit