コード例 #1
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     user_id = force_int(self.get_argument('user_id', 0), 0)
     current_user = self.current_user
     user = User.get(id=user_id)
     if not user:
         category = self.get_argument('category', 'all')
         return self.render("user/message_box.html",
                            category=category,
                            page=page)
     message_box = current_user.get_message_box(user=user)
     if not message_box:
         result = {"status": "error", "message": "无此私信"}
         return self.send_result(result)
     form = MessageForm()
     self.render("user/message.html",
                 user=user,
                 message_box=message_box,
                 form=form,
                 page=page)
     if message_box.status == 0:
         message_box.status = 1
         try:
             orm.commit()
         except:
             pass
コード例 #2
0
ファイル: image.py プロジェクト: znanl/collipa
 def get(self):
     album_id = self.get_argument('album_id', None)
     from_id = force_int(self.get_argument('from_id', 0), 0)
     limit = force_int(self.get_argument('limit', config.paged), config.paged)
     if not album_id:
         result = {'status': 'error', 'message': '没有指定专辑'}
         return self.write(result)
     images = Image.query_by_album_id(album_id, from_id=from_id, limit=limit + 1)
     has_more = len(images) > limit
     object_list = []
     for image in images:
         object_list.append(image.to_dict())
     return self.send_success_result(object_list=object_list, has_more=has_more)
コード例 #3
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     limit = 12
     hot_users = User.get_users(category='hot', limit=limit)
     new_users = User.get_users(category='new', limit=limit)
     page_count = 0
     users = []
     url = '/users'
     if category == 'all':
         user_count = orm.count(User.get_users(page=None))
         page_count = (user_count + config.user_paged - 1) // config.user_paged
         users = User.get_users(page=page)
         url = '/users?category=all'
     elif category == 'online':
         online_members = User.get_online_members()
         online_members = [int(i) for i in online_members]
         user_count = len(online_members)
         online_members = online_members[(page - 1) * config.user_paged: page * config.user_paged]
         users = User.select(lambda rv: rv.id in online_members)
         page_count = (user_count + config.user_paged - 1) // config.user_paged
         url = '/users?category=online'
     return self.render("user/show.html", users=users, hot_users=hot_users,
                        new_users=new_users, page=page,
                        page_count=page_count, url=url, category=category)
コード例 #4
0
ファイル: topic.py プロジェクト: wbbim/collipa
 def get(self, topic_id):
     topic_id = int(topic_id)
     page = force_int(self.get_argument('page', 0), 0)
     topic = Topic.get(id=topic_id)
     if not topic:
         raise tornado.web.HTTPError(404)
     category = self.get_argument('category', None)
     if not category:
         category = 'all'
     if category == 'all':
         reply_count = topic.reply_count
         url = topic.url
     elif category == 'hot':
         reply_count = orm.count(
             topic.get_replies(page=None, category=category))
         url = topic.url + '?category=hot'
     page_count = (reply_count + config.reply_paged -
                   1) // config.reply_paged
     if page == 0:
         page = page_count
     replies = topic.get_replies(page=page, category=category)
     form = ReplyForm()
     return self.render("topic/index.html",
                        topic=topic,
                        replies=replies,
                        form=form,
                        category=category,
                        page=page,
                        page_count=page_count,
                        url=url)
コード例 #5
0
 def post(self):
     user_id = force_int(self.get_argument('user_id', 0), 0)
     sender = self.current_user
     receiver = User.get(id=user_id)
     if receiver:
         form = MessageForm(self.request.arguments)
         if form.validate():
             message = form.save(sender_id=sender.id,
                                 receiver_id=receiver.id)
             result = {
                 "status": "success",
                 "message": "私信发送成功",
                 "content": message.content,
                 "created": message.created,
                 "avatar": sender.get_avatar(size=48),
                 "url": sender.url,
                 "id": message.id,
             }
         else:
             result = {"status": "error", "message": "请填写至少 4 字的内容"}
         self.send_result(result)
         self.finish()
         return WebSocketHandler.send_message(message.receiver_id, message)
     result = {"status": "error", "message": "没有目标用户,不能发送私信哦"}
     self.send_result(result)
コード例 #6
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     limit = 12
     hot_users = User.get_users(category='hot', limit=limit)
     new_users = User.get_users(category='new', limit=limit)
     page_count = 0
     users = []
     url = '/users'
     if category == 'all':
         user_count = orm.count(User.get_users(page=None))
         page_count = (user_count + config.user_paged -
                       1) // config.user_paged
         users = User.get_users(page=page)
         url = '/users?category=all'
     elif category == 'online':
         online_members = User.get_online_members()
         online_members = [int(i) for i in online_members]
         user_count = len(online_members)
         online_members = online_members[(page - 1) *
                                         config.user_paged:page *
                                         config.user_paged]
         users = User.select(lambda rv: rv.id in online_members)
         page_count = (user_count + config.user_paged -
                       1) // config.user_paged
         url = '/users?category=online'
     return self.render("user/show.html",
                        users=users,
                        hot_users=hot_users,
                        new_users=new_users,
                        page=page,
                        page_count=page_count,
                        url=url,
                        category=category)
コード例 #7
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def post(self):
     user_id = force_int(self.get_argument('user_id', 0), 0)
     sender = self.current_user
     receiver = User.get(id=user_id)
     if receiver:
         form = MessageForm(self.request.arguments)
         if form.validate():
             message = form.save(sender_id=sender.id,
                                 receiver_id=receiver.id)
             result = {
                 "status": "success",
                 "message": "私信发送成功",
                 "content": message.content,
                 "created": message.created,
                 "avatar": sender.get_avatar(size=48),
                 "url": sender.url,
                 "id": message.id,
             }
         else:
             result = {"status": "error", "message": "请填写至少 4 字的内容"}
         self.send_result(result)
         self.finish()
         return WebSocketHandler.send_message(message.receiver_id, message)
     result = {"status": "error", "message": "没有目标用户,不能发送私信哦"}
     self.send_result(result)
コード例 #8
0
ファイル: image.py プロジェクト: wbbim/collipa
 def get(self):
     album_id = self.get_argument('album_id', None)
     from_id = force_int(self.get_argument('from_id', 0), 0)
     limit = force_int(self.get_argument('limit', config.paged),
                       config.paged)
     if not album_id:
         result = {'status': 'error', 'message': '没有指定专辑'}
         return self.write(result)
     images = Image.query_by_album_id(album_id,
                                      from_id=from_id,
                                      limit=limit + 1)
     has_more = len(images) > limit
     object_list = []
     for image in images:
         object_list.append(image.to_dict())
     return self.send_success_result(object_list=object_list,
                                     has_more=has_more)
コード例 #9
0
ファイル: topic.py プロジェクト: wbbim/collipa
 def get(self):
     node_id = force_int(self.get_argument('node_id', 0), 0)
     node = Node.get(id=node_id)
     if node:
         selected = node.name
     else:
         selected = None
     choices = Node.get_node_choices()
     form = TopicForm.init(choices=choices, selected=selected)
     return self.render("topic/create.html", form=form, node=node)
コード例 #10
0
ファイル: topic.py プロジェクト: lansheng228/collipa
 def get(self):
     node_id = force_int(self.get_argument('node_id', 0), 0)
     node = Node.get(id=node_id)
     if node:
         selected = node.name
     else:
         selected = None
     choices = Node.get_node_choices()
     form = TopicForm.init(choices=choices, selected=selected)
     return self.render("topic/create.html", form=form, node=node)
コード例 #11
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     user_id = force_int(self.get_argument('user_id', 0), 0)
     current_user = self.current_user
     user = User.get(id=user_id)
     if not user:
         category = self.get_argument('category', 'all')
         return self.render("user/message_box.html",
                            category=category, page=page)
     message_box = current_user.get_message_box(user=user)
     if not message_box:
         result = {"status": "error", "message": "无此私信"}
         return self.send_result(result)
     form = MessageForm()
     self.render("user/message.html", user=user, message_box=message_box,
                 form=form, page=page)
     if message_box.status == 0:
         message_box.status = 1
         try:
             orm.commit()
         except:
             pass
コード例 #12
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def post(self):
     action = self.get_argument('action', None)
     if action != "read":
         return
     user_id = force_int(self.get_argument('user_id', 0), 0)
     current_user = self.current_user
     user = User.get(id=user_id)
     if not user:
         return self.send_error(404)
     message_box = current_user.get_message_box(user=user)
     if not message_box:
         return self.send_error(404)
     message_box.status = 1
     return self.send_success_result(msg="已读")
コード例 #13
0
 def post(self):
     action = self.get_argument('action', None)
     if action != "read":
         return
     user_id = force_int(self.get_argument('user_id', 0), 0)
     current_user = self.current_user
     user = User.get(id=user_id)
     if not user:
         return self.send_error(404)
     message_box = current_user.get_message_box(user=user)
     if not message_box:
         return self.send_error(404)
     message_box.status = 1
     return self.send_success_result(msg="已读")
コード例 #14
0
ファイル: node.py プロジェクト: cc272309126/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     page_count = 0
     nodes = []
     category = self.get_argument('category', None)
     hot_nodes = Node.get_nodes(category='hot', limit=8)
     new_nodes = Node.get_nodes(category='new', limit=8)
     url = '/nodes'
     if category == 'all':
         nodes = Node.get_nodes(category='all', page=page)
         node_count = orm.count(Node.get_nodes(page=None))
         page_count = (node_count + config.node_paged - 1) // config.node_paged
         url = '/nodes?category=' + category
     return self.render("node/show.html", hot_nodes=hot_nodes,
                        new_nodes=new_nodes, nodes=nodes, category=category, page=page,
                        page_count=page_count, url=url)
コード例 #15
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     page_count = 0
     nodes = []
     category = self.get_argument('category', None)
     hot_nodes = Node.get_nodes(category='hot', limit=8)
     new_nodes = Node.get_nodes(category='new', limit=8)
     url = '/nodes'
     if category == 'all':
         nodes = Node.get_nodes(category='all', page=page)
         node_count = orm.count(Node.get_nodes(page=None))
         page_count = (node_count + config.node_paged - 1) // config.node_paged
         url = '/nodes?category=' + category
     return self.render("node/show.html", hot_nodes=hot_nodes,
                        new_nodes=new_nodes, nodes=nodes, category=category, page=page,
                        page_count=page_count, url=url)
コード例 #16
0
ファイル: topic.py プロジェクト: lansheng228/collipa
 def post(self):
     node_id = force_int(self.get_argument('node_id', 0), 0)
     node = Node.get(id=node_id)
     user = self.current_user
     form = TopicForm(self.request.arguments)
     if form.validate():
         topic = form.save(user=user)
         topic.put_notifier()
         result = {'status': 'success', 'message': '主题创建成功',
                   'topic_url': topic.url}
         if self.is_ajax:
             return self.write(result)
         self.flash_message(**result)
         return self.redirect(topic.url)
     if self.is_ajax:
         return self.write(form.result)
     return self.render("topic/create.html", form=form, node=node)
コード例 #17
0
 def post(self):
     node_id = force_int(self.get_argument('node_id', 0), 0)
     node = Node.get(id=node_id)
     user = self.current_user
     form = TopicForm(self.request.arguments)
     if form.validate():
         topic = form.save(user=user)
         topic.put_notifier()
         result = {'status': 'success', 'message': '主题创建成功',
                   'topic_url': topic.url}
         if self.is_ajax:
             return self.write(result)
         self.flash_message(**result)
         return self.redirect(topic.url)
     if self.is_ajax:
         return self.write(form.result)
     return self.render("topic/create.html", form=form, node=node)
コード例 #18
0
 def get(self, urlname, view='index', category='all'):
     page = force_int(self.get_argument('page', 1), 1)
     user = User.get(urlname=urlname)
     if not user:
         raise tornado.web.HTTPError(404)
     action = self.get_argument('action', None)
     if action and self.current_user:
         if action == 'follow' and user != self.current_user:
             result = self.current_user.follow(whom_id=user.id)
             return self.send_result(result)
     items = []
     item_count = 0
     url = user.url
     if view == 'topics':
         items = user.get_topics(page=page, category=category)
         item_count = orm.count(
             user.get_topics(page=None, category=category))
         url += '/topics'
     elif view == 'replies':
         items = user.get_replies(page=page, category=category)
         item_count = orm.count(
             user.get_replies(page=None, category=category))
         url += '/replies'
     elif view == 'followings':
         items = user.get_followings(page=page)
         item_count = orm.count(user.get_followings(page=None))
         url += '/followings'
     elif view == 'followers':
         items = user.get_followers(page=page)
         item_count = orm.count(user.get_followers(page=None))
         url += '/followers'
     elif view == 'albums':
         items = user.get_albums(page=page)
         item_count = orm.count(user.get_albums(page=None))
         url += '/albums'
     page_count = (item_count + config.paged - 1) // config.paged
     return self.render("user/index.html",
                        user=user,
                        items=items,
                        view=view,
                        category=category,
                        page=page,
                        page_count=page_count,
                        url=url)
コード例 #19
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     view = self.get_argument('view', 'all')
     user = self.current_user
     if not category:
         category = self.index_category
     else:
         self.set_index_category(category)
     if category == 'timeline' and not user:
         category = self.set_index_category('index')
     if category == 'hot':
         topics = mc.get('hot_topics')
         if not topics:
             now = int(time.time())
             ago = now - 60 * 60 * 24
             topics = orm.select(
                 rv for rv in Topic if rv.created_at > ago
             ).order_by(lambda: orm.desc(
                 (rv.collect_count + rv.thank_count - rv.report_count) * 10
                 + (rv.up_count - rv.down_count) * 5 + rv.reply_count * 3))
             mc.set('hot_topics', list(topics), 60 * 60 * 2)
     elif category == 'timeline':
         topics = user.get_followed_topics(page=None, category=view)
     elif category == 'latest':
         topics = orm.select(
             rv for rv in Topic).order_by(lambda: orm.desc(rv.created_at))
     elif category == 'desert':
         topics = orm.select(rv for rv in Topic if rv.reply_count ==
                             0).order_by(lambda: orm.desc(rv.created_at))
     else:
         topics = orm.select(
             rv
             for rv in Topic).order_by(lambda: orm.desc(rv.last_reply_date))
     topic_count = orm.count(topics)
     topics = topics[(page - 1) * config.paged:page * config.paged]
     page_count = (topic_count + config.paged - 1) // config.paged
     return self.render("site/index.html",
                        topics=topics,
                        category=category,
                        page=page,
                        view=view,
                        page_count=page_count,
                        url='/')
コード例 #20
0
ファイル: site.py プロジェクト: cc272309126/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     view = self.get_argument('view', 'all')
     user = self.current_user
     if not category:
         category = self.index_category
     else:
         self.set_index_category(category)
     if category == 'timeline' and not user:
         category = self.set_index_category('index')
     if category == 'hot':
         topics = mc.get('hot_topics')
         if not topics:
             now = int(time.time())
             ago = now - 60 * 60 * 24
             topics = orm.select(rv for rv in Topic if
                                 rv.created_at > ago).order_by(lambda:
                                                               orm.desc((rv.collect_count + rv.thank_count
                                                                         - rv.report_count) * 10 +
                                                                        (rv.up_count - rv.down_count) * 5 +
                                                                        rv.reply_count * 3))
             mc.set('hot_topics', list(topics), 60 * 60 * 2)
     elif category == 'timeline':
         topics = user.get_followed_topics(page=None, category=view)
     elif category == 'latest':
         topics = orm.select(rv for rv in Topic).order_by(lambda:
                                                          orm.desc(rv.created_at))
     elif category == 'desert':
         topics = orm.select(rv for rv in Topic if rv.reply_count == 0).order_by(lambda:
                                                                                 orm.desc(rv.created_at))
     else:
         topics = orm.select(rv for rv in Topic).order_by(lambda: orm.desc(rv.last_reply_date))
     if isinstance(topics, list):
         topic_count = len(topics)
     else:
         topic_count = orm.count(topics)
     topics = topics[(page - 1) * config.paged: page * config.paged]
     page_count = (topic_count + config.paged - 1) // config.paged
     return self.render("site/index.html", topics=topics, category=category,
                        page=page, view=view, page_count=page_count, url='/')
コード例 #21
0
ファイル: node.py プロジェクト: lansheng228/collipa
 def get(self):
     page = force_int(self.get_argument("page", 1), 1)
     page_count = 0
     nodes = []
     category = self.get_argument("category", None)
     hot_nodes = Node.get_nodes(category="hot", limit=8)
     new_nodes = Node.get_nodes(category="new", limit=8)
     url = "/nodes"
     if category == "all":
         nodes = Node.get_nodes(category="all", page=page)
         node_count = orm.count(Node.get_nodes(page=None))
         page_count = (node_count + config.node_paged - 1) // config.node_paged
         url = "/nodes?category=" + category
     return self.render(
         "node/show.html",
         hot_nodes=hot_nodes,
         new_nodes=new_nodes,
         nodes=nodes,
         category=category,
         page=page,
         page_count=page_count,
         url=url,
     )
コード例 #22
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def get(self, urlname, view='index', category='all'):
     page = force_int(self.get_argument('page', 1), 1)
     user = User.get(urlname=urlname)
     if not user:
         raise tornado.web.HTTPError(404)
     action = self.get_argument('action', None)
     if action and self.current_user:
         if action == 'follow' and user != self.current_user:
             result = self.current_user.follow(whom_id=user.id)
             return self.send_result(result)
     items = []
     item_count = 0
     url = user.url
     if view == 'topics':
         items = user.get_topics(page=page, category=category)
         item_count = orm.count(user.get_topics(page=None, category=category))
         url += '/topics'
     elif view == 'replies':
         items = user.get_replies(page=page, category=category)
         item_count = orm.count(user.get_replies(page=None, category=category))
         url += '/replies'
     elif view == 'followings':
         items = user.get_followings(page=page)
         item_count = orm.count(user.get_followings(page=None))
         url += '/followings'
     elif view == 'followers':
         items = user.get_followers(page=page)
         item_count = orm.count(user.get_followers(page=None))
         url += '/followers'
     elif view == 'albums':
         items = user.get_albums(page=page)
         item_count = orm.count(user.get_albums(page=None))
         url += '/albums'
     page_count = (item_count + config.paged - 1) // config.paged
     return self.render("user/index.html", user=user, items=items,
                        view=view, category=category, page=page,
                        page_count=page_count, url=url)
コード例 #23
0
ファイル: topic.py プロジェクト: lansheng228/collipa
 def get(self, topic_id):
     topic_id = int(topic_id)
     page = force_int(self.get_argument('page', 0), 0)
     topic = Topic.get(id=topic_id)
     if not topic:
         raise tornado.web.HTTPError(404)
     category = self.get_argument('category', None)
     if not category:
         category = 'all'
     if category == 'all':
         reply_count = topic.reply_count
         url = topic.url
     elif category == 'hot':
         reply_count = orm.count(topic.get_replies(page=None,
                                                   category=category))
         url = topic.url + '?category=hot'
     page_count = (reply_count + config.reply_paged - 1) // config.reply_paged
     if page == 0:
         page = page_count
     replies = topic.get_replies(page=page, category=category)
     form = ReplyForm()
     return self.render("topic/index.html", topic=topic, replies=replies,
                        form=form, category=category, page=page,
                        page_count=page_count, url=url)
コード例 #24
0
ファイル: node.py プロジェクト: zky001/collipa
 def get(self, urlname, category='all'):
     node = Node.get(urlname=urlname)
     if not node:
         raise tornado.web.HTTPError(404)
     page = force_int(self.get_argument('page', 1), 1)
     action = self.get_argument('action', None)
     tag = self.get_argument('tag', None)
     if tag:
         if tag == 'description':
             result = {
                 'status': 'success',
                 'message': '简介传输成功',
                 'node_description': node.description,
                 'node_topic_count': node.topic_count,
                 'node_follow_count': node.follow_count,
             }
             return self.write(result)
         if tag == 'relationship':
             parent_nodes = node.parent_nodes
             child_nodes = node.child_nodes
             sibling_nodes = node.sibling_nodes
             parent_json = []
             children_json = []
             sibling_json = []
             for p in parent_nodes:
                 parent_json.append(
                     dict(id=p.id,
                          name=p.name,
                          url=p.url,
                          description=p.description,
                          summary=p.summary,
                          urlname=p.urlname,
                          icon=p.icon))
             for c in child_nodes:
                 children_json.append(
                     dict(id=c.id,
                          name=c.name,
                          url=c.url,
                          description=c.description,
                          summary=c.summary,
                          urlname=c.urlname,
                          icon=c.icon))
             for s in sibling_nodes:
                 sibling_json.append(
                     dict(id=s.id,
                          name=s.name,
                          url=s.url,
                          description=s.description,
                          summary=s.summary,
                          urlname=s.urlname,
                          icon=s.icon))
             result = {
                 'status': 'success',
                 'parent_nodes': parent_json,
                 'child_nodes': children_json,
                 'sibling_nodes': sibling_json
             }
             return self.write(result)
     user = self.current_user
     if action and user:
         if action == 'follow':
             result = user.follow(node_id=node.id)
             if self.is_ajax:
                 return self.write(result)
             self.flash_message(**result)
             return self.redirect_next_url()
     topic_count = orm.count(node.get_topics(page=None, category=category))
     page_count = (topic_count + config.reply_paged -
                   1) // config.reply_paged
     url = node.url + '?category=' + category
     topics = node.get_topics(page=page, category=category)
     return self.render("node/index.html",
                        node=node,
                        topics=topics,
                        category=category,
                        page=page,
                        page_count=page_count,
                        url=url)
コード例 #25
0
ファイル: _base.py プロジェクト: lansheng228/collipa
 def page(self):
     return force_int(self.get_argument("page", 1))
コード例 #26
0
ファイル: node.py プロジェクト: cc272309126/collipa
 def get(self, urlname, category='all'):
     node = Node.get(urlname=urlname)
     if not node:
         raise tornado.web.HTTPError(404)
     page = force_int(self.get_argument('page', 1), 1)
     action = self.get_argument('action', None)
     tag = self.get_argument('tag', None)
     if tag:
         if tag == 'description':
             result = {
                 'status': 'success',
                 'message': '简介传输成功',
                 'node_description': node.description,
                 'node_topic_count': node.topic_count,
                 'node_follow_count': node.follow_count,
             }
             return self.write(result)
         if tag == 'relationship':
             parent_nodes = node.parent_nodes
             child_nodes = node.child_nodes
             sibling_nodes = node.sibling_nodes
             parent_json = []
             children_json = []
             sibling_json = []
             for p in parent_nodes:
                 parent_json.append(dict(id=p.id, name=p.name,
                                         url=p.url,
                                         description=p.description,
                                         summary=p.summary,
                                         urlname=p.urlname,
                                         icon=p.icon))
             for c in child_nodes:
                 children_json.append(dict(id=c.id, name=c.name,
                                           url=c.url,
                                           description=c.description,
                                           summary=c.summary,
                                           urlname=c.urlname,
                                           icon=c.icon))
             for s in sibling_nodes:
                 sibling_json.append(dict(id=s.id, name=s.name,
                                          url=s.url,
                                          description=s.description,
                                          summary=s.summary,
                                          urlname=s.urlname,
                                          icon=s.icon))
             result = {
                 'status': 'success',
                 'parent_nodes': parent_json,
                 'child_nodes': children_json,
                 'sibling_nodes': sibling_json
             }
             return self.write(result)
     user = self.current_user
     if action and user:
         if action == 'follow':
             result = user.follow(node_id=node.id)
             if self.is_ajax:
                 return self.write(result)
             self.flash_message(**result)
             return self.redirect_next_url()
     topic_count = orm.count(node.get_topics(page=None, category=category))
     page_count = (topic_count + config.reply_paged - 1) // config.reply_paged
     url = node.url + '?category=' + category
     topics = node.get_topics(page=page, category=category)
     return self.render("node/index.html", node=node, topics=topics,
                        category=category, page=page,
                        page_count=page_count, url=url)
コード例 #27
0
ファイル: _base.py プロジェクト: cc272309126/collipa
 def page(self):
     return force_int(self.get_argument('page', 1))
コード例 #28
0
ファイル: node.py プロジェクト: lansheng228/collipa
 def get(self, urlname, category="all"):
     node = Node.get(urlname=urlname)
     if not node:
         raise tornado.web.HTTPError(404)
     page = force_int(self.get_argument("page", 1), 1)
     action = self.get_argument("action", None)
     tag = self.get_argument("tag", None)
     if tag:
         if tag == "description":
             result = {
                 "status": "success",
                 "message": "简介传输成功",
                 "node_description": node.description,
                 "node_topic_count": node.topic_count,
                 "node_follow_count": node.follow_count,
             }
             return self.write(result)
         if tag == "relationship":
             parent_nodes = node.parent_nodes
             child_nodes = node.child_nodes
             sibling_nodes = node.sibling_nodes
             parent_json = []
             children_json = []
             sibling_json = []
             for p in parent_nodes:
                 parent_json.append(
                     dict(
                         id=p.id,
                         name=p.name,
                         url=p.url,
                         description=p.description,
                         summary=p.summary,
                         urlname=p.urlname,
                         icon=p.icon,
                     )
                 )
             for c in child_nodes:
                 children_json.append(
                     dict(
                         id=c.id,
                         name=c.name,
                         url=c.url,
                         description=c.description,
                         summary=c.summary,
                         urlname=c.urlname,
                         icon=c.icon,
                     )
                 )
             for s in sibling_nodes:
                 sibling_json.append(
                     dict(
                         id=s.id,
                         name=s.name,
                         url=s.url,
                         description=s.description,
                         summary=s.summary,
                         urlname=s.urlname,
                         icon=s.icon,
                     )
                 )
             result = {
                 "status": "success",
                 "parent_nodes": parent_json,
                 "child_nodes": children_json,
                 "sibling_nodes": sibling_json,
             }
             return self.write(result)
     user = self.current_user
     if action and user:
         if action == "follow":
             result = user.follow(node_id=node.id)
             if self.is_ajax:
                 return self.write(result)
             self.flash_message(**result)
             return self.redirect_next_url()
     topic_count = orm.count(node.get_topics(page=None, category=category))
     page_count = (topic_count + config.reply_paged - 1) // config.reply_paged
     url = node.url + "?category=" + category
     topics = node.get_topics(page=page, category=category)
     return self.render(
         "node/index.html", node=node, topics=topics, category=category, page=page, page_count=page_count, url=url
     )
コード例 #29
0
ファイル: _base.py プロジェクト: cc272309126/collipa
 def get_int(self, name, default=None):
     return force_int(self.get_argument(name, default), default)
コード例 #30
0
ファイル: _base.py プロジェクト: ywmmmw/collipa
 def page(self):
     return force_int(self.get_argument('page', 1))
コード例 #31
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', 'all')
     self.render("user/notification.html", category=category, page=page)
     return self.current_user.read_notifications()
コード例 #32
0
ファイル: _base.py プロジェクト: ywmmmw/collipa
 def get_int(self, name, default=None):
     return force_int(self.get_argument(name, default), default)
コード例 #33
0
ファイル: user.py プロジェクト: cc272309126/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', 'all')
     self.render("user/notification.html",
                 category=category, page=page)
     return self.current_user.read_notifications()