Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
#218 fix autoloading choices
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwunderbar666 committed Feb 18, 2023
1 parent ec4a16b commit b2861c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions flaskinventory/flaskdgraph/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,14 @@ def get_field(self, field):
if v.edit and current_user.user_role >= v.permission:
if isinstance(v, (SingleRelationship, ReverseRelationship, MutualRelationship)) and k in populate_obj.keys():
if not v.autoload_choices:
choices = [(subval['uid'], subval['name'])
for subval in populate_obj[k]]
if isinstance(populate_obj[k], list):
choices = [(subval['uid'], subval.get('name', subval['uid']))
for subval in populate_obj[k]]
else:
choices = [(populate_obj[k]['uid'], populate_obj[k].get('name', populate_obj[k]['uid']))]

v.choices_tuples = choices

setattr(F, k, v.wtf_field)

if current_user.user_role >= USER_ROLES.Reviewer and entry_review_status == 'pending':
Expand Down

0 comments on commit b2861c5

Please sign in to comment.