Esempio n. 1
0
 def after_thread_action_normal(self):
     self.thread.set_checkpoint(self.request, 'bogus')
     if self.thread.original_weight == 2:
         with UpdatingMonitor() as cm:
             monitor.decrease('reported_posts')
     messages.success(self.request, _('Report has been set as bogus.'),
                      'threads')
Esempio n. 2
0
 def post_form(self, form):
     self.thread.original_weight = self.thread.weight
     super(SetStateCheckpointMixin, self).post_form(form)
     if self.thread.original_weight != self.thread.weight:
         if self.thread.original_weight == 2:
             with UpdatingMonitor() as cm:
                 monitor.decrease('reported_posts')
         if self.thread.weight == 1:
             self.thread.set_checkpoint(self.request, 'resolved')
         if self.thread.weight == 0:
             self.thread.set_checkpoint(self.request, 'bogus')
Esempio n. 3
0
 def post_form(self, form):
     self.thread.original_weight = self.thread.weight
     super(SetStateCheckpointMixin, self).post_form(form)
     if self.thread.original_weight != self.thread.weight:
         if self.thread.original_weight == 2:
             with UpdatingMonitor() as cm:
                 monitor.decrease('reported_posts')
         if self.thread.weight == 1:
             self.thread.set_checkpoint(self.request, 'resolved')
         if self.thread.weight == 0:
             self.thread.set_checkpoint(self.request, 'bogus')
Esempio n. 4
0
 def thread_action_hard(self):
     # Delete thread
     self.thread.delete()
     # Update forum
     self.forum.sync()
     self.forum.save(force_update=True)
     # Update monitor
     with UpdatingMonitor() as cm:
         monitor.decrease('threads')
         monitor.decrease('posts', self.thread.replies + 1)
     self.after_thread_action_hard()
     return self.threads_list_redirect()
Esempio n. 5
0
 def thread_action_hard(self):
     # Delete thread
     self.thread.delete()
     # Update forum
     self.forum.sync()
     self.forum.save(force_update=True)
     # Update monitor
     with UpdatingMonitor() as cm:
         monitor.decrease('threads')
         monitor.decrease('posts', self.thread.replies + 1)
     self.after_thread_action_hard()
     return self.threads_list_redirect()
Esempio n. 6
0
    def action_activate(self, items, checked):
        for user in items:
            if user.pk in checked and user.activation > 0:
                with UpdatingMonitor() as cm:
                    monitor.decrease('users_inactive')
                user.activation = user.ACTIVATION_NONE
                user.save(force_update=True)
                user.email_user(
                                self.request,
                                'users/activation/admin_done',
                                _("Your Account has been activated"),
                                )

        return Message(_('Selected users accounts have been activated.'), messages.SUCCESS), reverse('admin_users')
Esempio n. 7
0
    def action_activate(self, items, checked):
        for user in items:
            if user.pk in checked and user.activation > 0:
                with UpdatingMonitor() as cm:
                    monitor.decrease('users_inactive')
                user.activation = user.ACTIVATION_NONE
                user.save(force_update=True)
                user.email_user(
                                self.request,
                                'users/activation/admin_done',
                                _("Your Account has been activated"),
                                )

        return Message(_('Selected users accounts have been activated.'), messages.SUCCESS), reverse('admin_users')
Esempio n. 8
0
 def thread_action_soft(self):
     # Update first post in thread
     self.thread.start_post.deleted = True
     self.thread.start_post.save(force_update=True)
     # Update thread
     self.thread.sync()
     self.thread.save(force_update=True)
     # Set checkpoint
     self.thread.set_checkpoint(self.request, 'deleted')
     # Update forum
     self.forum.sync()
     self.forum.save(force_update=True)
     # Update monitor
     with UpdatingMonitor() as cm:
         monitor.decrease('threads')
         monitor.decrease('posts', self.thread.replies + 1)
     self.after_thread_action_soft()
Esempio n. 9
0
 def mass_resolve(self, ids):
     reported_posts = []
     reported_threads = []
     for thread in self.threads:
         if thread.pk in ids:
             if thread.original_weight != thread.weight:
                 if thread.weight == 1:
                     thread.set_checkpoint(self.request, 'resolved')
                 if thread.weight == 0:
                     thread.set_checkpoint(self.request, 'bogus')
             if thread.original_weight == 2 and thread.report_for_id:
                 reported_posts.append(thread.report_for.pk)
                 reported_threads.append(thread.report_for.thread_id)
     if reported_threads:
         Thread.objects.filter(id__in=reported_threads).update(replies_reported=F('replies_reported') - 1)
         Post.objects.filter(id__in=reported_posts).update(reported=False, reports=None)
         with UpdatingMonitor() as cm:
             monitor.decrease('reported_posts', len(reported_threads))
Esempio n. 10
0
 def thread_action_soft(self):
     # Update first post in thread
     self.thread.start_post.deleted = True
     self.thread.start_post.edit_user = self.request.user
     self.thread.start_post.edit_user_name = self.request.user.username
     self.thread.start_post.edit_user_slug = self.request.user.username_slug
     self.thread.start_post.save(force_update=True)
     # Update thread
     self.thread.sync()
     self.thread.save(force_update=True)
     # Set checkpoint
     self.thread.set_checkpoint(self.request, 'deleted')
     # Update forum
     self.forum.sync()
     self.forum.save(force_update=True)
     # Update monitor
     with UpdatingMonitor() as cm:
         monitor.decrease('threads')
         monitor.decrease('posts', self.thread.replies + 1)
     self.after_thread_action_soft()
Esempio n. 11
0
 def after_thread_action_soft(self):
     if self.thread.original_weight == 2:
         with UpdatingMonitor() as cm:
             monitor.decrease("reported_posts")
     messages.success(self.request, _("Report has been hidden."), "threads")
Esempio n. 12
0
 def after_thread_action_normal(self):
     self.thread.set_checkpoint(self.request, "bogus")
     if self.thread.original_weight == 2:
         with UpdatingMonitor() as cm:
             monitor.decrease("reported_posts")
     messages.success(self.request, _("Report has been set as bogus."), "threads")
Esempio n. 13
0
 def after_thread_action_soft(self):
     if self.thread.original_weight == 2:
         with UpdatingMonitor() as cm:
             monitor.decrease('reported_posts')
     messages.success(self.request, _('Report has been hidden.'), 'threads')