Exemple #1
0
 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(
             attrs=self.widget.attrs,
             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.choices = glist
         self.widget = FilteredSelectJSON(
             attrs=self.widget.attrs,
             url=("account_bsdgroup_json",),
             choices=glist
         )
Exemple #2
0
 def _reroll(self):
     from freenasUI.account.forms import FilteredSelectJSON
     try:
         with client as c:
             groups = c.call('groups.query',
                             {'extra': {
                                 'search_dscache': True
                             }})
     except:
         groups = []
     kwargs = {'api_name': 'v1.0', 'resource_name': 'account/all_groups'}
     if len(groups) > 500:
         if self.initial:
             self.choices = ((self.initial, self.initial), )
         self.widget = FilteredSelectJSON(attrs=self.widget.attrs,
                                          url=reverse('api_dispatch_list',
                                                      kwargs=kwargs))
     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['group'], x['group']) for x in sorted(
             groups, key=lambda y: (y['gid'] not in notbuiltin, y['group']))
                       ])
         #self.choices = glist
         self.widget = FilteredSelectJSON(attrs=self.widget.attrs,
                                          url=reverse('api_dispatch_list',
                                                      kwargs=kwargs),
                                          choices=glist)
Exemple #3
0
    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
Exemple #4
0
    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(
                attrs=self.widget.attrs,
                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 = FilteredSelectJSON(
                attrs=self.widget.attrs,
                url=("account_bsduser_json",),
                choices=ulist
            )
Exemple #5
0
    def _reroll(self):
        from freenasUI.account.forms import FilteredSelectJSON
        try:
            with client as c:
                users = c.call('users.query',
                               {'extra': {
                                   'search_dscache': True
                               }})
        except:
            users = []
        kwargs = {'api_name': 'v1.0', 'resource_name': 'account/all_users'}
        if len(users) > 500:
            if self.initial:
                self.choices = ((self.initial, self.initial), )
            if len(self._exclude) > 0:
                kwargs['exclude'] = ','.join(self._exclude)
            self.widget = FilteredSelectJSON(attrs=self.widget.attrs,
                                             url=reverse('api_dispatch_list',
                                                         kwargs=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([
                (x['username'],
                 x['username']) for x in sorted([
                     y for y in users
                     if (y is not None and y['username'] not in self._exclude)
                 ],
                                                key=lambda y:
                                                (y['uid'] not in notbuiltin, y[
                                                    'username']))
            ])

            self.widget = FilteredSelectJSON(attrs=self.widget.attrs,
                                             url=reverse('api_dispatch_list',
                                                         kwargs=kwargs),
                                             choices=ulist)
Exemple #6
0
    def _reroll(self):
        from freenasUI.account.forms import FilteredSelectJSON
        try:
            users = FreeNAS_Users(flags=FLAGS_DBINIT | FLAGS_CACHE_READ_USER)
        except:
            users = []
        kwargs = {
            'api_name': 'v1.0',
            'resource_name': 'account/all_users'
        }
        if len(users) > 500:
            if self.initial:
                self.choices = ((self.initial, self.initial),)
            if len(self._exclude) > 0:
                kwargs['exclude'] = ','.join(self._exclude)
            self.widget = FilteredSelectJSON(
                attrs=self.widget.attrs,
                url=reverse('api_dispatch_list', kwargs=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(
                [(x.pw_name, x.pw_name, ) for x in sorted([y for y in users if (
                            y is not None and y.pw_name not in self._exclude
                        )], key=lambda y: (y.pw_uid not in notbuiltin, y.pw_name))]
            )

            self.widget = FilteredSelectJSON(
                attrs=self.widget.attrs,
                url=reverse('api_dispatch_list', kwargs=kwargs),
                choices=ulist
            )
Exemple #7
0
 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