Example #1
0
    def merge(self, other_post):
        if self.poster_id != other_post.poster_id:
            raise ValueError("post can't be merged with other user's post")
        elif (self.poster_id is None and other_post.poster_id is None
              and self.poster_name != other_post.poster_name):
            raise ValueError("post can't be merged with other user's post")

        if self.thread_id != other_post.thread_id:
            raise ValueError(
                "only posts belonging to same thread can be merged")

        if self.is_event or other_post.is_event:
            raise ValueError("can't merge events")

        if self.pk == other_post.pk:
            raise ValueError("post can't be merged with itself")

        other_post.original = str('\n\n').join(
            (other_post.original, self.original))
        other_post.parsed = str('\n').join((other_post.parsed, self.parsed))
        update_post_checksum(other_post)

        if self.is_protected:
            other_post.is_protected = True
        if self.is_best_answer:
            self.thread.best_answer = other_post
        if other_post.is_best_answer:
            self.thread.best_answer_is_protected = other_post.is_protected

        from misago.threads.signals import merge_post
        merge_post.send(sender=self, other_post=other_post)
Example #2
0
    def merge(self, other_post):
        if self.thread_id != other_post.thread_id:
            raise ValueError(
                "only posts belonging to same thread can be merged")

        if self.is_event or other_post.is_event:
            raise ValueError("can't merge events")

        if self.pk == other_post.pk:
            raise ValueError("post can't be merged with itself")

        other_post.original = six.text_type('\n\n').join(
            (other_post.original, self.original))
        other_post.parsed = six.text_type('\n').join(
            (other_post.parsed, self.parsed))
        update_post_checksum(other_post)

        from misago.threads.signals import merge_post
        merge_post.send(sender=self, other_post=other_post)
Example #3
0
    def merge(self, other_post):
        if not self.poster_id or self.poster_id != other_post.poster_id:
            raise ValueError("post can't be merged with other user's post")

        if self.thread_id != other_post.thread_id:
            raise ValueError("only posts belonging to same thread can be merged")

        if self.is_event or other_post.is_event:
            raise ValueError("can't merge events")

        if self.pk == other_post.pk:
            raise ValueError("post can't be merged with itself")

        other_post.original = six.text_type('\n\n').join((other_post.original, self.original))
        other_post.parsed = six.text_type('\n').join((other_post.parsed, self.parsed))
        update_post_checksum(other_post)

        from misago.threads.signals import merge_post
        merge_post.send(sender=self, other_post=other_post)
Example #4
0
    def merge(self, other_post):
        if self.thread_id != other_post.thread_id:
            message = "only posts belonging to same thread can be merged"
            raise ValueError(message)

        message = "posts made by different authors can't be merged"
        if self.poster_id and other_post.poster_id:
            if self.poster_id != other_post.poster_id:
                raise ValueError(message)
        else:
            raise ValueError(message)

        if self.pk == other_post.pk:
            raise ValueError("post can't be merged with itself")

        other_post.original = '%s\n\n%s' % (other_post.original, self.original)
        other_post.parsed = '%s\n%s' % (other_post.parsed, self.parsed)
        update_post_checksum(other_post)

        from misago.threads.signals import merge_post
        merge_post.send(sender=self, other_thread=other_post)
Example #5
0
 def merge_with(self, post):
     post.post = '%s\n- - -\n%s' % (post.post, self.post)
     merge_post.send(sender=self, new_post=post)