Пример #1
0
 def get_items(self, _from=0):
     rows = service.get_funny_limit(_from)
     next_index = _from + rows.__len__()
     next_link = gen_link_obj("next", self.settings['HOST_FUNNY'] + "?index=%d" % next_index)
     home_link = gen_link_obj("home", self.settings['HOST'])
     funny = dump_list_view_pack(rows, next_link, home_link)
     return funny
Пример #2
0
    def get(self, *args, **kwargs):
        query_user_id = self.get_argument(ARG_USER_ID, default=None)
        if query_user_id is None:
            raise MissingArgumentError('no user to query')

        self.get_user_info()

        index = int(self.get_argument(ARG_CIRCLE_INTEREST_INDEX, default=0))

        con = service.get_connection()
        sql = 'select circle_id FROM circle_interest WHERE user_id=%s'
        rows = con.query(sql, query_user_id)
        con.close()

        interest_circle_ids = list()
        for row in rows:
            interest_circle_ids.append(row['circle_id'])

        to_index = index + MAX_INDEX_COUNT
        if to_index >= interest_circle_ids.__len__():
            to_index = interest_circle_ids.__len__()

        rows = list()
        for i in range(index, to_index):
            r = service.select_row_with_id(TABLE_CIRCLE, interest_circle_ids[i],
                                           columns=[ROW_IMAGE, ROW_SLOGAN, ROW_TITLE, ROW_HOT_COUNT])
            rows.append(r)

        next_index = to_index
        next_link = gen_link_obj("next", self.settings['HOST_CIRCLE_INTEREST'] + "?index=%d" % next_index)
        home_link = gen_link_obj("home", self.settings['HOST'])
        items = dump_list_view_pack(rows, next_link, home_link)
        self.write(items)
Пример #3
0
    def write_items(self, rows, url, index, *other_links):
        next_index = index + rows.__len__()

        if "?" in url:
            op = '&'
        else:
            op = '?'

        next_link = gen_link_obj("next", url + "%sindex=%d" % (op, next_index))
        links = list()
        links.append(next_link)
        for l in other_links:
            links.append(l)
        items = dump_list_view_pack(rows, *links)
        self.write(items)
Пример #4
0
    def get(self, *args, **kwargs):
        arg = self.get_argument(name="index", default=0)
        _from = int(arg)

        rows = service.select_rows_limit(TABLE_CIRCLE, _from, ROW_ID, ROW_IMAGE, ROW_SLOGAN, ROW_TITLE, ROW_HOT_COUNT)
        next_index = _from + rows.__len__()

        # for row in rows:
        #     service.filter_columns(row, ROW_ID, ROW_CATEGORY_ID)

        for r in rows:
            # remove hidden id
            # build image path
            image_name = r[ROW_IMAGE]
            image_path = self.settings['HOST_IMAGE'] + image_name
            r[ROW_IMAGE] = image_path
            follow_link = gen_link_obj("interest", self.settings['HOST_CIRCLE'] + "?circle_id=%d" % r[ROW_ID])
            r['link'] = follow_link

        next_link = gen_link_obj("next", self.settings['HOST_CIRCLE'] + "?index=%d" % next_index)
        home_link = gen_link_obj("home", self.settings['HOST'])
        items = dump_list_view_pack(rows, next_link, home_link)

        self.write(items)
Пример #5
0
            url_images = list()
            for image_name in image_json_array:
                image_path = self.settings['HOST_IMAGE'] + image_name
                url_images.append(image_path)

            row[ROW_IMAGE] = url_images

            '''filter hide column'''
            _hide_columns = [ROW_USER_ID, ROW_ID]
            service.filter_columns(row, *_hide_columns)

>>>>>>> 14dca0509e3022adbf5f2e64b42384b4d3e2746b
        next_index = _from + rows.__len__()
        next_link = gen_link_obj("next", self.settings['HOST_MOMENT'] + "?index=%d" % next_index)
        home_link = gen_link_obj("home", self.settings['HOST'])
        items = dump_list_view_pack(rows, next_link, home_link)
        return items

    '''获取关联的moment user'''

    def get_moment_user(self, user_id):
        return service.get_user_with(user_id)

<<<<<<< HEAD
    '''发布moment'''
=======
>>>>>>> 14dca0509e3022adbf5f2e64b42384b4d3e2746b
    def post(self, *args, **kwargs):
        # if no circle id do not allow publish
        circle_id = self.get_argument('circle_id', default=None)
Пример #6
0
 def get(self, *args, **kwargs):
     index = self.get_index()
     moment_items = self.get_moment_items(index=index)
     next_link = gen_link_obj("next", self.settings['HOST_MOMENT'] + "?index=%d" % (int(index) + 1))
     items = dump_list_view_pack(moment_items, next_link)
     self.write(items)