示例#1
0
def _reply_list_dump(reply_list, can_admin, current_user_id):
    result = []
    career_bind(reply_list, "user_id")
    ico_url_bind_with_default(tuple(i.user for i in reply_list))
    pre_user_id = None

    for reply in reply_list:
        user = reply.user
        career = reply.career
        career = " , ".join(filter(bool,career))
        if not career:
            career = 0

        user_id = user.id


        reply_tuple = (
            reply.htm, 
            reply.id, 
            can_admin or reply.can_admin(current_user_id)
        )

        if user_id == pre_user_id:
            result[-1][-1].append(reply_tuple)
        else:
            result.append(
                (url_or_id(user_id), user.name , career, user.ico, [reply_tuple])
            )

        pre_user_id = user_id
    
    return result
示例#2
0
def _reply_list_dump(reply_list, can_admin, current_user_id):
    result = []
    career_bind(reply_list, "user_id")
    ico_url_bind_with_default(tuple(i.user for i in reply_list))
    pre_user_id = None

    for reply in reply_list:
        user = reply.user
        career = reply.career
        career = " , ".join(filter(bool, career))
        if not career:
            career = 0

        user_id = user.id

        reply_tuple = (reply.htm, reply.id, can_admin
                       or reply.can_admin(current_user_id))

        if user_id == pre_user_id:
            result[-1][-1].append(reply_tuple)
        else:
            result.append((url_or_id(user_id), user.name, career, user.ico,
                           [reply_tuple]))

        pre_user_id = user_id

    return result
示例#3
0
def _get(self, func):
    key = self.get_argument('q', None)
    user_id = self.current_user_id
    result = []
    if user_id:
        name_dict, url_dict = func(user_id)
        id_list = zsite_by_key(key, name_dict, url_dict, 7)
        zsite_list = Zsite.mc_get_list(id_list)
        ico_url_bind_with_default(zsite_list)
        career_bind(zsite_list)

        for i in zsite_list:
            li = (i.name, ','.join(i.career), url_or_id(i.id), i.ico)
            result.append(li)
    #print result
    self.finish(jsonp(self, dumps(result)))