Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Commit

Permalink
fix: fix rero/rero-ils#27 save patron without phones
Browse files Browse the repository at this point in the history
Signed-off-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr authored and rerowep committed Jun 25, 2018
1 parent bf1bdcd commit 46fd9c1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions reroils_data/patrons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def save_patron(data, record_type, fetcher, minter,
and attached to the patron.
"""
email = data.get('email')
data = staff_patron_fields(data)
data = clean_patron_fields(data)
if email:
find_user = datastore.find_user(email=email)
if find_user is None:
Expand Down Expand Up @@ -88,8 +88,16 @@ def save_patron(data, record_type, fetcher, minter,
return _next, patron.persistent_identifier


def staff_patron_fields(data):
"""Validate user fields based on user type (patorn or staff)."""
def clean_patron_fields(data):
"""Clean patron fields.
Remove empty fields and
validate user fields based on user type (patron/staff).
"""
for key, value in list(data.items()):
if not value or value == '':
del data[key]

if not data.get('is_patron'):
if 'barcode' in data:
del(data['barcode'])
Expand Down

0 comments on commit 46fd9c1

Please sign in to comment.