Commit 3c69457
fix: commerce and enrollment error handling and ux (#36612)
Returns HTTP 400 for disallowed enrollments instead of HTTP 500.
Prevents infinite loading spinners on the enrollment page.
Displays clear error messages to users before redirection.
Ensures consistent and meaningful responses from enrollment API endpoints.
* fix: commerce and enrollment apis return 403 when enrollment not allowed
* fix: now both apis send the right message and http code when enrollment fails
* fix: InvalidEnrollmentAtribute as final exception to catch and HTTP 400 returned
* style: the message is displayed as a popup instead of creating a div at the end
* fix: import not used removed for pylint checks
* style: popup now use utility classes
* refactor: use const instead of let for existing const
* refactor: textContent const structure changed due check failed
* refactor: SetTimeout settled as arrow function
* feat: button incorporated to bring users enough time to read the message
* refactor: ErrorStatuses defined at the top of the file to use it in conditionals
* style: typo fixed
Co-authored-by: Diana Olarte <dcoa@live.com>
* refactor: double validation of redirectUrl eliminated and better styling of the message
Co-authored-by: Diana Olarte <dcoa@live.com>
* refactor: redirectUrl param eliminated in showmessage function, close button redirects to dashboard always
* docs: remove unused redirectUrl param from JSDoc and explain hardcoded URL
* style: endline added
* feat: enrollmentNotAllowed exception added in views and the js
* docs: comment added to especify exception
* style: endline added
* refactor: error statuses velidation changed to one single validation instead of two
* refactor: function added to handle enrollment errors
* feat: enrollmentNotAllowed exception added for API coherence and consistency
* style: empty line added
* style: pylint check line too long disabled
---------
Co-authored-by: Diana Olarte <dcoa@live.com>1 parent 5063021 commit 3c69457
File tree
3 files changed
+118
-11
lines changed- lms
- djangoapps/commerce/api/v0
- static/js/student_account
- openedx/core/djangoapps/enrollments
3 files changed
+118
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
153 | 175 | | |
154 | 176 | | |
155 | 177 | | |
156 | 178 | | |
157 | 179 | | |
158 | 180 | | |
159 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
160 | 200 | | |
161 | 201 | | |
162 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| |||
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
55 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
56 | 110 | | |
57 | 111 | | |
58 | 112 | | |
| |||
65 | 119 | | |
66 | 120 | | |
67 | 121 | | |
| 122 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
868 | 871 | | |
869 | 872 | | |
870 | 873 | | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
871 | 882 | | |
872 | 883 | | |
873 | 884 | | |
| |||
899 | 910 | | |
900 | 911 | | |
901 | 912 | | |
| 913 | + | |
902 | 914 | | |
903 | 915 | | |
904 | 916 | | |
| |||
0 commit comments