Skip to content

Commit

Permalink
feat(middlewared/account): add user.pop_attribute
Browse files Browse the repository at this point in the history
Ticket:	#27705
  • Loading branch information
william-gr committed Jan 9, 2018
1 parent b5f9979 commit e323cf2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/middlewared/middlewared/plugins/account.py
Expand Up @@ -345,6 +345,25 @@ async def set_attribute(self, pk, key, value):

return True

@item_method
@accepts(
Int('id'),
Str('key'),
)
async def pop_attribute(self, pk, key):
"""
Remove user general purpose `attributes` dictionary `key`.
"""
user = await self._get_instance(pk)
user.pop('group')

if key in user['attributes']:
user['attributes'].pop(key)
await self.middleware.call('datastore.update', 'account.bsdusers', pk, user, {'prefix': 'bsdusr_'})
return True
else:
return False

@accepts()
async def get_next_uid(self):
"""
Expand Down

0 comments on commit e323cf2

Please sign in to comment.