Exemplo n.º 1
0
    def gen_redis_kw(self):
        condition = {}
        if self.get_current_user():
            redis_kw = redisvr.smembers(CMS_CFG['redis_kw'] +
                                        self.userinfo.user_name)
        else:
            redis_kw = []

        kw_condition_arr = []
        for x in redis_kw:
            kw_condition_arr.append(x.decode('utf-8'))
        if redis_kw:
            condition['def_tag_arr'] = kw_condition_arr
        return condition
Exemplo n.º 2
0
    def list(self, catid):
        '''
        页面打开后的渲染方法,不包含 list 的查询结果与分页导航
        '''
        logger.info('Infocat input: {0}'.format(catid))
        condition = self.gen_redis_kw()
        sig = catid
        bread_title = ''
        bread_crumb_nav_str = '<li>当前位置:<a href="/">信息</a></li>'

        _catinfo = MCategory.get_by_uid(catid)
        logger.info('Infocat input: {0}'.format(_catinfo))
        if _catinfo.pid == '0000':
            pcatinfo = _catinfo
            catinfo = None
            parent_id = catid
            parent_catname = MCategory.get_by_uid(parent_id).name
            condition['parentid'] = [parent_id]
            catname = MCategory.get_by_uid(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                sig, catname)
            bread_title = '{0}'.format(catname)

        else:
            catinfo = _catinfo
            pcatinfo = MCategory.get_by_uid(_catinfo.pid)
            condition['def_cat_uid'] = [sig]
            parent_id = _catinfo.uid
            parent_catname = MCategory.get_by_uid(parent_id).name
            catname = MCategory.get_by_uid(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                parent_id, parent_catname)

            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                sig, catname)
            bread_title += '{0} - '.format(parent_catname)
            bread_title += '{0}'.format(catname)

        num = MPost.get_num_condition(condition)

        kwd = {
            'catid': catid,
            'daohangstr': bread_crumb_nav_str,
            'breadtilte': bread_title,
            'parentid': parent_id,
            'parentlist': MCategory.get_parent_list(),
            'condition': condition,
            'catname': catname,
            'rec_num': num
        }

        # cat_rec = MCategory.get_by_uid(catid)
        if self.get_current_user() and self.userinfo:
            redis_kw = redisvr.smembers(CMS_CFG['redis_kw'] +
                                        self.userinfo.user_name)
        else:
            redis_kw = []
        kw_condition_arr = []
        for the_key in redis_kw:
            kw_condition_arr.append(the_key.decode('utf-8'))
        self.render('autogen/list/list_{0}.html'.format(catid),
                    userinfo=self.userinfo,
                    kwd=kwd,
                    widget_info=kwd,
                    condition_arr=kw_condition_arr,
                    cat_enum=MCategory.get_qian2(parent_id[:2]),
                    pcatinfo=pcatinfo,
                    catinfo=catinfo)
Exemplo n.º 3
0
    def list(self, input):
        '''
        页面打开后的渲染方法,不包含 list 的查询结果与分页导航
        '''

        condition = self.gen_redis_kw()

        sig = input
        bread_title = ''
        bread_crumb_nav_str = '<li>当前位置:<a href="/">信息</a></li>'

        if input.endswith('00'):
            parent_id = input
            parent_catname = self.mappcat.get_by_id(parent_id).name
            condition['parentid'] = [parent_id]
            catname = self.mappcat.get_by_id(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                sig, catname)
            bread_title = '{1}'.format(sig, catname)

        else:
            condition['catid'] = [sig]
            parent_id = sig[:2] + '00'
            parent_catname = self.mappcat.get_by_id(parent_id).name
            catname = self.mappcat.get_by_id(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                parent_id, parent_catname)

            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(
                sig, catname)
            bread_title += '{1} - '.format(parent_id, parent_catname)
            bread_title += '{1}'.format(sig, catname)

        num = self.minfo.get_num_condition(condition)

        kwd = {
            'catid': input,
            'daohangstr': bread_crumb_nav_str,
            'breadtilte': bread_title,
            'parentid': parent_id,
            'parentlist': self.mappcat.get_parent_list(),
            'condition': condition,
            'catname': catname,
            'rec_num': num,
        }

        cat_rec = self.mappcat.get_by_uid(input)
        role_mask_idx = cat_rec.role_mask.index('1')

        if self.get_current_user():
            redis_kw = redisvr.smembers(config.redis_kw +
                                        self.userinfo.user_name)
        else:
            redis_kw = []
        kw_condition_arr = []
        for x in redis_kw:
            kw_condition_arr.append(x.decode('utf-8'))
        self.render(
            'autogen/list/list_{1}.html'.format(self.template_dir_name, input),
            userinfo=self.userinfo,
            kwd=kwd,
            widget_info=kwd,
            condition_arr=kw_condition_arr,
            cat_enum=self.mappcat.get_qian2(parent_id[:2]),
            role_mask_idx=role_mask_idx,
        )
Exemplo n.º 4
0
    def list(self, catid):
        '''
        页面打开后的渲染方法,不包含 list 的查询结果与分页导航
        '''
        print('infocat input:', catid)
        condition = self.gen_redis_kw()
        sig = catid
        bread_title = ''
        bread_crumb_nav_str = '<li>当前位置:<a href="/">信息</a></li>'

        _catinfo = self.mcat.get_by_uid(catid)
        if _catinfo.pid == '0000':
            pcatinfo = _catinfo
            catinfo = None
            parent_id = catid
            parent_catname = self.mcat.get_by_id(parent_id).name
            condition['parentid'] = [parent_id]
            catname = self.mcat.get_by_id(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(sig, catname)
            bread_title = '{1}'.format(sig, catname)

        else:
            catinfo = _catinfo
            pcatinfo = self.mcat.get_by_uid(_catinfo.pid)
            condition['catid'] = [sig]
            parent_id = _catinfo.uid
            parent_catname = self.mcat.get_by_id(parent_id).name
            catname = self.mcat.get_by_id(sig).name
            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(parent_id, parent_catname)

            bread_crumb_nav_str += '<li><a href="/list/{0}">{1}</a></li>'.format(sig, catname)
            bread_title += '{1} - '.format(parent_id, parent_catname)
            bread_title += '{1}'.format(sig, catname)

        num = self.minfo.get_num_condition(condition)

        kwd = {
            'catid': catid,
            'daohangstr': bread_crumb_nav_str,
            'breadtilte': bread_title,
            'parentid': parent_id,
            'parentlist': self.mcat.get_parent_list(),
            'condition': condition,
            'catname': catname,
            'rec_num': num,
        }

        cat_rec = self.mcat.get_by_uid(catid)

        if self.get_current_user():
            redis_kw = redisvr.smembers(config.redis_kw + self.userinfo.user_name)
        else:
            redis_kw = []
        kw_condition_arr = []
        for x in redis_kw:
            kw_condition_arr.append(x.decode('utf-8'))
        self.render('autogen/list/list_{0}.html'.format(catid),
                    userinfo=self.userinfo,
                    kwd=kwd,
                    widget_info=kwd,
                    condition_arr=kw_condition_arr,
                    cat_enum=self.mcat.get_qian2(parent_id[:2]),
                    pcatinfo = pcatinfo,
                    catinfo = catinfo,

                    )