Browse Source

Threads jumps implemented

Ralfp 12 years ago
parent
commit
f2874975dc

+ 49 - 0
misago/apps/threads/jumps.py

@@ -0,0 +1,49 @@
+from misago.apps.threadtype.jumps import *
+from misago.apps.threads.mixins import TypeMixin
+
+class LastReplyView(LastReplyBaseView, TypeMixin):
+    pass
+
+
+class FindReplyView(FindReplyBaseView, TypeMixin):
+    pass
+
+
+class NewReplyView(NewReplyBaseView, TypeMixin):
+    pass
+
+
+class FirstModeratedView(FirstModeratedBaseView, TypeMixin):
+    pass
+
+
+class FirstReportedView(FirstReportedBaseView, TypeMixin):
+    pass
+
+
+class ShowHiddenRepliesView(ShowHiddenRepliesBaseView, TypeMixin):
+    pass
+
+
+class WatchThreadView(WatchThreadBaseView, TypeMixin):
+    pass
+
+
+class WatchEmailThreadView(WatchEmailThreadBaseView, TypeMixin):
+    pass
+
+
+class UnwatchThreadView(UnwatchThreadBaseView, TypeMixin):
+    pass
+
+
+class UnwatchEmailThreadView(UnwatchEmailThreadBaseView, TypeMixin):
+    pass
+
+
+class UpvotePostView(UpvotePostBaseView, TypeMixin):
+    pass
+
+
+class DownvotePostView(DownvotePostBaseView, TypeMixin):
+    pass

+ 12 - 13
misago/apps/threads/urls.py

@@ -10,27 +10,26 @@ urlpatterns = patterns('misago.apps.threads',
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/edit/$', 'posting.EditReplyView', name="post_edit"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/edit/$', 'posting.EditReplyView', name="post_edit"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/$', 'thread.ThreadView', name="thread"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/$', 'thread.ThreadView', name="thread"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<page>\d+)/$', 'thread.ThreadView', name="thread"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<page>\d+)/$', 'thread.ThreadView', name="thread"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/last/$', 'jumps.LastReplyView', name="thread_last"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/find-(?P<post>\d+)/$', 'jumps.FindReplyView', name="thread_find"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/new/$', 'jumps.NewReplyView', name="thread_new"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/moderated/$', 'jumps.FirstModeratedView', name="thread_moderated"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/reported/$', 'jumps.FirstReportedView', name="thread_reported"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/show-hidden/$', 'jumps.ShowHiddenRepliesView', name="thread_show_hidden"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/$', 'jumps.WatchThreadView', name="thread_watch"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/email/$', 'jumps.WatchEmailThreadView', name="thread_watch_email"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/$', 'jumps.UnwatchThreadView', name="thread_unwatch"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/email/$', 'jumps.UnwatchEmailThreadView', name="thread_unwatch_email"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/upvote/$', 'jumps.UpvotePostView', name="post_upvote"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/downvote/$', 'jumps.DownvotePostView', name="post_downvote"),
 )
 )
 
 
 urlpatterns += patterns('misago.apps.errors',
 urlpatterns += patterns('misago.apps.errors',
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/last/$', 'error_not_implemented', name="thread_last"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/find-(?P<post>\d+)/$', 'error_not_implemented', name="thread_find"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/new/$', 'error_not_implemented', name="thread_new"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/moderated/$', 'error_not_implemented', name="thread_moderated"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/reported/$', 'error_not_implemented', name="thread_reported"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/show-hidden/$', 'error_not_implemented', name="thread_show_hidden"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/$', 'error_not_implemented', name="thread_watch"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/watch/email/$', 'error_not_implemented', name="thread_watch_email"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/$', 'error_not_implemented', name="thread_unwatch"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/email/$', 'error_not_implemented', name="thread_unwatch_email"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<quote>\d+)/reply/$', 'error_not_implemented', name="thread_reply"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/delete/$', 'error_not_implemented', name="thread_delete", kwargs={'mode': 'delete_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/delete/$', 'error_not_implemented', name="thread_delete", kwargs={'mode': 'delete_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/hide/$', 'error_not_implemented', name="thread_hide", kwargs={'mode': 'hide_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/hide/$', 'error_not_implemented', name="thread_hide", kwargs={'mode': 'hide_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/delete/$', 'error_not_implemented', name="post_delete", kwargs={'mode': 'delete_post'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/delete/$', 'error_not_implemented', name="post_delete", kwargs={'mode': 'delete_post'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/hide/$', 'error_not_implemented', name="post_hide", kwargs={'mode': 'hide_post'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/hide/$', 'error_not_implemented', name="post_hide", kwargs={'mode': 'hide_post'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/info/$', 'error_not_implemented', name="post_info"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/info/$', 'error_not_implemented', name="post_info"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/upvote/$', 'error_not_implemented', name="post_upvote"),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/downvote/$', 'error_not_implemented', name="post_downvote"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/votes/$', 'error_not_implemented', name="post_votes"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/votes/$', 'error_not_implemented', name="post_votes"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/changelog/$', 'error_not_implemented', name="changelog"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/changelog/$', 'error_not_implemented', name="changelog"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/changelog/(?P<change>\d+)/$', 'error_not_implemented', name="changelog_diff"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/changelog/(?P<change>\d+)/$', 'error_not_implemented', name="changelog_diff"),

+ 10 - 7
misago/apps/threadtype/jumps.py

@@ -9,9 +9,9 @@ from misago.messages import Message
 from misago.models import Forum, Thread, Post, Karma, WatchedThread
 from misago.models import Forum, Thread, Post, Karma, WatchedThread
 from misago.readstrackers import ThreadsTracker
 from misago.readstrackers import ThreadsTracker
 from misago.utils.pagination import make_pagination
 from misago.utils.pagination import make_pagination
-from misago.apps.threadtype.base import BaseView
+from misago.apps.threadtype.base import ViewBase
 
 
-class JumpView(BaseView):
+class JumpView(ViewBase):
     def fetch_thread(self, thread):
     def fetch_thread(self, thread):
         self.thread = Thread.objects.get(pk=thread)
         self.thread = Thread.objects.get(pk=thread)
         self.forum = self.thread.forum
         self.forum = self.thread.forum
@@ -27,8 +27,11 @@ class JumpView(BaseView):
 
 
     def __call__(self, request, slug=None, thread=None, post=None):
     def __call__(self, request, slug=None, thread=None, post=None):
         self.request = request
         self.request = request
+        self.parents = []
         try:
         try:
             self.fetch_thread(thread)
             self.fetch_thread(thread)
+            if self.forum.level:
+                self.parents = Forum.objects.forum_parents(self.forum.pk, True)
             self.check_forum_type()
             self.check_forum_type()
             if post:
             if post:
                 self.fetch_post(post)
                 self.fetch_post(post)
@@ -126,7 +129,7 @@ class WatchThreadBaseView(JumpView):
         return view(self.request)
         return view(self.request)
 
 
 
 
-class WatchEmailThreadBaseView(WatchThreadView):
+class WatchEmailThreadBaseView(WatchThreadBaseView):
     def update_watcher(self, request, watcher):
     def update_watcher(self, request, watcher):
         watcher.email = True
         watcher.email = True
         if watcher.pk:
         if watcher.pk:
@@ -135,7 +138,7 @@ class WatchEmailThreadBaseView(WatchThreadView):
             request.messages.set_flash(Message(_('This thread has been added to your watched threads list. You will also receive e-mail with notification when somebody replies to it.')), 'success', 'threads')
             request.messages.set_flash(Message(_('This thread has been added to your watched threads list. You will also receive e-mail with notification when somebody replies to it.')), 'success', 'threads')
 
 
 
 
-class UnwatchThreadBaseView(WatchThreadView):
+class UnwatchThreadBaseView(WatchThreadBaseView):
     def update_watcher(self, request, watcher):
     def update_watcher(self, request, watcher):
         watcher.deleted = True
         watcher.deleted = True
         watcher.delete()
         watcher.delete()
@@ -145,13 +148,13 @@ class UnwatchThreadBaseView(WatchThreadView):
             request.messages.set_flash(Message(_('This thread has been removed from your watched threads list.')), 'success', 'threads')
             request.messages.set_flash(Message(_('This thread has been removed from your watched threads list.')), 'success', 'threads')
 
 
 
 
-class UnwatchEmailThreadBaseView(WatchThreadView):
+class UnwatchEmailThreadBaseView(WatchThreadBaseView):
     def update_watcher(self, request, watcher):
     def update_watcher(self, request, watcher):
         watcher.email = False
         watcher.email = False
         request.messages.set_flash(Message(_('You will no longer receive e-mails with notifications when somebody replies to this thread.')), 'success', 'threads')
         request.messages.set_flash(Message(_('You will no longer receive e-mails with notifications when somebody replies to this thread.')), 'success', 'threads')
 
 
 
 
-class UpvotePostBaseView(JumpView):        
+class UpvotePostBaseView(JumpView):
     def make_jump(self):
     def make_jump(self):
         @block_guest
         @block_guest
         @check_csrf
         @check_csrf
@@ -225,7 +228,7 @@ class UpvotePostBaseView(JumpView):
         vote.score = 1
         vote.score = 1
 
 
 
 
-class DownvotePostBaseView(UpvotePostView):
+class DownvotePostBaseView(UpvotePostBaseView):
     def check_acl(self, request):
     def check_acl(self, request):
         request.acl.threads.allow_post_downvote(self.forum)
         request.acl.threads.allow_post_downvote(self.forum)
     
     

+ 1 - 0
misago/apps/threadtype/thread/views.py

@@ -160,6 +160,7 @@ class ThreadBaseView(ViewBase):
         self.kwargs = kwargs
         self.kwargs = kwargs
         self.parents = []
         self.parents = []
         self.ignored = False
         self.ignored = False
+        self.watcher = False
         self.message = request.messages.get_message('threads')
         self.message = request.messages.get_message('threads')
         try:
         try:
             self.fetch_thread()
             self.fetch_thread()