Пример #1
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")
Пример #2
0
    user = models.ForeignKey("User", null=True, blank=True, on_delete=models.SET_NULL)
    user_name = models.CharField(max_length=255, null=True, blank=True)
    user_slug = models.SlugField(max_length=255, null=True, blank=True)
    date = models.DateTimeField()
    ip = models.GenericIPAddressField()
    agent = models.CharField(max_length=255)

    class Meta:
        app_label = "misago"


def rename_user_handler(sender, **kwargs):
    PollVote.objects.filter(user=sender).update(user_name=sender.username, user_slug=sender.username_slug)


rename_user.connect(rename_user_handler, dispatch_uid="rename_user_poll_votes")


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


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


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


move_thread.connect(move_thread_handler, dispatch_uid="move_thread_polls_votes")
Пример #3
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")
Пример #4
0
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")


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")
Пример #5
0
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")
Пример #6
0
        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")
Пример #7
0
                                             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")


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):
Пример #8
0
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")
Пример #9
0
    ip = models.GenericIPAddressField()
    agent = models.CharField(max_length=255)

    class Meta:
        app_label = 'misago'


def rename_user_handler(sender, **kwargs):
    PollVote.objects.filter(user=sender).update(
        user_name=sender.username,
        user_slug=sender.username_slug,
    )


rename_user.connect(rename_user_handler, dispatch_uid="rename_user_poll_votes")


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


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


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


move_thread.connect(move_thread_handler,
                    dispatch_uid="move_thread_polls_votes")
Пример #10
0
rename_user.connect(rename_user_handler, dispatch_uid="rename_user_changes")


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'])

Пример #11
0
    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")
Пример #12
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")
Пример #13
0
                            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):
    sender.attachment_set.update(thread=kwargs['new_thread'])


merge_thread.connect(merge_thread_handler,
Пример #14
0
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")


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


sync_user_profile.connect(sync_user_handler, dispatch_uid="sync_user_posts")
Пример #15
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")
Пример #16
0
            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):
    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):
Пример #17
0
                                              user_name=sender.username,
                                              user_slug=sender.username_slug,
                                              )
rename_user.connect(rename_user_handler, dispatch_uid="rename_user_changes")


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):