コード例 #1
0
ファイル: modelpost.py プロジェクト: asdlei99/enkiWS
 def get_thread_data(cls,
                     thread_selected,
                     post_requested=POST_DEFAULT,
                     post_count=POSTS_PER_PAGE):
     # get posts by thread
     forums_url = enki.libutil.get_local_url('forums')
     thread = EnkiModelThread.get_by_id(int(thread_selected))
     thread_url = enki.libutil.get_local_url(
         'thread', {'thread': str(thread_selected)})
     forum = EnkiModelForum.get_by_id(thread.forum)
     forum_url = enki.libutil.get_local_url('forum',
                                            {'forum': str(forum.key.id())})
     if post_requested == cls.POST_LAST:
         post_requested = thread.num_posts
     list = cls.fetch_by_thread(int(thread_selected),
                                offset=(int(post_requested) - 1),
                                limit=int(post_count))
     if list:
         for i, item in enumerate(list):
             item.author_data = EnkiModelDisplayName.get_user_id_display_name_url(
                 EnkiModelDisplayName.get_by_user_id_current(item.author))
             item.post_page = enki.libutil.get_local_url(
                 'post', {'post': str(item.key.id())})
             item.sticky = True if (item.sticky_order > 0) else False
             list[i] = item
     thread_data = threadData(forums_url, forum, forum_url, thread,
                              thread_url, list,
                              enki.libutil.markdown_escaped_extras,
                              thread_selected)
     return thread_data
コード例 #2
0
ファイル: modelpost.py プロジェクト: asdlei99/enkiWS
 def get_author_posts(cls, author_selected):
     # get posts by author to display on their profile. If the author hasn't set a display name, return nothing
     author_display_name = EnkiModelDisplayName.get_by_user_id_current(
         int(author_selected))
     if author_display_name:
         forums_url = enki.libutil.get_local_url('forums')
         author_data = EnkiModelDisplayName.get_user_id_display_name_url(
             author_display_name)
         list = cls.fetch_by_author(int(author_selected))
         if list:
             for i, item in enumerate(list):
                 thread = EnkiModelThread.get_by_id(item.thread)
                 forum = EnkiModelForum.get_by_id(thread.forum)
                 item.thread_title = thread.title
                 item.thread_url = enki.libutil.get_local_url(
                     'thread', {'thread': str(item.thread)})
                 item.forum_title = forum.title
                 item.forum_group = forum.group
                 item.forum_url = enki.libutil.get_local_url(
                     'forum', {'forum': str(forum.key.id())})
                 item.post_page = enki.libutil.get_local_url(
                     'post', {'post': str(item.key.id())})
                 item.sticky = True if (item.sticky_order > 0) else False
                 list[i] = item
         author_posts_data = authorpostsData(
             forums_url, author_data, list,
             enki.libutil.markdown_escaped_extras)
         return author_posts_data
コード例 #3
0
 def get_friends_user_id_display_name_url(cls, user_id):
     friend_list = []
     list = cls.get_friends_user_id(user_id)
     if list:
         for friend_id in list:
             friend = EnkiModelDisplayName.get_user_id_display_name_url(
                 EnkiModelDisplayName.get_by_user_id_current(friend_id))
             friend_list.append(friend)
     return friend_list
コード例 #4
0
 def get_messages(cls, user_id):
     list = cls.fetch_by_recipient(user_id)
     message_list = []
     if list:
         for i, item in enumerate(list):
             entity = EnkiModelDisplayName.get_by_user_id_current(
                 item.sender)
             sender = EnkiModelDisplayName.get_user_id_display_name_url(
                 entity)
             type = item.type
             message_id = item.key.id()
             message = messageData(message_id, type, sender)
             message_list.append(message)
         return message_list
コード例 #5
0
ファイル: modelpost.py プロジェクト: asdlei99/enkiWS
 def get_post_data(cls, post_selected):
     # get a post
     forums_url = enki.libutil.get_local_url('forums')
     post = cls.get_by_id(int(post_selected))
     sticky = True if (post.sticky_order > 0) else False
     post_page = enki.libutil.get_local_url('post',
                                            {'post': str(post.key.id())})
     thread = EnkiModelThread.get_by_id(post.thread)
     thread_url = enki.libutil.get_local_url(
         'thread', {'thread': str(thread.key.id())})
     forum = EnkiModelForum.get_by_id(thread.forum)
     forum_url = enki.libutil.get_local_url('forum',
                                            {'forum': str(forum.key.id())})
     author_data = EnkiModelDisplayName.get_user_id_display_name_url(
         EnkiModelDisplayName.get_by_user_id_current(post.author))
     post_data = postData(forums_url, forum, forum_url, thread, thread_url,
                          post, sticky, post_page, author_data,
                          enki.libutil.markdown_escaped_extras)
     return post_data
コード例 #6
0
 def get_forum_data(cls, forum_selected):
     forums_url = enki.libutil.get_local_url('forums')
     forum = EnkiModelForum.get_by_id(int(forum_selected))
     num_posts = 0
     threads = cls.fetch_by_forum(int(forum_selected))
     if threads:
         for i, thread in enumerate(threads):
             num_posts += thread.num_posts
             url = enki.libutil.get_local_url(
                 'thread', {'thread': str(thread.key.id())})
             thread.url = url
             thread.author_data = EnkiModelDisplayName.get_user_id_display_name_url(
                 EnkiModelDisplayName.get_by_user_id_current(thread.author))
             thread.sticky = True if (thread.sticky_order > 0) else False
             threads[i] = thread
     forum_data = forumData(forums_url, forum, num_posts, threads,
                            enki.libutil.markdown_escaped_extras,
                            forum_selected)
     return forum_data