Beispiel #1
0
 def cards(self, req):
     req.nav = '/cards'
     cate = req.get_form_var('cate', '')
     start = req.get_form_var('start')
     start = start and str(start).isdigit() and int(start) or 0
     limit = 32
     total, cards = Card.gets(cate, start, limit)
     prefix = "/cards?cate=%s&" % cate
     if req.get_form_var("output", None) == 'json':
         req.response.set_content_type('application/json; charset=utf-8')
         r = {
                 "cards": [c.json_dict(req.user) for c in cards]
         }
         return json.dumps(r)
     return st('/cards/cards.html', **locals())
Beispiel #2
0
    def _q_index(self, req):
        print 'Enter into index.'
        if req.card and not req.card.is_basic:
            return req.redirect('/mine')
        req.nav = '/'
        card = req.card
        photo_num, photo_cards = Card.gets(cate='photo', limit=20)

        all_badages = Badage.gets()

        num, blogs = Blog.gets(limit=30)
        num, photo_blogs = Blog.get_photo_blogs(limit=40)
        photo_blogs = [b for b in photo_blogs if b.n_unlike == 0]
        num, event_photos = EventPhoto.gets(limit=20)
        new_photos = sorted(photo_blogs + event_photos + photo_cards, key=attrgetter('sort_time'), reverse=True)
        print 'Index...'
        return st('/index.html', **locals())