Skip to content

Commit

Permalink
Add 0017_clarify_insertion_form_error.patch to clarify user facing er…
Browse files Browse the repository at this point in the history
…ror message in insertion web page
  • Loading branch information
francesco-ballarin committed Aug 17, 2024
1 parent 3e3ad68 commit 690d0c4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
44 changes: 44 additions & 0 deletions patches/turing/0017_clarify_insertion_form_error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/engine/tests.py b/engine/tests.py
index 2d07dd8..9859e8d 100644
--- a/engine/tests.py
+++ b/engine/tests.py
@@ -1041,7 +1041,7 @@ class ValidationTests(MyTestCase, TuringTests):
self.assertTrue(self.user.is_inseritore(self.gara))

self.view_helper(200, 200,
- messages_post=[{"tag": "danger", "message": "Inserimento non riuscito"}],
+ messages_post=[{"tag": "danger", "message": "Inserimento non riuscito. Vedere l'elenco puntato sotto \"Gara: GaraTest - inserimento risposte\" per maggiori dettagli sull'errore."}],
form_errors={'__all__': ['Il problema deve esistere']})

self.assertFalse(self.gara.eventi.exists())
@@ -1060,7 +1060,7 @@ class ValidationTests(MyTestCase, TuringTests):
self.assertTrue(self.user.is_inseritore(self.gara))

self.view_helper(200, 200,
- messages_post=[{"tag": "danger", "message": "Inserimento non riuscito"}],
+ messages_post=[{"tag": "danger", "message": "Inserimento non riuscito. Vedere l'elenco puntato sotto \"Gara: GaraTest - inserimento risposte\" per maggiori dettagli sull'errore."}],
form_errors={'squadra': ["Scegli un'opzione valida. La scelta effettuata non compare tra quelle disponibili."]})

self.assertFalse(self.gara.eventi.exists())
@@ -1430,7 +1430,7 @@ class PermissionTests(MyTestCase, TuringTests):
self.view_helper(200, 200, messages_post=[{"tag": "info", "message": "Inserimento avvenuto", "partial": True}])

self.data = {'squadra': sq.pk, 'problema': 2, 'jolly': True}
- self.view_helper(200, 200, messages_post=[{"tag": "danger", "message": "Inserimento non riuscito"}])
+ self.view_helper(200, 200, messages_post=[{"tag": "danger", "message": "Inserimento non riuscito. Vedere l'elenco puntato sotto \"Gara: GaraTest - inserimento risposte\" per maggiori dettagli sull'errore."}])

jolly = self.gara.get_jolly()
assert len(jolly) == 1
diff --git a/engine/views.py b/engine/views.py
index b8e6b28..7e9dc44 100644
--- a/engine/views.py
+++ b/engine/views.py
@@ -346,7 +346,7 @@ class InserimentoView(CheckPermissionsMixin, DetailView, FormView):
return super().form_valid(form)

def form_invalid(self, form, *args, **kwargs):
- messages.error(self.request, "Inserimento non riuscito")
+ messages.error(self.request, f"Inserimento non riuscito. Vedere l'elenco puntato sotto \"Gara: {self.get_object().nome} - inserimento risposte\" per maggiori dettagli sull'errore.")
return super().form_invalid(form)


1 change: 1 addition & 0 deletions patches/turing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ This directory contains a few local patches. Most of them are related to changes
14. `0014_classification_time_from_server.patch`: stop using `Date.now()` in the calculation of the classification and use the server datetime instead, since the browser date may not agree with the one on the server.
15. `0015_manual_bonus.patch`: add feature to assign (positive or negative) bonus to a team. As a side effect, for simplicity of the implementation of the new feature the commentary has been disabled.
16. `0016_show_event_insertion_datetime_in_admin.patch`: show date and time of the creation of an event in the admin panel.
17. `0017_clarify_insertion_form_error.patch`: clarify error message in insertion form, explaining where the error details are.
1 change: 1 addition & 0 deletions patches/turing/apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ else
apply_patch 0014_classification_time_from_server.patch
apply_patch 0015_manual_bonus.patch
apply_patch 0016_show_event_insertion_datetime_in_admin.patch
apply_patch 0017_clarify_insertion_form_error.patch
fi

0 comments on commit 690d0c4

Please sign in to comment.