Ejemplo n.º 1
0
    def test_title_from_content_object(self, content_object):
        item = Item()
        content_object.get_agenda_title_information.return_value = {
            "attr": "related_title"
        }

        self.assertEqual(item.title_information, {"attr": "related_title"})
Ejemplo n.º 2
0
 def create_assignments(self, options):
     number_of_assignments = options["assignments"]
     if number_of_assignments is None and not options["only"]:
         number_of_assignments = DEFAULT_NUMBER
     if number_of_assignments is not None and number_of_assignments > 0:
         self.stdout.write(f"Start creating {number_of_assignments} assignments ...")
         current_assignments = list(Assignment.objects.values_list("id", flat=True))
         new_assignments = []
         for i in range(number_of_assignments):
             new_assignments.append(
                 Assignment(title=get_random_string(20, self.chars), open_posts=1)
             )
         Assignment.objects.bulk_create(new_assignments)
         items = []
         lists_of_speakers = []
         for assignment in Assignment.objects.exclude(pk__in=current_assignments):
             items.append(Item(content_object=assignment))
             lists_of_speakers.append(ListOfSpeakers(content_object=assignment))
         Item.objects.bulk_create(items)
         ListOfSpeakers.objects.bulk_create(lists_of_speakers)
         self.stdout.write(
             self.style.SUCCESS(
                 f"{number_of_assignments} assignments successfully created."
             )
         )
     elif number_of_assignments is not None and number_of_assignments < 0:
         raise CommandError("Number for assignments must not be negative.")
Ejemplo n.º 3
0
    def test_title_invalid_related(self, content_object):
        item = Item()
        content_object.get_agenda_title_information.return_value = "related_title"
        del content_object.get_agenda_title_information

        with self.assertRaises(NotImplementedError):
            item.title_information
Ejemplo n.º 4
0
 def create_assignments(self, options):
     number_of_assignments = options['assignments']
     if number_of_assignments is None and not options['only']:
         number_of_assignments = DEFAULT_NUMBER
     if number_of_assignments is not None and number_of_assignments > 0:
         self.stdout.write('Start creating {} assignments ...'.format(
             number_of_assignments))
         current_assignments = list(
             Assignment.objects.values_list('id', flat=True))
         new_assignments = []
         for i in range(number_of_assignments):
             new_assignments.append(
                 Assignment(title=get_random_string(20, self.chars),
                            open_posts=1))
         Assignment.objects.bulk_create(new_assignments)
         items = []
         for assignment in Assignment.objects.exclude(
                 pk__in=current_assignments):
             items.append(Item(content_object=assignment))
         Item.objects.bulk_create(items)
         self.stdout.write(
             self.style.SUCCESS(
                 '{} assignments successfully created.'.format(
                     number_of_assignments)))
     elif number_of_assignments is not None and number_of_assignments < 0:
         raise CommandError('Number for assignments must not be negative.')
Ejemplo n.º 5
0
 def create_topics(self, options):
     number_of_topics = options['topics']
     if number_of_topics is None and not options['only']:
         number_of_topics = DEFAULT_NUMBER
     if number_of_topics is not None and number_of_topics > 0:
         self.stdout.write('Start creating {} topcis ...'.format(number_of_topics))
         current_topics = list(Topic.objects.values_list('id', flat=True))
         new_topics = []
         for i in range(number_of_topics):
             new_topics.append(Topic(title=get_random_string(20, self.chars)))
         Topic.objects.bulk_create(new_topics)
         items = []
         for topic in Topic.objects.exclude(pk__in=current_topics):
             items.append(Item(content_object=topic, type=Item.AGENDA_ITEM))
         Item.objects.bulk_create(items)
         self.stdout.write(self.style.SUCCESS('{} topcis successfully created.'.format(number_of_topics)))
     elif number_of_topics is not None and number_of_topics < 0:
         raise CommandError('Number for topics must not be negative.')
Ejemplo n.º 6
0
 def create_topics(self, options):
     number_of_topics = options["topics"]
     if number_of_topics is None and not options["only"]:
         number_of_topics = DEFAULT_NUMBER
     if number_of_topics is not None and number_of_topics > 0:
         self.stdout.write(f"Start creating {number_of_topics} topcis ...")
         current_topics = list(Topic.objects.values_list("id", flat=True))
         new_topics = []
         for i in range(number_of_topics):
             new_topics.append(Topic(title=get_random_string(20, self.chars)))
         Topic.objects.bulk_create(new_topics)
         items = []
         lists_of_speakers = []
         for topic in Topic.objects.exclude(pk__in=current_topics):
             items.append(Item(content_object=topic, type=Item.AGENDA_ITEM))
             lists_of_speakers.append(ListOfSpeakers(content_object=topic))
         Item.objects.bulk_create(items)
         ListOfSpeakers.objects.bulk_create(lists_of_speakers)
         self.stdout.write(
             self.style.SUCCESS(f"{number_of_topics} topcis successfully created.")
         )
     elif number_of_topics is not None and number_of_topics < 0:
         raise CommandError("Number for topics must not be negative.")
Ejemplo n.º 7
0
 def pre_redirect(self, request, *args, **kwargs):
     self.assignment = Assignment.objects.get(pk=kwargs['assignment_id'])
     self.item = Item(related_sid=self.assignment.sid)
     self.item.save()
Ejemplo n.º 8
0
 def pre_redirect(self, request, *args, **kwargs):
     self.motion = Motion.objects.get(pk=kwargs['motion_id'])
     self.item = Item(related_sid=self.motion.sid)
     self.item.save()
Ejemplo n.º 9
0
    def test_title_from_content_object(self, content_object):
        item = Item()
        content_object.get_agenda_title.return_value = 'related_title'

        self.assertEqual(item.title, 'related_title')