csv_import: accept empty unmandatory phone (#87581)
gitea/authentic/pipeline/head This commit looks good
Details
gitea/authentic/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f9d07d749a
commit
af6ad87f92
|
@ -564,7 +564,7 @@ class UserCsvImporter:
|
|||
except Attribute.DoesNotExist:
|
||||
pass
|
||||
else:
|
||||
if attr.kind == 'phone_number':
|
||||
if attr.kind == 'phone_number' and (attr.required or data[header.name]):
|
||||
pn = parse_phone_number(data[header.name])
|
||||
if pn:
|
||||
# fill multi value field
|
||||
|
|
|
@ -901,6 +901,7 @@ def test_user_import_attributes(transactional_db, app, admin):
|
|||
assert 'Enter a valid date.' in response.text
|
||||
assert 'birthdate must be in the past and greater or equal than 1900-01-01.' in response.text
|
||||
assert 'The value must be a valid french postcode' in response.text
|
||||
assert 'Enter a valid phone number' in response.text
|
||||
|
||||
assert User.objects.count() == user_count + 1
|
||||
elliot = User.objects.filter(email='elliot@universalpictures.com')[0]
|
||||
|
@ -926,6 +927,13 @@ def test_user_import_attributes(transactional_db, app, admin):
|
|||
assert et.attributes.values['zip'].content == '42000'
|
||||
assert et.attributes.values['phone'].content == '+3281123456'
|
||||
|
||||
# empty not mandatory phone
|
||||
csv_lines[2] = 'et@universalpictures.com,ET,the Extra-Terrestrial,,,,,,42000,'
|
||||
response = import_csv('\n'.join(csv_lines), app)
|
||||
et = User.objects.filter(email='et@universalpictures.com')[0]
|
||||
assert et.attributes.values['phone'].content == ''
|
||||
assert 'Enter a valid phone number' not in response.text
|
||||
|
||||
|
||||
def test_detail_view(app, admin, simple_user, freezer, user_ou1, ou1, settings):
|
||||
url = f'/manage/users/{simple_user.pk}/'
|
||||
|
|
Loading…
Reference in New Issue