Skip to content

Commit

Permalink
feat: suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Cañon <[email protected]>
  • Loading branch information
johanseto and andrey-canon authored Jul 11, 2024
1 parent 9806c06 commit f225572
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion eox_nelp/user_profile/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ def update_user_data(request):
# so some fields like first_name and last_name are not editable in the standad implementation.

extra_account_user_fields = getattr(settings, "EXTRA_ACCOUNT_USER_FIELDS", [])

for field in extra_account_user_fields:
if (value := request.data.get(field)) and hasattr(request.user, field):
setattr(request.user, field, value)
request.user.save()
# Also some fields related ExtraInfo are not editable too in the standad implementation. So we need
# Also some fields related ExtraInfo are not editable too in the standard implementation. So we need
# save_extrainfo_field method with the desired settings.
required_user_extra_info_fields = getattr(settings, 'USER_PROFILE_API_EXTRA_INFO_FIELDS', [])

for field in required_user_extra_info_fields:
if value := request.data.get(field):
save_extrainfo_field(request.user, field, value)
Expand Down
2 changes: 1 addition & 1 deletion eox_nelp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def save_extrainfo_field(user, field, value):
field (string): extrainfo field to change
value (any): value set in extrainfo field
"""
ExtraInfo = import_module("custom_reg_form.models").ExtraInfo # pylint: disable=invalid-name
from custom_reg_form.models import ExtraInfo # pylint: disable=import-outside-toplevel
if not hasattr(ExtraInfo, field):
return

Expand Down

0 comments on commit f225572

Please sign in to comment.