def shifts(monkeypatch):

    shift_helpers = ShiftHelperFactory.create_batch(2)
    for shift_helper in shift_helpers:
        monkeypatch.setattr(shift_helper.shift, "volunteer_count", 2, False)

    return [shift_helper.shift for shift_helper in shift_helpers]
    def handle(self, *args, **options):
        if options['flush']:
            print "delete all data in app tables"
            RegistrationProfile.objects.all().delete()

            Shift.objects.all().delete()
            Task.objects.all().delete()
            Workplace.objects.all().delete()
            Facility.objects.all().delete()

            UserAccount.objects.all().delete()

            # delete geographic information
            Country.objects.all().delete()
            Region.objects.all().delete()
            Area.objects.all().delete()
            Place.objects.all().delete()

            User.objects.filter().exclude(is_superuser=True).delete()

        # create regional data
        places = list()
        for i in range(0, 10):
            places.append(PlaceFactory.create())

        organizations = list()
        for i in range(0, 4):
            organizations.append(OrganizationFactory.create())

        # create shifts for number of days
        for day in range(0, options['days'][0]):
            for i in range(2, 23):
                place = places[random.randint(0, len(places) - 1)]
                organization = organizations[random.randint(0, len(organizations) - 1)]
                facility = FacilityFactory.create(
                    description=LOREM,
                    place=place,
                    organization=organization
                )
                shift = ShiftFactory.create(
                    starting_time=gen_date(hour=i - 1, day=day),
                    ending_time=gen_date(hour=i, day=day),
                    facility=facility
                )
                # assign random volunteer for each shift
                reg_user = ShiftHelperFactory.create(shift=shift)
                reg_user.save()
    def handle(self, *args, **options):
        if options['flush']:
            print "delete all data in app tables"
            RegistrationProfile.objects.all().delete()

            Shift.objects.all().delete()
            Task.objects.all().delete()
            Workplace.objects.all().delete()
            Facility.objects.all().delete()

            UserAccount.objects.all().delete()

            # delete geographic information
            Country.objects.all().delete()
            Region.objects.all().delete()
            Area.objects.all().delete()
            Place.objects.all().delete()

            User.objects.filter().exclude(is_superuser=True).delete()

        # create regional data
        places = list()
        for i in range(0, 10):
            places.append(PlaceFactory.create())

        organizations = list()
        for i in range(0, 4):
            organizations.append(OrganizationFactory.create())

        # create shifts for number of days
        for day in range(0, options['days'][0]):
            for i in range(2, 23):
                place = places[random.randint(0, len(places) - 1)]
                organization = organizations[random.randint(
                    0,
                    len(organizations) - 1)]
                facility = FacilityFactory.create(description=LOREM,
                                                  place=place,
                                                  organization=organization)
                shift = ShiftFactory.create(starting_time=gen_date(hour=i - 1,
                                                                   day=day),
                                            ending_time=gen_date(hour=i,
                                                                 day=day),
                                            facility=facility)
                # assign random volunteer for each shift
                reg_user = ShiftHelperFactory.create(shift=shift)
                reg_user.save()
Example #4
0
    def handle(self, *args, **options):
        if options['flush']:
            print "delete all data in app tables"
            RegistrationProfile.objects.all().delete()
            Need.objects.all().delete()
            Location.objects.all().delete()
            Topics.objects.all().delete()

            # delete geographic information
            Country.objects.all().delete()
            Region.objects.all().delete()
            Area.objects.all().delete()
            Place.objects.all().delete()

            User.objects.filter().exclude(is_superuser=True).delete()

        # create regional data
        places = list()
        for i in range(0, 10):
            places.append(PlaceFactory.create())

        # create shifts for number of days
        for day in range(0, options['days'][0]):
            for i in range(2, 23):
                topic = TopicFactory.create(title=random.choice(HELPTOPICS))
                location = LocationFactory.create(
                    name="Shelter" + str(random.randint(0, 9)),
                    place=places[random.randint(0,
                                                len(places) - 1)],
                    additional_info=LOREM)
                need = NeedFactory.create(starting_time=self.gen_date(hour=i -
                                                                      1,
                                                                      day=day),
                                          ending_time=self.gen_date(hour=i,
                                                                    day=day),
                                          topic=topic,
                                          location=location)
                # assign random volunteer for each need
                reg_user = ShiftHelperFactory.create(need=need)
                reg_user.save()
    def handle(self, *args, **options):
        if options['flush']:
            print "delete all data in app tables"
            RegistrationProfile.objects.all().delete()
            Need.objects.all().delete()
            Location.objects.all().delete()
            Topics.objects.all().delete()

            # delete geographic information
            Country.objects.all().delete()
            Region.objects.all().delete()
            Area.objects.all().delete()
            Place.objects.all().delete()

            User.objects.filter().exclude(is_superuser=True).delete()

        # create regional data
        places = list()
        for i in range(0,10):
            places.append(PlaceFactory.create())

        # create shifts for number of days
        for day in range(0, options['days'][0]):
            for i in range(2, 23):
                topic = TopicFactory.create(title=random.choice(HELPTOPICS))
                location = LocationFactory.create(
                    name="Shelter" + str(random.randint(0,9)),
                    place=places[random.randint(0,len(places)-1)],
                    additional_info=LOREM
                )
                need = NeedFactory.create(
                    starting_time=self.gen_date(hour=i-1, day=day),
                    ending_time=self.gen_date(hour=i, day=day),
                    topic=topic,
                    location=location
                )
                # assign random volunteer for each need
                reg_user = ShiftHelperFactory.create(need=need)
                reg_user.save()