2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 13:35:40 +00:00

Merge pull request #2161 from matmair/onboarding-group

Onboarding group
This commit is contained in:
Oliver
2021-10-15 12:55:55 +11:00
committed by GitHub
3 changed files with 31 additions and 7 deletions

View File

@ -11,7 +11,7 @@ import decimal
import math
from django.db import models, transaction
from django.contrib.auth.models import User
from django.contrib.auth.models import User, Group
from django.db.utils import IntegrityError, OperationalError
from django.conf import settings
@ -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
@ -479,6 +476,11 @@ class BaseInvenTreeSetting(models.Model):
return value
def settings_group_options():
"""build up group tuple for settings based on gour choices"""
return [('', _('No group')), *[(str(a.id), str(a)) for a in Group.objects.all()]]
class InvenTreeSetting(BaseInvenTreeSetting):
"""
An InvenTreeSetting object is a key:value pair used for storing
@ -845,6 +847,12 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': True,
'validator': bool,
},
'SIGNUP_GROUP': {
'name': _('Group on signup'),
'description': _('Group new user are asigned on registration'),
'default': '',
'choices': settings_group_options
},
}
class Meta: