Browse Source

Small changes in thread types API

Ralfp 12 years ago
parent
commit
7e969bb5e1
2 changed files with 12 additions and 6 deletions
  1. 9 3
      misago/apps/threads/posting.py
  2. 3 3
      misago/apps/threadtype/mixins.py

+ 9 - 3
misago/apps/threads/posting.py

@@ -42,8 +42,14 @@ class EditThreadView(EditThreadBaseView, TypeMixin):
         return redirect(reverse('thread', kwargs={'thread': self.thread.pk, 'slug': self.thread.slug}) + ('#post-%s' % self.post.pk))
 
 
-class NewReplyView(NewReplyBaseView, TypeMixin):
-    pass
+class NewReplyView(NewReplyBaseView, RedirectToPostMixin, TypeMixin):
+    def response(self):
+        if self.post.moderated:
+            request.messages.set_flash(Message(_("Your reply has been posted. It will be hidden from other members until moderator reviews it.")), 'success', 'threads_%s' % self.post.pk)
+        else:
+            request.messages.set_flash(Message(_("Your reply has been posted.")), 'success', 'threads_%s' % self.post.pk)
+        return self.redirect_to_post(post)
+
 
-class EditReplyView(EditReplyBaseView, TypeMixin):
+class EditReplyView(EditReplyBaseView, RedirectToPostMixin, TypeMixin):
     pass

+ 3 - 3
misago/apps/threadtype/mixins.py

@@ -25,8 +25,8 @@ class ValidateThreadNameMixin(object):
 
 
 class RedirectToPostMixin(object):
-    def _redirect_to_post(self, link, post):
+    def redirect_to_post(self, post):
         pagination = make_pagination(0, self.request.acl.threads.filter_posts(self.request, self.thread, self.thread.post_set).filter(id__lte=post.pk).count(), self.request.settings.posts_per_page)
         if pagination['total'] > 1:
-            return redirect(reverse(link, kwargs={'thread': self.thread.pk, 'slug': self.thread.slug, 'page': pagination['total']}) + ('#post-%s' % post.pk))
-        return redirect(reverse(link, kwargs={'thread': self.thread.pk, 'slug': self.thread.slug}) + ('#post-%s' % post.pk))
+            return redirect(reverse(self.thread_url, kwargs={'thread': self.thread.pk, 'slug': self.thread.slug, 'page': pagination['total']}) + ('#post-%s' % post.pk))
+        return redirect(reverse(self.thread_url, kwargs={'thread': self.thread.pk, 'slug': self.thread.slug}) + ('#post-%s' % post.pk))