def answer_and_vote(self, topics, users):
        from solace.models import Post
        replies = {'small': 4, 'medium': 8, 'large': 12}[self.data_set_size]
        posts = [x.question for x in topics]
        last_date = topics[-1].last_change
        for topic in topics:
            for x in xrange(randrange(2, replies)):
                post = Post(topic, choice(users),
                            generate_lorem_ipsum(randrange(1, 3), False,
                                                 20, 100),
                            self.get_date(last_date))
                posts.append(post)
                last_date = post.created
        print 'Generated %d posts' % len(posts)

        votes = 0
        for post in posts:
            for x in xrange(randrange(replies * 4)):
                post = choice(posts)
                user = choice(users)
                if user != post.author:
                    if random() >= 0.05:
                        user.upvote(post)
                    else:
                        user.downvote(post)
                    votes += 1

        print 'Casted %d votes' % votes

        answered = 0
        for topic in topics:
            replies = list(topic.replies)
            if replies:
                replies.sort(key=lambda x: x.votes)
                post = choice(replies[:4])
                if post.votes > 0 and random() > 0.2:
                    topic.accept_answer(post, choice(users))
                    answered += 1

        print 'Answered %d posts' % answered
        return posts
dataset/ETHPy150Open mitsuhiko/solace/solace/scripts.py/MakeTestDataCommand.answer_and_vote/original