2 from dateutil
.parser
import parse
as parse_date
6 log
= logging
.getLogger(__name__
)
10 def __init__(self
, controller
, user_info
):
11 self
.controller
= controller
12 self
._user
_info
= user_info
16 return tag
.user(self
.username
)
20 return self
._user
_info
.username
23 def display_name(self
):
24 return self
._user
_info
.display_name
27 def last_connection(self
):
28 return parse_date(self
._user
_info
.last_connection
)
32 return self
._user
_info
.access
35 def date_created(self
):
36 return self
._user
_info
.date_created
40 return not self
._user
_info
.disabled
44 return self
._user
_info
.disabled
48 return self
._user
_info
.created_by
50 async def set_password(self
, password
):
51 """Update this user's password.
53 await self
.controller
.change_user_password(self
.username
, password
)
54 self
._user
_info
.password
= password
56 async def grant(self
, acl
='login'):
57 """Set access level of this user on the controller.
59 :param str acl: Access control ('login', 'add-model', or 'superuser')
61 await self
.controller
.grant(self
.username
, acl
)
62 self
._user
_info
.access
= acl
64 async def revoke(self
):
65 """Removes all access rights for this user from the controller.
67 await self
.controller
.revoke(self
.username
)
68 self
._user
_info
.access
= ''
70 async def disable(self
):
73 await self
.controller
.disable_user(self
.username
)
74 self
._user
_info
.disabled
= True
76 async def enable(self
):
77 """Re-enable this user.
79 await self
.controller
.enable_user(self
.username
)
80 self
._user
_info
.disabled
= False