def _reroll(self): from freenasUI.account.forms import FilteredSelectJSON users = FreeNAS_Users(flags=FLAGS_DBINIT | FLAGS_CACHE_READ_USER | FLAGS_CACHE_WRITE_USER) if len(users) > 500: if self.initial: self.choices = ((self.initial, self.initial), ) kwargs = {} if len(self._exclude) > 0: kwargs['exclude'] = ','.join(self._exclude) self.widget = FilteredSelectJSON(url=("account_bsduser_json", None, (), kwargs)) else: ulist = [] if not self.required: ulist.append(('-----', 'N/A')) ulist.extend( map( lambda x: ( x.pw_name, x.pw_name, ), filter( lambda y: y is not None and y.pw_name not in self. _exclude, users))) self.widget = widgets.FilteringSelect() self.choices = ulist
def _reroll(self): from freenasUI.account.forms import FilteredSelectJSON groups = FreeNAS_Groups(flags=FLAGS_DBINIT | FLAGS_CACHE_READ_GROUP | FLAGS_CACHE_WRITE_GROUP) if len(groups) > 500: if self.initial: self.choices = ((self.initial, self.initial), ) self.widget = FilteredSelectJSON(url=("account_bsdgroup_json", )) else: glist = [] if not self.required: glist.append(('-----', 'N/A')) glist.extend([(x.gr_name, x.gr_name) for x in groups]) self.widget = widgets.FilteringSelect() self.choices = glist
def _reroll(self): from freenasUI.account.forms import FilteredSelectJSON try: users = FreeNAS_Users(flags=FLAGS_DBINIT | FLAGS_CACHE_READ_USER) except: users = [] if len(users) > 500: if self.initial: self.choices = ((self.initial, self.initial), ) kwargs = {} if len(self._exclude) > 0: kwargs['exclude'] = ','.join(self._exclude) self.widget = FilteredSelectJSON(url=("account_bsduser_json", None, (), kwargs)) else: ulist = [] if not self.required: ulist.append(('-----', 'N/A')) notbuiltin = [ o[0] for o in bsdUsers.objects.filter( bsdusr_builtin=False).values_list('bsdusr_uid') ] ulist.extend( map( lambda x: ( x.pw_name, x.pw_name, ), sorted(filter( lambda y: (y is not None and y.pw_name not in self._exclude), users), key=lambda y: (y.pw_uid not in notbuiltin, y.pw_name)))) self.widget = widgets.FilteringSelect() self.choices = ulist
def _reroll(self): from freenasUI.account.forms import FilteredSelectJSON try: groups = FreeNAS_Groups(flags=FLAGS_DBINIT | FLAGS_CACHE_READ_GROUP) except: groups = [] if len(groups) > 500: if self.initial: self.choices = ((self.initial, self.initial), ) self.widget = FilteredSelectJSON(url=("account_bsdgroup_json", )) else: glist = [] if not self.required: glist.append(('-----', 'N/A')) notbuiltin = [ o[0] for o in bsdGroups.objects.filter( bsdgrp_builtin=False).values_list('bsdgrp_gid') ] glist.extend([(x.gr_name, x.gr_name) for x in sorted( groups, key=lambda y: (y.gr_gid not in notbuiltin, y.gr_name)) ]) self.widget = widgets.FilteringSelect() self.choices = glist