示例#1
0
def good():
    page = is_num(request.args.get('page'))
    topics = Topic.query.filter_by(is_good=True).paginate(
        page, current_app.config['PER_PAGE'],
        error_out=True)
    data = {'title': '精华文章 - ', 'topics': topics}
    return render_template('topic/topic_good.html', **data)
示例#2
0
def board(child_b):
    page = is_num(request.args.get('page'))
    if child_b is None:
        boards = Board.query.filter_by(parent_board=g.parent_b).all()
        topic_base = Topic.query.join(
            Topic.board).filter(Board.parent_board == g.parent_b)
        topics = topic_base.filter(Topic.is_top == False).paginate(
            page, 20, True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        data = {
            'title': '%s - ' % g.parent_b,
            'boards': boards,
            'topics': topics,
            'top_topics': top_topics
        }
        return render_template('board/board_list.html', **data)
    else:
        board = Board.query.filter_by(board=child_b).first_or_404()
        topic_base = board.topics
        topics = topic_base.filter(Topic.is_top == False).paginate(
            page, 20, True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        data = {
            'title': '%s - ' % board.board,
            'board': board,
            'topics': topics,
            'top_topics': top_topics
        }
        return render_template('board/board.html', **data)
示例#3
0
def userlist():
    page = is_num(request.args.get('page'))
    users = User.query.paginate(page,
                                current_app.config['PER_PAGE'],
                                error_out=True)
    data = {'title': _('Userlist - '), 'users': users}
    return render_template('forums/userlist.html', **data)
示例#4
0
文件: views.py 项目: 0xsKu/maple-bbs
def board(child_b):
    page = is_num(request.args.get('page'))
    if child_b is None:
        boards = Board.query.filter_by(parent_board=g.parent_b).all()
        topic_base = Topic.query.join(Topic.board).filter(Board.parent_board ==
                                                          g.parent_b)
        topics = topic_base.filter(Topic.is_top == False).paginate(page, 20,
                                                                   True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        data = {'title': '%s - ' % g.parent_b,
                'boards': boards,
                'topics': topics,
                'top_topics': top_topics}
        return render_template('board/board_list.html', **data)
    else:
        board = Board.query.filter_by(board=child_b).first_or_404()
        topic_base = board.topics
        topics = topic_base.filter(Topic.is_top == False).paginate(page, 20,
                                                                   True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        data = {'title': '%s - ' % board.board,
                'board': board,
                'topics': topics,
                'top_topics': top_topics}
        return render_template('board/board.html', **data)
示例#5
0
def good():
    page = is_num(request.args.get('page'))
    topics = Topic.query.filter_by(is_good=True).paginate(
        page, current_app.config['PER_PAGE'],
        error_out=True)
    data = {'title': '精华文章 - ', 'topics': topics}
    return render_template('topic/topic_good.html', **data)
示例#6
0
def userlist():
    page = is_num(request.args.get('page'))
    users = User.query.paginate(page,
                                current_app.config['PER_PAGE'],
                                error_out=True)
    data = {'title': _('Userlist - '), 'users': users}
    return render_template('forums/userlist.html', **data)
示例#7
0
 def get(self, type):
     page = is_num(request.args.get('page'))
     per_page = current_app.config['PER_PAGE']
     if type == 'tag':
         following = current_user.following_tags.paginate(
             page, per_page, False)
         return render_template('follow/following_tag.html',
                                following_type=type,
                                following=following)
     elif type == 'user':
         following = current_user.following_users.paginate(
             page, per_page, False)
         return render_template('follow/following_user.html',
                                following_type=type,
                                following=following)
     elif type == 'collect':
         following = current_user.following_collects.paginate(
             page, per_page, False)
         return render_template('follow/following_collect.html',
                                following_type=type,
                                following=following)
     else:
         following = current_user.following_topics.paginate(
             page, per_page, False)
         return render_template('follow/following_topic.html',
                                following_type=type,
                                following=following)
示例#8
0
文件: views.py 项目: 0xsKu/maple-bbs
 def get(self, type):
     page = is_num(request.args.get('page'))
     per_page = current_app.config['PER_PAGE']
     if type == 'tag':
         following = current_user.following_tags.paginate(page, per_page,
                                                          False)
         return render_template('follow/following_tag.html',
                                following_type=type,
                                following=following)
     elif type == 'user':
         following = current_user.following_users.paginate(page, per_page,
                                                           False)
         return render_template('follow/following_user.html',
                                following_type=type,
                                following=following)
     elif type == 'collect':
         following = current_user.following_collects.paginate(
             page, per_page, False)
         return render_template('follow/following_collect.html',
                                following_type=type,
                                following=following)
     else:
         following = current_user.following_topics.paginate(page, per_page,
                                                            False)
         return render_template('follow/following_topic.html',
                                following_type=type,
                                following=following)
示例#9
0
def collect():
    page = is_num(request.args.get('page'))
    collects = Collect.query.paginate(page,
                                      app.config['PER_PAGE'],
                                      error_out=True)
    data = {'type': 'collect', 'collects': collects}
    return render_template('user/user.html', **data)
示例#10
0
def follower():
    page = is_num(request.args.get('page'))
    user = User.query.filter_by(username=g.user_url).first_or_404()
    followers = user.followers.paginate(page,
                                        app.config['PER_PAGE'],
                                        error_out=True)
    data = {'type': 'follower', 'followers': followers}
    return render_template('user/user.html', **data)
示例#11
0
def reply():
    page = is_num(request.args.get('page'))
    replies = Reply.query.join(Reply.author).filter(
        User.username == g.user_url).paginate(page,
                                              app.config['PER_PAGE'],
                                              error_out=True)
    data = {'type': 'reply', 'replies': replies}
    return render_template('user/user.html', **data)
示例#12
0
def topic():
    page = is_num(request.args.get('page'))
    topics = Topic.query.join(Topic.author).filter(
        User.username == g.user_url).paginate(page,
                                              app.config['PER_PAGE'],
                                              error_out=True)
    data = {'type': 'topic', 'topics': topics}
    return render_template('user/user.html', **data)
示例#13
0
 def get(self, collectId):
     if collectId is not None:
         page = is_num(request.args.get('page'))
         collect = Collect.query.filter_by(id=collectId).first_or_404()
         topics = collect.topics.paginate(page, 10, True)
         data = {'collect': collect, 'topics': topics}
         return self.template_with_uid(data)
     else:
         return redirect(url_for('mine.collect'))
示例#14
0
 def get(self):
     page = is_num(request.args.get('page'))
     topics, top_topics = TopicModel.get_list(page)
     data = {
         'title': 'All Topics - ',
         'topics': topics,
         'top_topics': top_topics
     }
     return render_template('topic/topic.html', **data)
示例#15
0
文件: views.py 项目: 0xsKu/maple-bbs
 def get(self, collectId):
     if collectId is not None:
         page = is_num(request.args.get('page'))
         collect = Collect.query.filter_by(id=collectId).first_or_404()
         topics = collect.topics.paginate(page, 10, True)
         data = {'collect': collect, 'topics': topics}
         return self.template_with_uid(data)
     else:
         return redirect(url_for('mine.collect'))
示例#16
0
 def get(self, collectId):
     if collectId is None:
         page = is_num(request.args.get('page'))
         collects = current_user.collects.paginate(
             page, current_app.config['PER_PAGE'], error_out=True)
         data = {'collects': collects}
         return self.template_without_uid(data)
     else:
         return redirect(url_for('mine.collect_detail',
                                 collectId=collectId))
示例#17
0
文件: views.py 项目: 0xsKu/maple-bbs
 def get(self, collectId):
     if collectId is None:
         page = is_num(request.args.get('page'))
         collects = current_user.collects.paginate(page,
                                                   app.config['PER_PAGE'],
                                                   error_out=True)
         data = {'collects': collects}
         return self.template_without_uid(data)
     else:
         return redirect(url_for('mine.collect_detail',
                                 collectId=collectId))
示例#18
0
def follower():
    page = is_num(request.args.get('page'))
    order = request.args.get('orderby')
    order_list = ['publish', 'score']
    if order and order not in order_list:
        abort(404)
    user = User.query.filter_by(username=g.user_url).first_or_404()
    followers = user.followers.paginate(page,
                                        current_app.config['PER_PAGE'],
                                        error_out=True)
    data = {'type': 'follower', 'followers': followers}
    return render_template('user/user.html', **data)
示例#19
0
文件: views.py 项目: 0xsKu/maple-bbs
def collect():
    page = is_num(request.args.get('page'))
    per_page = current_app.config['PER_PAGE']
    if current_user.is_authenticated and current_user.username == g.user_url:
        collects = current_user.collects.paginate(
            page, per_page, error_out=True)
    else:
        collects = Collect.query.join(Collect.author).filter(
            Collect.is_privacy == False, User.username == g.user_url).paginate(
                page, per_page, error_out=True)
    data = {'type': 'collect', 'collects': collects}
    return render_template('user/user.html', **data)
示例#20
0
文件: views.py 项目: 0xsKu/maple-bbs
def follower():
    page = is_num(request.args.get('page'))
    order = request.args.get('orderby')
    order_list = ['publish', 'score']
    if order and order not in order_list:
        abort(404)
    user = User.query.filter_by(username=g.user_url).first_or_404()
    followers = user.followers.paginate(page,
                                        current_app.config['PER_PAGE'],
                                        error_out=True)
    data = {'type': 'follower', 'followers': followers}
    return render_template('user/user.html', **data)
示例#21
0
 def get(self, topicId):
     page = is_num(request.args.get('page'))
     order = request.args.get('orderby')
     form = ReplyForm()
     topic, replies = TopicModel.get_detail(page, topicId, order)
     data = {
         'title': '%s - ' % topic.title,
         'form': form,
         'topic': topic,
         'replies': replies
     }
     return render_template('topic/content.html', **data)
示例#22
0
def board(child_b):
    page = is_num(request.args.get('page'))
    if child_b is None:
        boards = Board.query.filter_by(parent_board=g.parent_b).all()
        topics = Topic.query.join(Topic.board).filter(
            Board.parent_board == g.parent_b).paginate(page, 20, True)
        data = {'boards': boards, 'topics': topics}
        return render_template('forums/board_list.html', **data)
    else:
        board = Board.query.filter_by(board=child_b).first_or_404()
        topics = board.topics.paginate(page, 20, True)
        data = {'board': board, 'topics': topics}
        return render_template('forums/board.html', **data)
示例#23
0
 def get(self, uid):
     page = is_num(request.args.get('page'))
     if uid is None:
         topics = Topic.query.paginate(page,
                                       app.config['PER_PAGE'],
                                       error_out=True)
         return self.template_without_uid(topics)
     else:
         form = ReplyForm()
         topic = Topic.query.filter_by(uid=str(uid)).first_or_404()
         replies = topic.replies.paginate(page, 5, True)
         RedisData.set_read_count(topic.id)
         return self.template_with_uid(form, topic, replies)
示例#24
0
def collect_detail(collectId):
    page = is_num(request.args.get('page'))
    per_page = current_app.config['PER_PAGE']
    if current_user.is_authenticated:
        collect = Collect.query.join(Collect.author).filter(
            Collect.id == collectId,
            User.username == g.user_url).first_or_404()
    else:
        collect = Collect.query.join(Collect.author).filter(
            Collect.id == collectId, Collect.is_privacy == False,
            User.username == g.user_url).first_or_404()
    topics = collect.topics.paginate(page, per_page, True)
    data = {'type': 'collect_detail', 'topics': topics, 'collect': collect}
    return render_template('user/user.html', **data)
示例#25
0
def tag(tag):
    if tag is None:
        tags = Tags.query.distinct(Tags.tagname).all()
        data = {'tags': tags}
        return render_template('forums/tag_list.html', **data)
    else:
        page = is_num(request.args.get('page'))
        topics = Topic.query.join(Topic.tags).filter(
            Tags.tagname == tag).paginate(page,
                                          app.config['PER_PAGE'],
                                          error_out=True)
        tag = Tags.query.filter_by(tagname=tag).first_or_404()
        data = {'tag': tag, 'topics': topics}
        return render_template('forums/tag.html', **data)
示例#26
0
def notice():
    page = is_num(request.args.get('page'))
    notices = Notice.query.filter_by(
        rece_id=current_user.id).order_by(Notice.publish.desc()).paginate(
            page, current_app.config['PER_PAGE'],
            error_out=True)
    unread_notices = Notice.query.filter_by(rece_id=current_user.id,
                                            is_read=False).all()
    if unread_notices:
        for notice in unread_notices:
            notice.is_read = True
        db.session.commit()
    data = {'title': _('Notice - '), 'notices': notices}
    return render_template('forums/notice.html', **data)
示例#27
0
 def get(self, child_b):
     page = is_num(request.args.get('page'))
     board = Board.query.filter_by(board=child_b).first_or_404()
     topic_base = board.topics
     topics = topic_base.filter(Topic.is_top == False).paginate(page, 20,
                                                                True)
     top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
     data = {
         'title': '%s - ' % board.board,
         'board': board,
         'topics': topics,
         'top_topics': top_topics
     }
     return render_template('board/board.html', **data)
示例#28
0
文件: views.py 项目: 0xsKu/maple-bbs
def collect_detail(collectId):
    page = is_num(request.args.get('page'))
    per_page = current_app.config['PER_PAGE']
    if current_user.is_authenticated:
        collect = Collect.query.join(Collect.author).filter(
            Collect.id == collectId,
            User.username == g.user_url).first_or_404()
    else:
        collect = Collect.query.join(Collect.author).filter(
            Collect.id == collectId, Collect.is_privacy == False,
            User.username == g.user_url).first_or_404()
    topics = collect.topics.paginate(page, per_page, True)
    data = {'type': 'collect_detail', 'topics': topics, 'collect': collect}
    return render_template('user/user.html', **data)
示例#29
0
def notice():
    page = is_num(request.args.get('page'))
    notices = Notice.query.filter_by(
        rece_id=current_user.id).order_by(Notice.publish.desc()).paginate(
            page, current_app.config['PER_PAGE'],
            error_out=True)
    unread_notices = Notice.query.filter_by(rece_id=current_user.id,
                                            is_read=False).all()
    if unread_notices:
        for notice in unread_notices:
            notice.is_read = True
        db.session.commit()
    data = {'title': _('Notice - '), 'notices': notices}
    return render_template('forums/notice.html', **data)
示例#30
0
 def get(self):
     page = is_num(request.args.get('page'))
     boards = Board.query.filter_by(parent_board=g.parent_b).all()
     topic_base = Topic.query.join(Topic.board).filter(
         Board.parent_board == g.parent_b)
     topics = topic_base.filter(Topic.is_top == False).paginate(page, 20,
                                                                True)
     top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
     data = {
         'title': '%s - ' % g.parent_b,
         'boards': boards,
         'topics': topics,
         'top_topics': top_topics
     }
     return render_template('board/board_list.html', **data)
示例#31
0
def collect():
    page = is_num(request.args.get('page'))
    per_page = current_app.config['PER_PAGE']
    if current_user.is_authenticated and current_user.username == g.user_url:
        collects = current_user.collects.paginate(page,
                                                  per_page,
                                                  error_out=True)
    else:
        collects = Collect.query.join(Collect.author).filter(
            Collect.is_privacy == False,
            User.username == g.user_url).paginate(page,
                                                  per_page,
                                                  error_out=True)
    data = {'type': 'collect', 'collects': collects}
    return render_template('user/user.html', **data)
示例#32
0
 def get(self, topicId):
     page = is_num(request.args.get('page'))
     order = request.args.get('orderby')
     if topicId is None:
         topics, top_topics = TopicModel.get_list(page)
         data = {'title': '所有主题 - ',
                 'topics': topics,
                 'top_topics': top_topics}
         return self.template_without_uid(data)
     else:
         form = ReplyForm()
         topic, replies = TopicModel.get_detail(page, topicId, order)
         data = {'title': '%s - ' % topic.title,
                 'form': form,
                 'topic': topic,
                 'replies': replies}
         return self.template_with_uid(data)
示例#33
0
 def get(self, topicId):
     page = is_num(request.args.get('page'))
     order = request.args.get('orderby')
     if topicId is None:
         topics, top_topics = TopicModel.get_list(page)
         data = {'title': '所有主题 - ',
                 'topics': topics,
                 'top_topics': top_topics}
         return self.template_without_uid(data)
     else:
         form = ReplyForm()
         topic, replies = TopicModel.get_detail(page, topicId, order)
         data = {'title': '%s - ' % topic.title,
                 'form': form,
                 'topic': topic,
                 'replies': replies}
         return self.template_with_uid(data)
示例#34
0
def reply():
    order = request.args.get('orderby')
    page = is_num(request.args.get('page'))
    all_order = ['like', 'publish']
    if order and order not in all_order:
        abort(404)
    if order == 'like':
        user = User.query.filter_by(username=g.user_url).first_or_404()
        replies = Reply.query.outerjoin(Like).filter(
            Reply.author_id == user.id).group_by(Reply.id).order_by(
                func.count(Like.id).desc()).paginate(
                    page, current_app.config['PER_PAGE'], True)
    else:
        replies = Reply.query.join(
            Reply.author).filter(User.username == g.user_url).paginate(
                page, current_app.config['PER_PAGE'], error_out=True)
    data = {'type': 'reply', 'replies': replies}
    return render_template('user/user.html', **data)
示例#35
0
def topic():
    orderby = request.args.get('orderby')
    page = is_num(request.args.get('page'))
    all_order = ['vote', 'publish']
    if orderby and orderby not in all_order:
        abort(404)
    if orderby == 'vote':
        topics = Topic.query.join(
            Topic.author).filter(User.username == g.user_url).order_by(
                Topic.vote.desc()).paginate(page,
                                            current_app.config['PER_PAGE'],
                                            error_out=True)
    else:
        topics = Topic.query.join(
            Topic.author).filter(User.username == g.user_url).paginate(
                page, current_app.config['PER_PAGE'], error_out=True)
    data = {'type': 'topic', 'topics': topics}
    return render_template('user/user.html', **data)
示例#36
0
文件: views.py 项目: 0xsKu/maple-bbs
def tag(tag):
    if tag is None:
        tags = Tags.query.distinct(Tags.tagname).all()
        data = {'title': '所有标签 - ', 'tags': tags}
        return render_template('tag/tag_list.html', **data)
    else:
        page = is_num(request.args.get('page'))
        topic_base = Topic.query.join(Topic.tags).filter(Tags.tagname == tag)
        topics = topic_base.filter(Topic.is_top == False).paginate(
            page, app.config['PER_PAGE'],
            error_out=True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        tag = Tags.query.filter_by(tagname=tag).first_or_404()
        data = {'title': '%s - ' % tag,
                'tag': tag,
                'topics': topics,
                'top_topics': top_topics}
        return render_template('tag/tag.html', **data)
示例#37
0
文件: views.py 项目: 0xsKu/maple-bbs
def topic():
    orderby = request.args.get('orderby')
    page = is_num(request.args.get('page'))
    all_order = ['vote', 'publish']
    if orderby and orderby not in all_order:
        abort(404)
    if orderby == 'vote':
        topics = Topic.query.join(Topic.author).filter(
            User.username == g.user_url).order_by(Topic.vote.desc()).paginate(
                page, current_app.config['PER_PAGE'],
                error_out=True)
    else:
        topics = Topic.query.join(Topic.author).filter(
            User.username == g.user_url).paginate(
                page, current_app.config['PER_PAGE'],
                error_out=True)
    data = {'type': 'topic', 'topics': topics}
    return render_template('user/user.html', **data)
示例#38
0
def tag(tag):
    if tag is None:
        tags = Tags.query.distinct(Tags.tagname).all()
        data = {'title': '所有标签 - ', 'tags': tags}
        return render_template('tag/tag_list.html', **data)
    else:
        page = is_num(request.args.get('page'))
        topic_base = Topic.query.join(Topic.tags).filter(Tags.tagname == tag)
        topics = topic_base.filter(Topic.is_top == False).paginate(
            page, app.config['PER_PAGE'], error_out=True)
        top_topics = topic_base.filter(Topic.is_top == True).limit(5).all()
        tag = Tags.query.filter_by(tagname=tag).first_or_404()
        data = {
            'title': '%s - ' % tag,
            'tag': tag,
            'topics': topics,
            'top_topics': top_topics
        }
        return render_template('tag/tag.html', **data)
示例#39
0
文件: views.py 项目: 0xsKu/maple-bbs
def reply():
    order = request.args.get('orderby')
    page = is_num(request.args.get('page'))
    all_order = ['like', 'publish']
    if order and order not in all_order:
        abort(404)
    if order == 'like':
        user = User.query.filter_by(username=g.user_url).first_or_404()
        replies = Reply.query.outerjoin(Like).filter(
            Reply.author_id == user.id).group_by(Reply.id).order_by(func.count(
                Like.id).desc()).paginate(page, current_app.config['PER_PAGE'],
                                          True)
    else:
        replies = Reply.query.join(Reply.author).filter(
            User.username == g.user_url).paginate(
                page, current_app.config['PER_PAGE'],
                error_out=True)
    data = {'type': 'reply', 'replies': replies}
    return render_template('user/user.html', **data)
示例#40
0
 def get(self):
     page = is_num(request.args.get('page'))
     topics = Topic.query.filter_by(is_top=True).paginate(
         page, current_app.config['PER_PAGE'], error_out=True)
     data = {'title': _('Top Topics - '), 'topics': topics}
     return render_template('topic/topic_top.html', **data)