Exemplo n.º 1
0
    def make_fcfs(self, signups_open_at=None):
        """ Set the algorithm to FCFS, adjust signup times appropriately. """
        self.algorithm = 'fcfs'
        now = dateutils.local_now()
        if signups_open_at:
            self.signups_open_at = signups_open_at
        elif dateutils.wed_morning() <= now < dateutils.closest_wed_at_noon():
            # If posted between lottery time and noon, make it open at noon
            self.signups_open_at = dateutils.closest_wed_at_noon()
        else:
            self.signups_open_at = now

        # If a Winter School trip is last-minute, occurring mid-week,
        # we end up with a close time in the past (preventing trip creation)
        if self.fcfs_close_time > now:
            self.signups_close_at = self.fcfs_close_time
Exemplo n.º 2
0
    def free_for_all(self):
        """ Make trips first-come, first-serve.

        Trips re-open Wednesday at noon, close at midnight on Thursday.
        """
        logger.info("Making all lottery trips first-come, first-serve")
        ws_trips = models.Trip.objects.filter(activity='winter_school')
        noon = closest_wed_at_noon()
        for trip in ws_trips.filter(algorithm='lottery'):
            trip.make_fcfs(signups_open_at=noon)
            trip.save()
Exemplo n.º 3
0
    def free_for_all(self):
        """ Make trips first-come, first-serve.

        Trips re-open Wednesday at noon, close at midnight on Thursday.
        """
        self.logger.info("Making all lottery trips first-come, first-serve")
        ws_trips = models.Trip.objects.filter(activity='winter_school')
        noon = closest_wed_at_noon()
        for trip in ws_trips.filter(algorithm='lottery'):
            trip.make_fcfs(signups_open_at=noon)
            trip.save()
Exemplo n.º 4
0
    def free_for_all(self):
        """ Make trips first-come, first-serve.

        Trips re-open Wednesday at noon, close at midnight on Thursday.
        """
        self.logger.info("Making all lottery trips first-come, first-serve")
        ws_trips = models.Trip.objects.filter(
            program=enums.Program.WINTER_SCHOOL.value)
        noon = closest_wed_at_noon()
        for trip in ws_trips.filter(algorithm='lottery'):
            trip.make_fcfs(signups_open_at=noon)
            trip.save()
Exemplo n.º 5
0
    def test_closest_wed_at_noon(self):
        eastern = ZoneInfo('America/New_York')

        # On Wednesday, we return the same day
        with freeze_time("2016-12-28 23:22 EST"):
            self.assertEqual(
                date_utils.closest_wed_at_noon(),
                datetime(2016, 12, 28, 12, 0, 0, tzinfo=eastern),
            )

        # 3 days to the next Wednesday, 4 days to the previous
        with freeze_time("2016-12-25 10:00 EST"):
            self.assertEqual(
                date_utils.closest_wed_at_noon(),
                datetime(2016, 12, 28, 12, 0, 0, tzinfo=eastern),
            )

        # 4 days to the next Wednesday, 3 days to the previous
        with freeze_time("2016-12-24 10:00 EST"):
            self.assertEqual(
                date_utils.closest_wed_at_noon(),
                datetime(2016, 12, 21, 12, 0, 0, tzinfo=eastern),
            )
Exemplo n.º 6
0
 def test_closest_wed_at_noon(self):
     wed_noon = date_utils.closest_wed_at_noon()
     self.assertEqual(wed_noon.hour, 12)
     self.assertEqual(wed_noon.minute, 0)