sender.post_set.all().delete() for thread in Thread.objects.filter(id__in=threads).iterator(): thread.sync() thread.save(force_update=True) delete_user_content.connect(delete_user_content_handler, dispatch_uid="delete_user_posts") def move_forum_content_handler(sender, **kwargs): Post.objects.filter(forum=sender).update(forum=kwargs["move_to"]) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_posts") def move_thread_handler(sender, **kwargs): Post.objects.filter(thread=sender).update(forum=kwargs["move_to"]) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_posts") def merge_thread_handler(sender, **kwargs): Post.objects.filter(thread=sender).update(thread=kwargs["new_thread"]) merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_posts")
rename_user.connect(rename_user_handler, dispatch_uid="rename_user_attachments") def delete_user_content_handler(sender, **kwargs): for attachment in sender.attachment_set.iterator(): if attachment.post_id: attachment.delete_from_post() attachment.delete() delete_user_content.connect(delete_user_content_handler, dispatch_uid="delete_user_attachments") def move_forum_content_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_attachments") def move_thread_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_attachments") def move_post_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to'].forum, thread=kwargs['move_to']) move_post.connect(move_thread_handler, dispatch_uid="move_post_attachments") def merge_thread_handler(sender, **kwargs):
def rename_user_handler(sender, **kwargs): Karma.objects.filter(user=sender).update( user_name=sender.username, user_slug=sender.username_slug, ) rename_user.connect(rename_user_handler, dispatch_uid="rename_user_karmas") def move_forum_content_handler(sender, **kwargs): Karma.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_karmas") def move_thread_handler(sender, **kwargs): Karma.objects.filter(thread=sender).update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_karmas") def merge_thread_handler(sender, **kwargs): Karma.objects.filter(thread=sender).update(thread=kwargs['new_thread']) merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_karmas")
email = models.BooleanField(default=False) deleted = False class Meta: app_label = 'misago' def save(self, *args, **kwargs): if not self.deleted: super(WatchedThread, self).save(*args, **kwargs) def move_forum_content_handler(sender, **kwargs): WatchedThread.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_threads_watchers") def move_thread_handler(sender, **kwargs): WatchedThread.objects.filter(forum=sender.forum_id).update( forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_watchers") def merge_thread_handler(sender, **kwargs): WatchedThread.objects.filter(thread=sender).delete() merge_thread.connect(merge_thread_handler,
from django.db import models from misago.signals import move_thread, move_thread, move_forum_content class PollOption(models.Model): poll = models.ForeignKey('Poll', related_name="option_set") forum = models.ForeignKey('Forum') thread = models.ForeignKey('Thread') name = models.CharField(max_length=255) votes = models.PositiveIntegerField(default=0) class Meta: app_label = 'misago' def move_forum_content_handler(sender, **kwargs): PollOption.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_polls_options") def move_thread_handler(sender, **kwargs): PollOption.objects.filter(thread=sender).update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_polls_options")
if removed_forums: remove_thread_prefix.send(sender=self, forums=removed_forums) self.forums.clear() for forum in new_forums: self.forums.add(forum) def move_forum_content_handler(sender, **kwargs): old_forum_prefixes = ThreadPrefix.objects.forum_prefixes(sender) new_forum_prefixes = ThreadPrefix.objects.forum_prefixes(kwargs['move_to']) bad_prefixes = list(set(new_forum_prefixes) - set(old_forum_prefixes)) if bad_prefixes: sender.thread_set.filter(prefix__in=bad_prefixes).update(prefix=None) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_threads_prefixes") def move_thread_handler(sender, **kwargs): if sender.prefix and not ThreadPrefix.objects.prefix_in_forum(sender.prefix, kwargs['move_to']): sender.prefix = None move_thread.connect(move_thread_handler, dispatch_uid="move_thread_prefixes") def merge_thread_handler(sender, **kwargs): if kwargs['new_thread'].prefix and not ThreadPrefix.objects.prefix_in_forum(kwargs['new_thread'].prefix, kwargs['new_thread'].forum): kwargs['new_thread'].prefix = None merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_prefixes")
def rename_user_handler(sender, **kwargs): Checkpoint.objects.filter(user=sender).update( user_name=sender.username, user_slug=sender.username_slug, ) rename_user.connect(rename_user_handler, dispatch_uid="rename_user_checkpoints") def move_forum_content_handler(sender, **kwargs): Checkpoint.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_checkpoints") def move_thread_handler(sender, **kwargs): Checkpoint.objects.filter(thread=sender).update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_checkpoints") def merge_thread_handler(sender, **kwargs): Checkpoint.objects.filter(thread=sender).delete() merge_thread.connect(merge_thread_handler,
forum = models.ForeignKey('Forum') thread = models.ForeignKey('Thread') starter = models.ForeignKey('User', blank=True, null=True, related_name='+') last_read = models.DateTimeField() email = models.BooleanField(default=False) deleted = False class Meta: app_label = 'misago' def save(self, *args, **kwargs): if not self.deleted: super(WatchedThread, self).save(*args, **kwargs) def move_forum_content_handler(sender, **kwargs): WatchedThread.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_threads_watchers") def move_thread_handler(sender, **kwargs): WatchedThread.objects.filter(forum=sender.forum_id).update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_watchers") def merge_thread_handler(sender, **kwargs): WatchedThread.objects.filter(thread=sender).delete() merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_watchers")
) rename_forum.connect(rename_forum_handler, dispatch_uid="rename_forum_checkpoints") def rename_user_handler(sender, **kwargs): Checkpoint.objects.filter(user=sender).update( user_name=sender.username, user_slug=sender.username_slug, ) rename_user.connect(rename_user_handler, dispatch_uid="rename_user_checkpoints") def move_forum_content_handler(sender, **kwargs): Checkpoint.objects.filter(forum=sender).update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_checkpoints") def move_thread_handler(sender, **kwargs): Checkpoint.objects.filter(thread=sender).update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_checkpoints") def merge_thread_handler(sender, **kwargs): Checkpoint.objects.filter(thread=sender).delete() merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_checkpoints")
def delete_user_content_handler(sender, **kwargs): for attachment in sender.attachment_set.iterator(): if attachment.post_id: attachment.delete_from_post() attachment.delete() delete_user_content.connect(delete_user_content_handler, dispatch_uid="delete_user_attachments") def move_forum_content_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to']) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_attachments") def move_thread_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to']) move_thread.connect(move_thread_handler, dispatch_uid="move_thread_attachments") def move_post_handler(sender, **kwargs): sender.attachment_set.update(forum=kwargs['move_to'].forum, thread=kwargs['move_to'])
self.forums.clear() for forum in new_forums: self.forums.add(forum) def move_forum_content_handler(sender, **kwargs): old_forum_prefixes = ThreadPrefix.objects.forum_prefixes(sender) new_forum_prefixes = ThreadPrefix.objects.forum_prefixes(kwargs['move_to']) bad_prefixes = list(set(new_forum_prefixes) - set(old_forum_prefixes)) if bad_prefixes: sender.thread_set.filter(prefix__in=bad_prefixes).update(prefix=None) move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_threads_prefixes") def move_thread_handler(sender, **kwargs): if sender.prefix and not ThreadPrefix.objects.prefix_in_forum( sender.prefix, kwargs['move_to']): sender.prefix = None move_thread.connect(move_thread_handler, dispatch_uid="move_thread_prefixes") def merge_thread_handler(sender, **kwargs): if kwargs['new_thread'].prefix and not ThreadPrefix.objects.prefix_in_forum( kwargs['new_thread'].prefix, kwargs['new_thread'].forum): kwargs['new_thread'].prefix = None