def update_profile(self, username, backup=False, email=None): ''' update user profile ''' self.user_exists(username) self.requires_owner_admin(username) if backup: backup = self.get_user_profile(username) # FIXME: make update_user_profile (or new method) to accept # a dict to apply not just a single key/value spec = {'_id': self.current_user} email = set_property({}, 'email', email, [basestring]) update = {'$set': email} self.user_profile(admin=True).update(spec, update, safe=True) if backup: return backup else: return True
def update_properties(self, username, backup=True, cube_quota=None): ''' update global user properties ''' self.user_exists(username) self.is_admin(username) if backup: backup = self.get_user_profile(username) spec = {'_id': username} cuba_quota = set_property({}, '_cube_quota', cube_quota, [int, float]) # FIXME: make update_user_profile (or new method) to accept # a dict to apply not just a single key/value update = {'$set': cuba_quota} result = self.user_profile(admin=True).update(spec, update, safe=True) logger.debug("user properties updated (%s): %s" % (username, result)) if backup: return backup else: return True