Просмотр исходного кода

further threads viewmodels cleanup

Rafał Pitoń 8 лет назад
Родитель
Сommit
803286706f

+ 1 - 1
misago/threads/api/threadpoll.py

@@ -12,7 +12,7 @@ from ..models import Poll
 from ..permissions.polls import (
     allow_see_poll_votes, allow_start_poll, allow_edit_poll, allow_delete_poll, can_start_poll)
 from ..serializers import PollSerializer, PollVoteSerializer, NewPollSerializer, EditPollSerializer
-from ..viewmodels.thread import ForumThread
+from ..viewmodels import ForumThread
 from .pollvotecreateendpoint import poll_vote_create
 
 

+ 1 - 3
misago/threads/api/threadposts.py

@@ -15,9 +15,7 @@ from ..moderation import posts as moderation
 from ..permissions.threads import (
     allow_delete_event, allow_delete_post, allow_edit_post, allow_reply_thread)
 from ..serializers import AttachmentSerializer, PostSerializer
-from ..viewmodels.post import ThreadPost
-from ..viewmodels.posts import ThreadPosts
-from ..viewmodels.thread import ForumThread
+from ..viewmodels import ForumThread, ThreadPost, ThreadPosts
 from .postingendpoint import PostingEndpoint
 from .postendpoints.edits import get_edit_endpoint, revert_post_endpoint
 from .postendpoints.likes import likes_list_endpoint

+ 1 - 1
misago/threads/api/threads.py

@@ -11,7 +11,7 @@ from misago.core.shortcuts import get_int_or_404
 
 from ..models import Post, Thread
 from ..moderation import threads as moderation
-from ..viewmodels.thread import ForumThread
+from ..viewmodels import ForumThread
 from .postingendpoint import PostingEndpoint
 from .threadendpoints.editor import thread_start_editor
 from .threadendpoints.list import threads_list_endpoint

+ 5 - 0
misago/threads/viewmodels/__init__.py

@@ -0,0 +1,5 @@
+from .category import *
+from .post import *
+from .posts import *
+from .thread import *
+from .threads import *

+ 3 - 0
misago/threads/viewmodels/category.py

@@ -8,6 +8,9 @@ from misago.core.viewmodel import ViewModel as BaseViewModel
 from misago.core.shortcuts import validate_slug
 
 
+__all__ = ['ThreadsRootCategory', 'ThreadsCategory', 'PrivateThreadsCategory']
+
+
 class ViewModel(BaseViewModel):
     def __init__(self, request, **kwargs):
         self._categories = self.get_categories(request)

+ 3 - 0
misago/threads/viewmodels/post.py

@@ -6,6 +6,9 @@ from misago.core.viewmodel import ViewModel as BaseViewModel
 from ..permissions.threads import exclude_invisible_posts
 
 
+__all__ = ['ThreadPost']
+
+
 class ViewModel(BaseViewModel):
     def __init__(self, request, thread, pk, select_for_update=False):
         model = self.get_post(request, thread, pk, select_for_update)

+ 5 - 1
misago/threads/viewmodels/posts.py

@@ -10,6 +10,9 @@ from ..serializers import PostSerializer
 from ..utils import add_likes_to_posts
 
 
+__all__ = ['ThreadPosts']
+
+
 class ViewModel(object):
     def __init__(self, request, thread, page):
         try:
@@ -19,7 +22,8 @@ class ViewModel(object):
 
         posts_queryset = self.get_queryset(request, thread_model)
 
-        list_page = paginate(posts_queryset, page, settings.MISAGO_POSTS_PER_PAGE, settings.MISAGO_POSTS_TAIL)
+        list_page = paginate(
+            posts_queryset, page, settings.MISAGO_POSTS_PER_PAGE, settings.MISAGO_POSTS_TAIL)
         paginator = pagination_dict(list_page, include_page_range=False)
 
         posts = list(list_page.object_list)

+ 8 - 0
misago/threads/viewmodels/thread.py

@@ -14,6 +14,9 @@ from ..subscriptions import make_subscription_aware
 from ..threadtypes import trees_map
 
 
+__all__ = ['ForumThread', 'PrivateThread']
+
+
 BASE_RELATIONS = (
     'category',
     'poll',
@@ -108,3 +111,8 @@ class ForumThread(ViewModel):
 
     def get_root_name(self):
         return _("Threads")
+
+
+class PrivateThread(ViewModel):
+    pass
+

+ 3 - 0
misago/threads/viewmodels/threads.py

@@ -19,6 +19,9 @@ from ..subscriptions import make_subscription_aware
 from ..utils import add_categories_to_threads
 
 
+__all__ = ['ForumThreads', 'PrivateThreads']
+
+
 LISTS_NAMES = {
     'all': None,
     'my': ugettext_lazy("Your threads"),

+ 1 - 1
misago/threads/views/goto.py

@@ -8,7 +8,7 @@ from django.views.generic import View
 from misago.conf import settings
 
 from ..permissions.threads import exclude_invisible_posts
-from ..viewmodels.thread import ForumThread
+from ..viewmodels import ForumThread
 
 
 class GotoView(View):

+ 3 - 2
misago/threads/views/list.py

@@ -4,8 +4,9 @@ from django.http import Http404
 from django.shortcuts import render
 from django.views.generic import View
 
-from ..viewmodels.category import PrivateThreadsCategory, ThreadsCategory, ThreadsRootCategory
-from ..viewmodels.threads import ForumThreads, PrivateThreads
+from ..viewmodels import (
+    PrivateThreadsCategory, ThreadsCategory, ThreadsRootCategory,
+    ForumThreads, PrivateThreads)
 
 
 class ListBase(View):

+ 1 - 2
misago/threads/views/thread.py

@@ -2,8 +2,7 @@ from django.core.urlresolvers import reverse
 from django.shortcuts import render
 from django.views.generic import View
 
-from ..viewmodels.posts import ThreadPosts
-from ..viewmodels.thread import ForumThread
+from ..viewmodels import ForumThread, ThreadPosts
 
 
 class ThreadBase(View):