Esempio n. 1
0
    def setUp(self):
        super().setUp()
        self.leader = factories.ParticipantFactory.create(
            name="Tim Beaver", email="*****@*****.**", cell_phone="+6172531000"
        )
        self.trip = factories.TripFactory.create(
            name="Mt. Lafayette",
            trip_date=date(2019, 10, 12),
            info=factories.TripInfoFactory.create(
                start_location='Old Bridle Path trailhead'
            ),
        )
        self.trip.leaders.add(self.leader)

        suzy = factories.ParticipantFactory(
            name="Suzy Queue", email="*****@*****.**", cell_phone="+17815551234"
        )
        self.joe = factories.ParticipantFactory(
            name="Joe Schmo", email="*****@*****.**", cell_phone=""
        )
        factories.SignUpFactory.create(participant=suzy, trip=self.trip, on_trip=True)
        factories.SignUpFactory.create(
            participant=self.joe, trip=self.trip, on_trip=True
        )

        # Participants on the waiting list or otherwise not on the trip aren't considered
        factories.SignUpFactory.create(trip=self.trip, on_trip=False)
        on_waitlist = factories.SignUpFactory.create(trip=self.trip, on_trip=False)
        factories.WaitListSignupFactory.create(signup=on_waitlist)
Esempio n. 2
0
    def test_driver_bump(self):
        """ Drivers can bump non-drivers off if it makes the trip possible. """
        trip = factories.TripFactory.create(
            algorithm='lottery',
            program=enums.Program.WINTER_SCHOOL.value,
            maximum_participants=2,
        )

        driver = factories.ParticipantFactory.create()
        factories.LotteryInfoFactory.create(participant=driver,
                                            car_status='own')
        factories.SignUpFactory.create(participant=driver, trip=trip)

        # Place two other people on the trip first!
        first = factories.ParticipantFactory()
        second = factories.ParticipantFactory()
        # Include a ranking override so that we guarantee first is ranked second
        # (This ensures that `second_signup` will be yanked for the driver)
        factories.LotteryAdjustmentFactory.create(participant=first,
                                                  adjustment=-1)
        for par in [first, second]:
            factories.SignUpFactory.create(trip=trip, participant=par)
            self._place_participant(par)

        self._assert_on_trip(first, trip)
        self._assert_on_trip(second, trip)

        # Place the driver, observe that they get a spot since we needed drivers.
        self._place_participant(driver)
        self._assert_on_trip(driver, trip)

        # The last person on the trip was bumped off!
        self._assert_on_trip(second, trip, on_trip=False)
Esempio n. 3
0
 def _leader(self):
     trip_leader = factories.ParticipantFactory()
     trip_leader.leaderrating_set.add(
         factories.LeaderRatingFactory.create(
             participant=trip_leader,
             activity=models.LeaderRating.WINTER_SCHOOL))
     return trip_leader
Esempio n. 4
0
    def test_token_is_for_a_different_user(self):
        """If you clicked an unsubscribe link for a different participant, it should still work."""
        participant = factories.ParticipantFactory.create()
        token = unsubscribe.generate_unsubscribe_token(participant)

        self.client.force_login(factories.ParticipantFactory().user)

        with self._spy_on_add_message() as add_message:
            response = self.client.get(f'/preferences/email/unsubscribe/{token}/')
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response.url, '/preferences/email/')

        add_message.assert_has_calls(
            [
                mock.call(
                    mock.ANY,
                    messages.SUCCESS,
                    'Successfully unsubscribed',
                ),
                mock.call(
                    mock.ANY,
                    messages.WARNING,
                    'Note that the unsubscribe token was for a different participant! '
                    'You may edit your own mail preferences below.',
                ),
            ],
            any_order=False,
        )
Esempio n. 5
0
 def test_closed_trip(self):
     """Nobody may sign up after signups close."""
     trip = self._make_trip(signups_close_at=date_utils.localize(
         datetime(2025, 12, 11, 11, 11)))
     self.assertTrue(trip.signups_closed)
     soup = self._render(factories.ParticipantFactory(), trip)
     self.assertEqual(
         soup.find(class_='alert-info').get_text(' ', strip=True),
         'Signups for this trip are closed.',
     )
     self.assertIsNone(soup.find('form'))
    def test_can_lead_own_activity_and_open(self):
        participant = factories.ParticipantFactory()
        participant.leaderrating_set.add(
            factories.LeaderRatingFactory.create(
                participant=participant, activity=enums.Activity.BIKING.value))
        # Can only lead programs for own activity
        self.assertTrue(participant.can_lead(enums.Program.BIKING))
        self.assertFalse(participant.can_lead(enums.Program.CLIMBING))

        # Can lead all open programs
        self.assertTrue(participant.can_lead(enums.Program.CIRCUS))
        self.assertTrue(participant.can_lead(enums.Program.NONE))
        self.assertTrue(participant.can_lead(enums.Program.SERVICE))

        self.assertCountEqual(
            participant.allowed_programs,
            [
                enums.Program.BIKING,
                enums.Program.CIRCUS,
                enums.Program.NONE,
                enums.Program.SERVICE,
            ],
        )
 def test_participants_cannot_lead(self):
     participant = factories.ParticipantFactory()
     self.assertFalse(participant.can_lead(enums.Program.WINTER_SCHOOL))
     # Even open programs aren't able to be led by any participant
     self.assertFalse(participant.can_lead(enums.Program.CIRCUS))
     self.assertCountEqual(participant.allowed_programs, [])