Exemplo n.º 1
0
 def get(self):
     page = int(self.get_argument('page', 1))
     if self.get_argument('act', '') == 'delete':
         Comment.delete_comment_by_id(int(self.get_argument('id', 0)))
     pagesize = 20
     rtn = Comment.get_comments(pagesize=pagesize)
     self.datamap['comments'] = rtn[1]
     self.datamap['count'] = rtn[0]
     self.datamap['pagecount'] = int(math.ceil(float(rtn[0]) / pagesize))
     self.write(render_admin.comment(self.datamap))
Exemplo n.º 2
0
    def get(self, nodeid, topicid):
        t_key = 't-%s-%s' % (str(nodeid), str(topicid))
        t_obj = Topic.get_by_key(t_key)
        if not t_obj or t_obj.has_key('hide'):
            self.set_status(404)
            self.echo(
                'error.html', {
                    'page': '404',
                    'title': "Can't find out this URL",
                    'h2': 'Oh, my god!',
                    'msg': 'Something seems to be lost...'
                })

            return
        if t_obj['cnum']:
            cnum = int(t_obj['cnum'])
            from_id = int(self.get_argument('id', '1'))
            if from_id > 1 and from_id % EACH_PAGE_COMMENT_NUM != 1:
                self.redirect('/' + t_key)
                return
            to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
            if to_id > cnum:
                to_id = cnum
            c_objs = Comment.get_comments(t_key, from_id, to_id)
        else:
            c_objs = None
            from_id = to_id = cnum = 0

        self.echo('topicdetail.html', {
            'title':
            t_obj['title'] + ' - ' + t_obj['nodename'],
            'description':
            'description',
            't_obj':
            t_obj,
            'c_objs':
            c_objs,
            'from_id':
            from_id,
            'to_id':
            to_id,
            'cnum':
            cnum,
            'newest_node':
            Node.get_newest(),
            'recent_node':
            Node.get_recent_node(),
            'hot_node':
            Node.get_hot_node(),
            'recent_topic_objs':
            Commomkvdb.get_comment_topic_by_keys('recent-topic-home'),
            'comment_topic_objs':
            Commomkvdb.get_comment_topic_by_keys('recent-comment-topic-home'),
        },
                  layout='_layout.html')
Exemplo n.º 3
0
    def get(self, nodeid, topicid):
        topic_key = '%s-%s' % (nodeid, topicid)
        t_obj = Topic.get_by_key_name(topic_key)
        if not t_obj:
            self.error(404)
            self.echo(
                'error.html', {
                    'page': '404',
                    'title': "Can't find out this URL",
                    'h2': 'Oh, my god!',
                    'msg': 'Something seems to be lost...'
                })
            return

        if t_obj.cnum:
            from_id = int(self.request.get('id', '1'))
            if from_id > 1 and from_id % EACH_PAGE_COMMENT_NUM != 1:
                self.redirect('/t-' + topic_key)
                return
            to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
            if to_id > t_obj.cnum:
                to_id = t_obj.cnum
            c_objs = Comment.get_comments(topic_key, from_id, to_id)
        else:
            c_objs = None
            from_id = to_id = cnum = 0

        self.echo(
            'topicdetail.html',
            {
                'title':
                t_obj.title + ' - ' + t_obj.node.name,
                'description':
                'description',
                't_obj':
                t_obj,
                'c_objs':
                c_objs,
                'from_id':
                from_id,
                'to_id':
                to_id,
                'newest_node':
                Node.get_newest(),
                #'recent_node': Node.get_recent_node(),
                'hot_node':
                Node.get_hot_node(),
                'recent_topic_objs':
                KeyStrValue.get_topic_key_title('recent-topic-home'),
                'reply_topic_objs':
                KeyStrValue.get_topic_key_title('recent-reply-topic'),
            },
            layout='_layout.html')
Exemplo n.º 4
0
 def get(self, nodeid, topicid):
     t_key = 't-%s-%s' % (str(nodeid), str(topicid))
     t_obj = Topic.get_by_key(t_key)
     if not t_obj or t_obj.has_key('hide'):
         self.set_status(404)
         self.echo('error.html', {
             'page': '404',
             'title': "Can't find out this URL",
             'h2': 'Oh, my god!',
             'msg': 'Something seems to be lost...'
         })
         
         return
     if t_obj['cnum']:
         cnum = int(t_obj['cnum'])
         from_id = int(self.get_argument('id', '1'))
         if from_id>1 and from_id%EACH_PAGE_COMMENT_NUM!=1:
             self.redirect('/'+t_key)
             return
         to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
         if to_id > cnum:
             to_id = cnum
         c_objs = Comment.get_comments(t_key, from_id, to_id)
     else:
         c_objs = None
         from_id = to_id = cnum = 0
         
     self.echo('topicdetail.html', {
         'title': t_obj['title'] + ' - ' + t_obj['nodename'],
         'description':'description',
         't_obj': t_obj,
         'c_objs': c_objs,
         'from_id': from_id,
         'to_id': to_id,
         'cnum': cnum,
         'newest_node': Node.get_newest(),
         'recent_node': Node.get_recent_node(),
         'hot_node': Node.get_hot_node(),
         'recent_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-topic-home'),
         'comment_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-comment-topic-home'),            
     }, layout='_layout.html')
Exemplo n.º 5
0
 def get(self, nodeid, topicid):
     topic_key = '%s-%s' % (nodeid, topicid)
     t_obj = Topic.get_by_key_name(topic_key)
     if not t_obj:
         self.error(404)
         self.echo('error.html', {
             'page': '404',
             'title': "Can't find out this URL",
             'h2': 'Oh, my god!',
             'msg': 'Something seems to be lost...'
         })
         return
     
     if t_obj.cnum:
         from_id = int(self.request.get('id', '1'))
         if from_id>1 and from_id%EACH_PAGE_COMMENT_NUM!=1:
             self.redirect('/t-'+topic_key)
             return
         to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
         if to_id > t_obj.cnum:
             to_id = t_obj.cnum
         c_objs = Comment.get_comments(topic_key, from_id, to_id)
     else:
         c_objs = None
         from_id = to_id = cnum = 0
     
     self.echo('topicdetail.html', {
         'title': t_obj.title + ' - ' + t_obj.node.name,
         'description':'description',
         't_obj': t_obj,
         'c_objs': c_objs,
         'from_id': from_id,
         'to_id': to_id,
         'newest_node': Node.get_newest(),
         'recent_node': Node.get_recent_node(),
         'hot_node': Node.get_hot_node(),
         'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
         'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),
     }, layout='_layout.html')