コード例 #1
0
ファイル: shop.py プロジェクト: MicroWorldwide/tweeria
    def getArtworks(self,
                    params,
                    artworks_on_page=20,
                    search={},
                    total_pages=0):
        page = 1
        if 'pa' in params:
            try:
                page = int(params['pa'])
            except Exception:
                pass

        if page > total_pages:
            page = 1

        verified = True
        if self.cur_player and 'login_admin' in self.cur_player and self.cur_player[
                'login_admin']:
            verified = 'nm'

        artworks = self.model.misc.getAllArtworks(
            limit=artworks_on_page,
            skip=(page - 1) * artworks_on_page,
            approved=True,
            search=search,
            sort_query={'approve.time': -1},
            verified=verified)

        items_ids = Set()
        for artwork in artworks:
            items_ids.add(artwork['_id'])

        item_likes = self.getLikesDict(items_ids)

        for artwork in artworks:
            artwork.update(self.getLike(item_likes, artwork['_id']))
            artwork.update(
                {'create_date_f': getReadbleTime(artwork['create_time'])})

        return miscController.formatArtworks(self, artworks)
コード例 #2
0
ファイル: shop.py プロジェクト: Ghloin/tweeria
    def getArtworks(self, params, artworks_on_page=20, search={}, total_pages=0):
        page = 1
        if 'pa' in params:
            try:
                page = int(params['pa'])
            except Exception:
                pass

        if page > total_pages:
            page = 1

        verified = True
        if self.cur_player and 'login_admin' in self.cur_player and self.cur_player['login_admin']:
            verified = 'nm'

        artworks = self.model.misc.getAllArtworks(
            limit=artworks_on_page,
            skip=(page - 1) * artworks_on_page,
            approved=True,
            search=search,
            sort_query={'approve.time': -1},
            verified=verified
        )

        items_ids = Set()
        for artwork in artworks:
            items_ids.add(artwork['_id'])

        item_likes = self.getLikesDict(items_ids)

        for artwork in artworks:
            artwork.update(self.getLike(item_likes, artwork['_id']))
            artwork.update({
            'create_date_f': getReadbleTime(artwork['create_time'])
            })

        return miscController.formatArtworks(self, artworks)
コード例 #3
0
ファイル: player.py プロジェクト: MHM5000/tweeria
        def formatArtworks(likes, artworks):

            for artwork in artworks:
                artwork.update(getLike(likes, artwork['_id']))

            return miscController.formatArtworks(self, artworks)