Exemplo n.º 1
0

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):
    sender.attachment_set.update(thread=kwargs['new_thread'])

merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_attachments")


def merge_post_handler(sender, **kwargs):
    sender.attachment_set.update(post=kwargs['new_post'], session=('attachments_%s' % kwargs['new_post'].pk))

merge_thread.connect(merge_thread_handler, dispatch_uid="merge_posts_attachments")
Exemplo n.º 2
0
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")


def move_posts_handler(sender, **kwargs):
    Karma.objects.filter(post=sender).update(forum=kwargs['move_to'].forum,
                                             thread=kwargs['move_to'])


move_post.connect(move_posts_handler, dispatch_uid="move_posts_karmas")


def merge_posts_handler(sender, **kwargs):
    Karma.objects.filter(post=sender).update(post=kwargs['new_post'])
    kwargs['new_post'].upvotes += sender.upvotes
    kwargs['new_post'].downvotes += sender.downvotes
Exemplo n.º 3
0
    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")
Exemplo n.º 4
0
            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")
Exemplo n.º 5
0
                            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")


def sync_user_handler(sender, **kwargs):
    sender.posts = sender.post_set.count()


sync_user_profile.connect(sync_user_handler, dispatch_uid="sync_user_posts")
Exemplo n.º 6
0
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")


def move_posts_handler(sender, **kwargs):
    Karma.objects.filter(post=sender).update(forum=kwargs['move_to'].forum, thread=kwargs['move_to'])

move_post.connect(move_posts_handler, dispatch_uid="move_posts_karmas")


def merge_posts_handler(sender, **kwargs):
    Karma.objects.filter(post=sender).update(post=kwargs['new_post'])
    kwargs['new_post'].upvotes += sender.upvotes
    kwargs['new_post'].downvotes += sender.downvotes

merge_post.connect(merge_posts_handler, dispatch_uid="merge_posts_karmas")
Exemplo n.º 7
0
        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")
Exemplo n.º 8
0
move_forum_content.connect(move_forum_content_handler,
                           dispatch_uid="move_forum_changes")


def move_thread_handler(sender, **kwargs):
    Change.objects.filter(thread=sender).update(forum=kwargs['move_to'])


move_thread.connect(move_thread_handler, dispatch_uid="move_thread_changes")


def merge_thread_handler(sender, **kwargs):
    Change.objects.filter(thread=sender).update(thread=kwargs['new_thread'])


merge_thread.connect(merge_thread_handler,
                     dispatch_uid="merge_threads_changes")


def move_posts_handler(sender, **kwargs):
    Change.objects.filter(post=sender).update(forum=kwargs['move_to'].forum,
                                              thread=kwargs['move_to'])


move_post.connect(move_posts_handler, dispatch_uid="move_posts_changes")


def merge_posts_handler(sender, **kwargs):
    Change.objects.filter(post=sender).update(post=kwargs['new_post'])


merge_post.connect(merge_posts_handler, dispatch_uid="merge_posts_changes")
Exemplo n.º 9
0
    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")
Exemplo n.º 10
0
                                                       )

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")
Exemplo n.º 11
0
    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):
    sender.attachment_set.update(thread=kwargs['new_thread'])


merge_thread.connect(merge_thread_handler,
                     dispatch_uid="merge_threads_attachments")


def merge_post_handler(sender, **kwargs):
    sender.attachment_set.update(post=kwargs['new_post'],
                                 session=('attachments_%s' %
                                          kwargs['new_post'].pk))


merge_post.connect(merge_post_handler, dispatch_uid="merge_posts_attachments")
Exemplo n.º 12
0

def move_forum_content_handler(sender, **kwargs):
    Change.objects.filter(forum=sender).update(forum=kwargs['move_to'])

move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_changes")


def move_thread_handler(sender, **kwargs):
    Change.objects.filter(thread=sender).update(forum=kwargs['move_to'])

move_thread.connect(move_thread_handler, dispatch_uid="move_thread_changes")


def merge_thread_handler(sender, **kwargs):
    Change.objects.filter(thread=sender).update(thread=kwargs['new_thread'])

merge_thread.connect(merge_thread_handler, dispatch_uid="merge_threads_changes")


def move_posts_handler(sender, **kwargs):
    Change.objects.filter(post=sender).update(forum=kwargs['move_to'].forum, thread=kwargs['move_to'])

move_post.connect(move_posts_handler, dispatch_uid="move_posts_changes")


def merge_posts_handler(sender, **kwargs):
    Change.objects.filter(post=sender).update(post=kwargs['new_post'])

merge_post.connect(merge_posts_handler, dispatch_uid="merge_posts_changes")