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

Created development branch, started refractoring

Ralfp 12 лет назад
Родитель
Сommit
15300637ba
2 измененных файлов с 44 добавлено и 4 удалено
  1. 4 4
      misago/threads/urls.py
  2. 40 0
      misago/threads/views/posting.py

+ 4 - 4
misago/threads/urls.py

@@ -3,7 +3,7 @@ from django.conf.urls import patterns, url
 urlpatterns = patterns('misago.threads.views',
     url(r'^forum/(?P<slug>(\w|-)+)-(?P<forum>\d+)/$', 'ThreadsView', name="forum"),
     url(r'^forum/(?P<slug>(\w|-)+)-(?P<forum>\d+)/(?P<page>\d+)/$', 'ThreadsView', name="forum"),
-    url(r'^forum/(?P<slug>(\w|-)+)-(?P<forum>\d+)/new/$', 'PostingView', name="thread_new", kwargs={'mode': 'new_thread'}),
+    url(r'^forum/(?P<slug>(\w|-)+)-(?P<forum>\d+)/new/$', 'PostingNewThreadView', name="thread_new"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/$', 'ThreadView', name="thread"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/last/$', 'LastReplyView', name="thread_last"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/find-(?P<post>\d+)/$', 'FindReplyView', name="thread_find"),
@@ -17,9 +17,9 @@ urlpatterns = patterns('misago.threads.views',
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/unwatch/email/$', 'UnwatchEmailThreadView', name="thread_unwatch_email"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<page>\d+)/$', 'ThreadView', name="thread"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/reply/$', 'PostingView', name="thread_reply", kwargs={'mode': 'new_post'}),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<quote>\d+)/reply/$', 'PostingView', name="thread_reply", kwargs={'mode': 'new_post'}),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/edit/$', 'PostingView', name="thread_edit", kwargs={'mode': 'edit_thread'}),
-    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/edit/$', 'PostingView', name="post_edit", kwargs={'mode': 'edit_post'}),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<quote>\d+)/reply/$', 'PostingNewReplyView', name="thread_reply"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/edit/$', 'PostingEditThreadView', name="thread_edit"),
+    url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/edit/$', 'PostingEditReplyView', name="post_edit"),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/delete/$', 'DeleteView', name="thread_delete", kwargs={'mode': 'delete_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/hide/$', 'DeleteView', name="thread_hide", kwargs={'mode': 'hide_thread'}),
     url(r'^thread/(?P<slug>(\w|-)+)-(?P<thread>\d+)/(?P<post>\d+)/delete/$', 'DeleteView', name="post_delete", kwargs={'mode': 'delete_post'}),

+ 40 - 0
misago/threads/views/posting.py

@@ -17,6 +17,46 @@ from misago.views import error403, error404
 from misago.utils import make_pagination, slugify, ugettext_lazy
 from misago.watcher.models import ThreadWatch
 
+
+class PostingBaseView(BaseView):
+    def __call__(self, request, **kwargs):
+        self.request = request
+
+        # Empty context attributes
+        self.forum = None
+        self.thread = None
+        self.quote = None
+        self.post = None
+
+        # Let inheriting class  set context
+        self.set_context()
+
+        # And set forum parents for render
+        self.parents = Forum.objects.forum_parents(self.forum.pk, True)
+
+        # Create form instance
+        
+
+    def set_context(self):
+        raise NotImplementedError(u"\"set_context\" method should be implemented in inheriting objects.")
+
+
+class PostingNewThreadView(PostingBaseView):
+    pass
+
+
+class PostingEditThreadView(PostingBaseView):
+    pass
+
+
+class PostingNewReplyView(PostingBaseView):
+    pass
+
+
+class PostingEditReplyView(PostingBaseView):
+    pass
+
+
 class PostingView(BaseView):
     def fetch_target(self, kwargs):
         if self.mode == 'new_thread':