Browse Source

Small changes in moderation tools.

Ralfp 12 years ago
parent
commit
5bfb4ccb4a

+ 4 - 14
misago/apps/threadtype/list/moderation.py

@@ -218,18 +218,15 @@ class ThreadsListModeration(object):
 
 
     def _action_undelete(self, ids):
     def _action_undelete(self, ids):
         undeleted = []
         undeleted = []
-        posts = 0
         for thread in self.threads:
         for thread in self.threads:
             if thread.pk in ids and thread.deleted:
             if thread.pk in ids and thread.deleted:
                 undeleted.append(thread.pk)
                 undeleted.append(thread.pk)
-                posts += thread.replies + 1
                 thread.start_post.deleted = False
                 thread.start_post.deleted = False
                 thread.start_post.save(force_update=True)
                 thread.start_post.save(force_update=True)
+                thread.sync()
+                thread.save(force_update=True)
                 thread.set_checkpoint(self.request, 'undeleted')
                 thread.set_checkpoint(self.request, 'undeleted')
         if undeleted:
         if undeleted:
-            Thread.objects.filter(id__in=undeleted).update(deleted=False)
-            self.request.monitor['threads'] = int(self.request.monitor['threads']) + len(undeleted)
-            self.request.monitor['posts'] = int(self.request.monitor['posts']) + posts
             self.forum.sync()
             self.forum.sync()
             self.forum.save(force_update=True)
             self.forum.save(force_update=True)
         return undeleted
         return undeleted
@@ -242,18 +239,15 @@ class ThreadsListModeration(object):
 
 
     def _action_soft(self, ids):
     def _action_soft(self, ids):
         deleted = []
         deleted = []
-        posts = 0
         for thread in self.threads:
         for thread in self.threads:
             if thread.pk in ids and not thread.deleted:
             if thread.pk in ids and not thread.deleted:
                 deleted.append(thread.pk)
                 deleted.append(thread.pk)
-                posts += thread.replies + 1
                 thread.start_post.deleted = True
                 thread.start_post.deleted = True
                 thread.start_post.save(force_update=True)
                 thread.start_post.save(force_update=True)
+                thread.sync()
+                thread.save(force_update=True)
                 thread.set_checkpoint(self.request, 'deleted')
                 thread.set_checkpoint(self.request, 'deleted')
         if deleted:
         if deleted:
-            Thread.objects.filter(id__in=deleted).update(deleted=True)
-            self.request.monitor['threads'] = int(self.request.monitor['threads']) - len(deleted)
-            self.request.monitor['posts'] = int(self.request.monitor['posts']) - posts
             self.forum.sync()
             self.forum.sync()
             self.forum.save(force_update=True)
             self.forum.save(force_update=True)
         return deleted
         return deleted
@@ -266,15 +260,11 @@ class ThreadsListModeration(object):
     
     
     def _action_hard(self, ids):        
     def _action_hard(self, ids):        
         deleted = []
         deleted = []
-        posts = 0
         for thread in self.threads:
         for thread in self.threads:
             if thread.pk in ids:
             if thread.pk in ids:
                 deleted.append(thread.pk)
                 deleted.append(thread.pk)
-                posts += thread.replies + 1
                 thread.delete()
                 thread.delete()
         if deleted:
         if deleted:
-            self.request.monitor['threads'] = int(self.request.monitor['threads']) - len(deleted)
-            self.request.monitor['posts'] = int(self.request.monitor['posts']) - posts
             self.forum.sync()
             self.forum.sync()
             self.forum.save(force_update=True)
             self.forum.save(force_update=True)
         return deleted
         return deleted

+ 6 - 8
misago/apps/threadtype/thread/moderation/thread.py

@@ -102,13 +102,12 @@ class ThreadModeration(object):
         self.request.messages.set_flash(Message(_('Thread has been closed.')), 'success', 'threads')
         self.request.messages.set_flash(Message(_('Thread has been closed.')), 'success', 'threads')
 
 
     def thread_action_undelete(self):
     def thread_action_undelete(self):
-        # Update thread
-        self.thread.deleted = False
-        self.thread.replies_deleted -= 1
-        self.thread.save(force_update=True)
         # Update first post in thread
         # Update first post in thread
         self.thread.start_post.deleted = False
         self.thread.start_post.deleted = False
         self.thread.start_post.save(force_update=True)
         self.thread.start_post.save(force_update=True)
+        # Update thread
+        self.thread.sync()
+        self.thread.save(force_update=True)
         # Set checkpoint
         # Set checkpoint
         self.thread.set_checkpoint(self.request, 'undeleted')
         self.thread.set_checkpoint(self.request, 'undeleted')
         # Update forum
         # Update forum
@@ -123,13 +122,12 @@ class ThreadModeration(object):
         self.request.messages.set_flash(Message(_('Thread has been restored.')), 'success', 'threads')
         self.request.messages.set_flash(Message(_('Thread has been restored.')), 'success', 'threads')
 
 
     def thread_action_soft(self):
     def thread_action_soft(self):
-        # Update thread
-        self.thread.deleted = True
-        self.thread.replies_deleted += 1
-        self.thread.save(force_update=True)
         # Update first post in thread
         # Update first post in thread
         self.thread.start_post.deleted = True
         self.thread.start_post.deleted = True
         self.thread.start_post.save(force_update=True)
         self.thread.start_post.save(force_update=True)
+        # Update thread
+        self.thread.sync()
+        self.thread.save(force_update=True)
         # Set checkpoint
         # Set checkpoint
         self.thread.set_checkpoint(self.request, 'deleted')
         self.thread.set_checkpoint(self.request, 'deleted')
         # Update forum
         # Update forum