move goup forming into own function

This commit is contained in:
Matthias 2021-10-14 22:16:07 +02:00
parent 27aec4246e
commit e0887cf55f
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -182,12 +182,9 @@ class BaseInvenTreeSetting(models.Model):
else: else:
choices = None choices = None
""" if callable(choices):
TODO:
if type(choices) is function:
# Evaluate the function (we expect it will return a list of tuples...) # Evaluate the function (we expect it will return a list of tuples...)
return choices() return choices()
"""
return choices return choices
@ -478,6 +475,8 @@ class BaseInvenTreeSetting(models.Model):
return value return value
def group_options():
return [('', _('No group')), *[(str(a.id), str(a)) for a in Group.objects.all()]]
class InvenTreeSetting(BaseInvenTreeSetting): class InvenTreeSetting(BaseInvenTreeSetting):
""" """
@ -849,10 +848,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'name': _('Group on signup'), 'name': _('Group on signup'),
'description': _('Group new user are asigned on registration'), 'description': _('Group new user are asigned on registration'),
'default': '', 'default': '',
'choices': [ 'choices': group_options
('', _('No group')),
*[(str(a.id), str(a)) for a in Group.objects.all()]
],
}, },
} }