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

Dropped "unread private threads" tab, changed way threads are fetched and added threads jumps

Ralfp 12 лет назад
Родитель
Сommit
435370a085

+ 7 - 53
misago/apps/privatethreads/list.py

@@ -11,77 +11,31 @@ class AllThreadsListView(ThreadsListBaseView, ThreadsListModeration, TypeMixin):
         self.forum = Forum.objects.get(special='private_threads')
 
     def threads_queryset(self):
-        announcements = self.request.acl.threads.filter_threads(self.request, self.forum, self.forum.thread_set).filter(weight=2).order_by('-pk')
-        threads = self.request.acl.threads.filter_threads(self.request, self.forum, self.forum.thread_set).filter(weight__lt=2).order_by('-last')
+        return self.forum.thread_set.filter(participants__id=self.request.user.pk).order_by('-last')
 
-        # Dont display threads by ignored users (unless they are important)
-        if self.request.user.is_authenticated():
-            ignored_users = self.request.user.ignored_users()
-            if ignored_users:
-                threads = threads.extra(where=["`threads_thread`.`start_poster_id` IS NULL OR `threads_thread`.`start_poster_id` NOT IN (%s)" % ','.join([str(i) for i in ignored_users])])
+    def fetch_threads(self):
+        qs_threads = self.threads_queryset()
 
         # Add in first and last poster
         if self.request.settings.avatars_on_threads_list:
-            announcements = announcements.prefetch_related('start_poster', 'last_poster')
-            threads = threads.prefetch_related('start_poster', 'last_poster')
-
-        return announcements, threads
+            qs_threads = qs_threads.prefetch_related('start_poster', 'last_poster')
 
-    def fetch_threads(self):
-        qs_announcements, qs_threads = self.threads_queryset()
         self.count = qs_threads.count()
         self.pagination = make_pagination(self.kwargs.get('page', 0), self.count, self.request.settings.threads_per_page)
 
         tracker_forum = ThreadsTracker(self.request, self.forum)
-        for thread in list(chain(qs_announcements, qs_threads[self.pagination['start']:self.pagination['stop']])):
+        for thread in qs_threads[self.pagination['start']:self.pagination['stop']]:
             thread.is_read = tracker_forum.is_read(thread)
             self.threads.append(thread)
 
-    def threads_actions(self):
-        acl = self.request.acl.threads.get_role(self.forum)
-        actions = []
-        try:
-            if acl['can_approve']:
-                actions.append(('accept', _('Accept threads')))
-            if acl['can_pin_threads'] == 2:
-                actions.append(('annouce', _('Change to announcements')))
-            if acl['can_pin_threads'] > 0:
-                actions.append(('sticky', _('Change to sticky threads')))
-            if acl['can_pin_threads'] > 0:
-                actions.append(('normal', _('Change to standard thread')))
-            if acl['can_move_threads_posts']:
-                actions.append(('move', _('Move threads')))
-                actions.append(('merge', _('Merge threads')))
-            if acl['can_close_threads']:
-                actions.append(('open', _('Open threads')))
-                actions.append(('close', _('Close threads')))
-            if acl['can_delete_threads']:
-                actions.append(('undelete', _('Undelete threads')))
-                actions.append(('soft', _('Soft delete threads')))
-            if acl['can_delete_threads'] == 2:
-                actions.append(('hard', _('Hard delete threads')))
-        except KeyError:
-            pass
-        return actions
-
     def template_vars(self, context):
         context['tab'] = 'all'
         return context
 
 
-class NewThreadsListView(AllThreadsListView, ThreadsListModeration, TypeMixin):
-    def template_vars(self, context):
-        context['tab'] = 'new'
-        return context
-
-
 class MyThreadsListView(AllThreadsListView, ThreadsListModeration, TypeMixin):
-    def threads_actions(self):
-        return (
-                ('open', _('Open threads')),
-                ('close', _('Close threads')),
-                ('hard', _('Delete threads')),
-                )
+    def threads_queryset(self):
+        return self.forum.thread_set.filter(start_poster_id=self.request.user.pk).order_by('-last')
 
     def template_vars(self, context):
         context['tab'] = 'my'

+ 3 - 0
misago/apps/privatethreads/mixins.py

@@ -14,3 +14,6 @@ class TypeMixin(object):
         for user in self.md.mentions:
             if user not in participants and user not in mentioned:
                 self.post.mentioned.add(user)
+
+    def threads_list_redirect(self):
+        return redirect(reverse('private_threads'))

+ 14 - 2
misago/apps/privatethreads/urls.py

@@ -3,8 +3,6 @@ from django.conf.urls import patterns, url
 urlpatterns = patterns('misago.apps.privatethreads',
     url(r'^$', 'list.AllThreadsListView', name="private_threads"),
     url(r'^(?P<page>\d+)/$', 'list.AllThreadsListView', name="private_threads"),
-    url(r'^new/$', 'list.NewThreadsListView', name="new_private_threads"),
-    url(r'^new/(?P<page>\d+)/$', 'list.NewThreadsListView', name="new_private_threads"),
     url(r'^my/$', 'list.MyThreadsListView', name="my_private_threads"),
     url(r'^my/(?P<page>\d+)/$', 'list.MyThreadsListView', name="my_private_threads"),
     url(r'^start/$', 'posting.NewThreadView', name="private_thread_start"),
@@ -12,4 +10,18 @@ urlpatterns = patterns('misago.apps.privatethreads',
     url(r'^(?P<slug>(\w|-)+)-(?P<thread>\d+)/reply/$', 'posting.NewReplyView', name="private_thread_reply"),
     url(r'^(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<quote>\d+)/reply/$', 'posting.NewReplyView', name="private_thread_reply"),
     url(r'^(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/edit/$', 'posting.EditReplyView', name="private_post_edit"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/$', 'thread.ThreadView', name="private_thread"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<page>\d+)/$', 'thread.ThreadView', name="private_thread"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/last/$', 'jumps.LastReplyView', name="private_thread_last"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/find-(?P<post>\d+)/$', 'jumps.FindReplyView', name="private_thread_find"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/new/$', 'jumps.NewReplyView', name="private_thread_new"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/moderated/$', 'jumps.FirstModeratedView', name="private_thread_moderated"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/reported/$', 'jumps.FirstReportedView', name="private_thread_reported"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/show-hidden/$', 'jumps.ShowHiddenRepliesView', name="private_thread_show_hidden"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/$', 'jumps.WatchThreadView', name="private_thread_watch"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/email/$', 'jumps.WatchEmailThreadView', name="private_thread_watch_email"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/$', 'jumps.UnwatchThreadView', name="private_thread_unwatch"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/email/$', 'jumps.UnwatchEmailThreadView', name="private_thread_unwatch_email"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/upvote/$', 'jumps.UpvotePostView', name="private_post_upvote"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/downvote/$', 'jumps.DownvotePostView', name="private_post_downvote"),
 )

+ 2 - 3
templates/cranefly/private_threads/list.html

@@ -21,9 +21,8 @@
     <h1>{% trans %}Private Threads{% endtrans %}</h1>
 
     <ul class="nav nav-tabs header-tabs">
-      <li class="{% if tab == 'all' %}active{% endif %}"><a href="{% url 'private_threads' %}">{% trans %}All Threads{% endtrans %}</a></li>
-      <li class="{% if tab == 'new' %}active{% endif %}"><a href="{% url 'new_private_threads' %}">{% trans %}Unread Threads{% endtrans %}</a></li>
-      <li class="{% if tab == 'my' %}active{% endif %}"><a href="{% url 'my_private_threads' %}">{% trans %}My Threads{% endtrans %}</a></li>
+      <li class="{% if tab == 'all' %}active{% endif %}"><a href="{% url 'private_threads' %}">{% trans %}Threads I participate in{% endtrans %}</a></li>
+      <li class="{% if tab == 'my' %}active{% endif %}"><a href="{% url 'my_private_threads' %}">{% trans %}Threads I've started{% endtrans %}</a></li>
     </ul>
   </div>
 </div>