1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-23 17:34:17 +03:00

Upgrading to new admin interface

This commit is contained in:
Adolfo Gómez García 2018-12-19 12:43:38 +01:00
parent c5d1702758
commit 1da058cec6
3 changed files with 14 additions and 5 deletions

View File

@ -113,6 +113,8 @@ class Authenticators(ModelHandler):
term = self._params['term']
limit = int(self._params.get('limit', '50'))
auth = item.getInstance()
canDoSearch = type_ == 'user' and (auth.searchUsers != auths.Authenticator.searchUsers) or (auth.searchGroups != auths.Authenticator.searchGroups)
@ -120,11 +122,13 @@ class Authenticators(ModelHandler):
self.notSupported()
if type_ == 'user':
return auth.searchUsers(term)
return auth.searchUsers(term)[:limit]
else:
return auth.searchGroups(term)
return auth.searchGroups(term)[:limit]
except Exception as e:
self.invalidResponseException('{}'.format(e))
logger.exception('Too many results: %s', e)
return [{'id': _('Too many results...'), 'name': _('Refine your query')}]
# self.invalidResponseException('{}'.format(e))
def test(self, type_):
from uds.core.Environment import Environment

View File

@ -89,11 +89,15 @@ class Users(DetailHandler):
# Extract authenticator
try:
if item is None:
return list(Users.uuid_to_id(parent.users.all().values('uuid', 'name', 'real_name', 'comments', 'state', 'staff_member', 'is_admin', 'last_access', 'parent')))
values = list(Users.uuid_to_id(parent.users.all().values('uuid', 'name', 'real_name', 'comments', 'state', 'staff_member', 'is_admin', 'last_access', 'parent')))
for res in values:
res['role'] = res['staff_member'] and (res['is_admin'] and _('Admin') or _('Staff member')) or _('User')
return values
else:
u = parent.users.get(uuid=processUuid(item))
res = model_to_dict(u, fields=('name', 'real_name', 'comments', 'state', 'staff_member', 'is_admin', 'last_access', 'parent'))
res['id'] = u.uuid
res['role'] = res['staff_member'] and (res['is_admin'] and _('Admin') or _('Staff member')) or _('User')
usr = aUser(u)
res['groups'] = [g.dbGroup().uuid for g in usr.groups()]
logger.debug('Item: {0}'.format(res))
@ -111,6 +115,7 @@ class Users(DetailHandler):
def getFields(self, parent):
return [
{'name': {'title': _('Username'), 'visible': True, 'type': 'icon', 'icon': 'fa fa-user text-success'}},
{'role': {'title': _('Role')}},
{'real_name': {'title': _('Name')}},
{'comments': {'title': _('Comments')}},
{'state': {'title': _('state'), 'type': 'dict', 'dict': State.dictionary()}},

View File

@ -54,7 +54,7 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2018-11-22'
__updated__ = '2018-12-19'
# a few constants
OVERVIEW = 'overview'