def mine(self, req): req.nav = '/mine' card = None card = req.card if card and not card.is_basic: return make(req) n, blogs = Blog.gets(card.id, blog_type='b') award = Award.get_actived() return st('/home.html', **locals())
def _q_index(self, req): card = self.card if req.get_form_var("output", None) == 'json': req.response.set_content_type('application/json; charset=utf-8') return json.dumps(card.json_dict(req.user)) elif req.get_form_var("html_widget", None): return stf("/card/utils.html", "card_widget", card=card, req=req) n, blogs = Blog.gets(card.id, blog_type='b') return st('/card/card.html', **locals())
def blogs(self, req): start = req.get_form_var('start') start = start and str(start).isdigit() and int(start) or 0 limit = 20 error = None card = self.card prefix = "%sblogs?" % card.path total, blogs = Blog.gets(card_id=self.card.id, start=start, limit=limit, blog_type='b') return st('/blog/blogs.html', **locals())
def update(self, req): req.nav = '/update' start = req.get_form_var('start') limit = req.get_form_var('count', 20) cate = req.get_form_var('cate', 'b') topic_num, topics = Topic.gets() start = start and str(start).isdigit() and int(start) or 0 limit = limit and str(limit).isdigit() and int(limit) or 0 error = None prefix = "/update?cate=%s&" % cate print 'update', error, req.get_method(), req.get_method() == "POST" if req.get_method() == "POST": text = req.get_form_var("update_text", '').strip() upload_file = req.get_form_var("update_file", None) print 'post', text, upload_file if not text and not upload_file: error = "no_data" if error is None: filename = '' ftype = '' if upload_file: filename = upload_file.tmp_filename ftype = upload_file.content_type bid = Blog.new(req.user.id, Blog.TYPE_BLOG, content=text, filename=filename, ftype=ftype) blog = Blog.get(bid) for t in blog.topics: html = str(stf("/blog/utils.html", "blog_ui", b=blog, req=req)) data = { 'html': html } #publish_channel_msg('me-topic-%s' % t.id, data) return req.redirect('%sstart=%s' % (prefix, start)) total, blogs = Blog.gets(start=start, limit=limit, blog_type=cate) if req.get_form_var("output", None) == 'json': fireworks = req.get_form_var("fireworks", None) req.response.set_content_type('application/json; charset=utf-8') d = { 'total':total, 'start':start, 'count':limit, } if fireworks: d['blogs'] = [b.fireworks_dict() for b in blogs] else: d['blogs'] = [b.json_dict(req.user) for b in blogs] return json.dumps(d) return st('/update.html', **locals())
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())