Skip to content

Commit debd4e7

Browse files
ntthitrinhkhangon
andauthored
feature-8878:Can't read errors related to unfilled fields in the form (#9017)
* feature-8878:Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form * feature-8878: Can't read errors related to unfilled fields in the form --------- Co-authored-by: Khang On - TMA <[email protected]>
1 parent 04fc790 commit debd4e7

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

app/api/helpers/custom_forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def validate_custom_form_constraints(form, obj, excluded):
6060
continue
6161
if not field.is_complex:
6262
if not getattr(obj, field.identifier):
63-
missing_required_fields.append(field.identifier)
63+
missing_required_fields.append(field.name)
6464
else:
6565
if obj.complex_field_values:
6666
if obj.complex_field_values.get(field.identifier) is None:
67-
missing_required_fields.append(field.identifier)
67+
missing_required_fields.append(field.name)
6868
else:
69-
missing_required_fields.append(field.identifier)
69+
missing_required_fields.append(field.name)
7070

7171
if len(missing_required_fields) > 0:
7272
raise UnprocessableEntityError(

tests/all/integration/api/attendee/test_attendee_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_edit_attendee_required_fields_missing(db, client, jwt, user):
9494
assert json.loads(response.data) == {
9595
'errors': [
9696
{
97-
'detail': "Missing required fields ['email', 'tax_business_info']",
97+
'detail': "Missing required fields ['Email', 'Tax Business Info']",
9898
'source': {'pointer': '/data/attributes'},
9999
'status': 422,
100100
'title': 'Unprocessable Entity',
@@ -208,7 +208,7 @@ def test_custom_form_complex_fields_missing_required(db, client, jwt, user):
208208
assert json.loads(response.data) == {
209209
'errors': [
210210
{
211-
'detail': "Missing required fields ['best_friend', 'job_title']",
211+
'detail': "Missing required fields ['Best Friend', 'Job Title']",
212212
'source': {'pointer': '/data/attributes'},
213213
'status': 422,
214214
'title': 'Unprocessable Entity',
@@ -290,7 +290,7 @@ def test_custom_form_complex_fields_missing_required_one(db, client, jwt, user):
290290
assert json.loads(response.data) == {
291291
'errors': [
292292
{
293-
'detail': "Missing required fields ['best_friend']",
293+
'detail': "Missing required fields ['Best Friend']",
294294
'source': {'pointer': '/data/attributes'},
295295
'status': 422,
296296
'title': 'Unprocessable Entity',

tests/all/integration/api/helpers/order/test_edit_order.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_order_pending_incomplete_complex_custom_form(client, db, user, jwt):
199199
'status': 422,
200200
'source': {'pointer': '/data/attributes'},
201201
'title': 'Unprocessable Entity',
202-
'detail': "Missing required fields ['what_college', 'what_university']",
202+
'detail': "Missing required fields ['what college', 'what university']",
203203
}
204204
],
205205
'jsonapi': {'version': '1.0'},
@@ -238,7 +238,7 @@ def test_order_placed_incomplete_complex_custom_form(client, db, user, jwt):
238238
'status': 422,
239239
'source': {'pointer': '/data/attributes'},
240240
'title': 'Unprocessable Entity',
241-
'detail': "Missing required fields ['what_college', 'what_university']",
241+
'detail': "Missing required fields ['what college', 'what university']",
242242
}
243243
],
244244
'jsonapi': {'version': '1.0'},

tests/all/integration/api/session/test_session_forms_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_edit_session_required_fields_missing(db, client, user, jwt):
115115
assert json.loads(response.data) == {
116116
'errors': [
117117
{
118-
'detail': "Missing required fields ['level', 'short_abstract']",
118+
'detail': "Missing required fields ['Level', 'Short Abstract']",
119119
'source': {'pointer': '/data/attributes'},
120120
'status': 422,
121121
'title': 'Unprocessable Entity',
@@ -162,7 +162,7 @@ def test_create_session_required_fields_missing(db, client, user, jwt):
162162
assert json.loads(response.data) == {
163163
'errors': [
164164
{
165-
'detail': "Missing required fields ['level', 'short_abstract']",
165+
'detail': "Missing required fields ['Level', 'Short Abstract']",
166166
'source': {'pointer': '/data/attributes'},
167167
'status': 422,
168168
'title': 'Unprocessable Entity',
@@ -328,7 +328,7 @@ def test_custom_form_complex_fields_missing_required(db, client, user, jwt):
328328
assert json.loads(response.data) == {
329329
'errors': [
330330
{
331-
'detail': "Missing required fields ['best_friend', 'slides_url']",
331+
'detail': "Missing required fields ['Best Friend', 'Slide']",
332332
'source': {'pointer': '/data/attributes'},
333333
'status': 422,
334334
'title': 'Unprocessable Entity',
@@ -377,7 +377,7 @@ def test_custom_form_create_complex_fields_missing_required(db, client, user, jw
377377
assert json.loads(response.data) == {
378378
'errors': [
379379
{
380-
'detail': "Missing required fields ['best_friend', 'slides_url']",
380+
'detail': "Missing required fields ['Best Friend', 'Slide']",
381381
'source': {'pointer': '/data/attributes'},
382382
'status': 422,
383383
'title': 'Unprocessable Entity',

tests/all/integration/api/speaker/test_speaker_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_edit_speaker_required_fields_missing(db, client, user, jwt):
104104
assert json.loads(response.data) == {
105105
'errors': [
106106
{
107-
'detail': "Missing required fields ['mobile', 'speaking_experience']",
107+
'detail': "Missing required fields ['Mobile', 'Speaking Experience']",
108108
'source': {'pointer': '/data/attributes'},
109109
'status': 422,
110110
'title': 'Unprocessable Entity',
@@ -146,7 +146,7 @@ def test_create_speaker_required_fields_missing(db, client, jwt):
146146
assert json.loads(response.data) == {
147147
'errors': [
148148
{
149-
'detail': "Missing required fields ['mobile', 'speaking_experience']",
149+
'detail': "Missing required fields ['Mobile', 'Speaking Experience']",
150150
'source': {'pointer': '/data/attributes'},
151151
'status': 422,
152152
'title': 'Unprocessable Entity',
@@ -292,7 +292,7 @@ def test_custom_form_complex_fields_missing_required(db, client, user, jwt):
292292
assert json.loads(response.data) == {
293293
'errors': [
294294
{
295-
'detail': "Missing required fields ['best_friend', 'heard_from']",
295+
'detail': "Missing required fields ['Best Friend', 'Heard From']",
296296
'source': {'pointer': '/data/attributes'},
297297
'status': 422,
298298
'title': 'Unprocessable Entity',
@@ -333,7 +333,7 @@ def test_custom_form_create_complex_fields_missing_required(db, client, jwt):
333333
assert json.loads(response.data) == {
334334
'errors': [
335335
{
336-
'detail': "Missing required fields ['best_friend', 'heard_from']",
336+
'detail': "Missing required fields ['Best Friend', 'Heard From']",
337337
'source': {'pointer': '/data/attributes'},
338338
'status': 422,
339339
'title': 'Unprocessable Entity',

0 commit comments

Comments
 (0)