Пример #1
0
    def setUp(self):
        super(OrganizerActivitiesViewTest, self).setUp()

        # get organizer
        organizer = self.organizer

        # create organizer activities
        today = now()
        yesterday = today - timedelta(1)

        self.unpublished_activities = \
            ActivityFactory.create_batch(2, organizer=organizer)

        # Open activities
        self.opened_activities = \
            ActivityFactory.create_batch(2, published=True,
                                         organizer=organizer)
        CalendarFactory.create_batch(size=2,
                                     initial_date=now() + timedelta(days=20),
                                     enroll_open=True,
                                     activity=factory.Iterator(
                                         self.opened_activities))

        self.closed_activities = \
            ActivityFactory.create_batch(2, published=True,
                                         organizer=organizer)

        self.activities = self.organizer.activity_set.all()

        # set url
        self.url = reverse('organizers:activities',
                           kwargs={'organizer_pk': organizer.id})
        self.autocomplete_url = reverse('organizers:activities_autocomplete',
                                        kwargs={'organizer_pk': organizer.id})
Пример #2
0
    def setUp(self):
        super(ActivitiesByStudentViewTest, self).setUp()

        # get student
        student = self.student

        # create student activities
        today = datetime.today().date()
        yesterday = today - timedelta(1)
        tomorrow = today + timedelta(1)
        month_ago = today - timedelta(days=31)

        # create current activities
        self.current_activities = \
            ActivityFactory.create_batch(2)
        self._create_calendars(self.current_activities, yesterday)

        # create next activities
        self.next_activities = \
            ActivityFactory.create_batch(2)
        self._create_calendars(self.next_activities, tomorrow)

        # create past activities
        self.past_activities = \
            ActivityFactory.create_batch(2)
        self._create_calendars(self.past_activities, month_ago)

        self.activities = Activity.objects.filter(calendars__orders__student=student)

        self.url = reverse('students:activities', kwargs={'pk': student.id})
        self.url_autocomplete = reverse('students:activities_autocomplete',
                                        kwargs={'pk': student.id})
Пример #3
0
    def create_activities(self, num_activities: int):
        self.stdout.write('Creando activities')
        activities = list()
        size = None

        if num_activities:
            size = num_activities // len(self.organizers)

        for organizer in self.organizers:
            quantity = size if size else self.get_quantity()
            instructors = list(organizer.instructors.all())
            instructors_sample = self.get_sample(instructors, 1)

            params = {
                'organizer': organizer,
                'published': True,
                'sub_category': factory.Iterator(self.subcategories,
                                                 cycle=True),
                'instructors': instructors_sample,
                'location': factory.Iterator(self.locations, cycle=True),
                'certification': factory.Faker('boolean'),
            }

            activities.append(ActivityFactory.create_batch(quantity, **params))

        activities = self.flat_list(activities)
        self.create_main_photo(activities)
        self.create_tags(activities)
        return activities
Пример #4
0
 def setUp(self):
     self.organizer = OrganizerFactory()
     self.activities = ActivityFactory.create_batch(
         organizer=self.organizer, size=2)