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