def _get(self, _app_uuid, _group_uuid, _user_list):
        _redis = self.application.redis

        for _user_uuid in _user_list:
            _r = self._remove(_group_uuid, _user_uuid)

        update_group_icon(_redis, _group_uuid)
        return
Exemplo n.º 2
0
    def _get(self, _app_uuid, _group_uuid, _user_list):
        if not isinstance(_user_list, list):
            self.setErrorCode(API_ERR.NOT_LIST)
            return

        _redis = self.application.redis

        # check the group belongs to app
        _key = OrgGroup.__tablename__ + ".app_uuid." + _app_uuid
        _is = _redis.sismember(_key, _group_uuid)
        if _is != True:
            self.setErrorCode(API_ERR.NO_ORG_GROUP)
            return

        for _user_uuid in _user_list:
            _r = self._remove(_group_uuid, _user_uuid)

        update_group_icon(_redis, _group_uuid)
        return
    def _get(self, _app_uuid, _group_uuid, _user_list):
        if not isinstance(_user_list, list):
            self.setErrorCode(API_ERR.NOT_LIST)
            return
        
        _redis = self.application.redis

        # check the group belongs to app
        _key = OrgGroup.__tablename__ + ".app_uuid." + _app_uuid
        _is = _redis.sismember(_key, _group_uuid)
        if _is != True:
            self.setErrorCode(API_ERR.NO_ORG_GROUP)
            return
        
        for _user_uuid in _user_list:
            _r = self._remove(_group_uuid, _user_uuid)

        update_group_icon(_redis, _group_uuid)
        return
    def _remove(self, _group_uuid, _user_uuid):
        _redis = self.application.redis
        _key = OrgUserGroupData.__tablename__ + ".group_uuid." + _group_uuid
        if _redis.sismember(_key, _user_uuid) == False:
            self.setErrorCode(API_ERR.NOT_GROUP_USER)
            logging.error("user: %s not in group:%s" % (_user_uuid, _group_uuid))
            return False

        _key = OrgUserGroupData.__tablename__ + ".group_uuid." + _group_uuid + ".user_uuid." + _user_uuid
        _data_uuid = _redis.get(_key)
        if _data_uuid == None:
            self.setErrorCode(API_ERR.NOT_GROUP_USER)
            logging.error("user: %s group:%s not bind." % (_user_uuid, _group_uuid))
            return False

        _row = OrgUserGroupData(uuid=_data_uuid)
        _row.async_delete()
        _row.delete_redis_keys(_redis)

        update_group_icon(_redis, _group_uuid)
        return True
    def _remove(self, _group_uuid, _user_uuid):
        _redis = self.application.redis
        _key = OrgUserGroupData.__tablename__ + \
               ".group_uuid." + _group_uuid
        if _redis.sismember(_key, _user_uuid) == False:
            self.setErrorCode(API_ERR.NOT_GROUP_USER)
            logging.error("user: %s not in group:%s" % (_user_uuid, _group_uuid))
            return False

        _key = OrgUserGroupData.__tablename__ + \
               ".group_uuid." + _group_uuid + \
               ".user_uuid." + _user_uuid
        _data_uuid = _redis.get(_key)
        if _data_uuid == None:
            self.setErrorCode(API_ERR.NOT_GROUP_USER)
            logging.error("user: %s group:%s not bind." % (_user_uuid, _group_uuid))
            return False
        
        _row = OrgUserGroupData(uuid=_data_uuid)
        _row.async_delete()
        _row.delete_redis_keys(_redis)

        update_group_icon(_redis, _group_uuid)
        return True