Beispiel #1
0
 def create_topics(self, tags, users):
     """Generates a bunch of topics."""
     from solace.models import Topic
     last_date = None
     topics = []
     num, var = {
         'small': (50, 10),
         'medium': (200, 20),
         'large': (1000, 200)
     }[self.data_set_size]
     count = 0
     for locale in self.locales:
         for x in xrange(randrange(num - var, num + var)):
             topic = Topic(locale,
                           generate_lorem_ipsum(1, False, 3, 9),
                           generate_lorem_ipsum(randrange(1, 5), False, 40,
                                                140),
                           choice(users),
                           date=self.get_date(last_date))
             last_date = topic.last_change
             these_tags = list(tags[locale])
             shuffle(these_tags)
             topic.bind_tags(these_tags[:randrange(2, 6)])
             topics.append(topic)
             count += 1
     print 'Generated %d topics in %d locales' % (count, len(self.locales))
     return topics
Beispiel #2
0
 def create_topic(self, view_lang=None, user=None):
     """Creates a new topic."""
     if view_lang is None:
         view_lang = self.request.view_lang
     if user is None:
         user = self.request.user
     topic = Topic(view_lang, self['title'], self['text'], user)
     topic.bind_tags(self['tags'])
     return topic
Beispiel #3
0
 def create_topic(self, view_lang=None, user=None):
     """Creates a new topic."""
     if view_lang is None:
         view_lang = self.request.view_lang
     if user is None:
         user = self.request.user
     topic = Topic(view_lang, self['title'], self['text'], user)
     topic.bind_tags(self['tags'])
     return topic
Beispiel #4
0
 def create_topics(self, tags, users):
     """Generates a bunch of topics."""
     from solace.models import Topic
     last_date = None
     topics = []
     num, var = {'small': (50, 10), 'medium': (200, 20),
                 'large': (1000, 200)}[self.data_set_size]
     count = 0
     for locale in self.locales:
         for x in xrange(randrange(num - var, num + var)):
             topic = Topic(locale, generate_lorem_ipsum(1, False, 3, 9),
                           generate_lorem_ipsum(randrange(1, 5), False,
                                                40, 140), choice(users),
                           date=self.get_date(last_date))
             last_date = topic.last_change
             these_tags = list(tags[locale])
             shuffle(these_tags)
             topic.bind_tags(these_tags[:randrange(2, 6)])
             topics.append(topic)
             count += 1
     print 'Generated %d topics in %d locales' % (count, len(self.locales))
     return topics