예제 #1
0
    def test_creator_is_eligible_as_participant(self):
        """So long as the creator is not a leader, they count as a non-trip participant."""
        trip = factories.TripFactory()
        self.assertNotIn(trip.creator, trip.leaders.all())
        self.assertIn(trip.creator, signup_utils.non_trip_participants(trip))

        trip.leaders.add(trip.creator)

        self.assertIn(trip.creator, trip.leaders.all())
        self.assertNotIn(trip.creator,
                         signup_utils.non_trip_participants(trip))
예제 #2
0
    def test_participants_on_trip(self):
        """All participants not signed up for the trip are returned."""
        trip = factories.TripFactory()
        on_trip = factories.ParticipantFactory.create()
        factories.SignUpFactory.create(participant=on_trip,
                                       trip=trip,
                                       on_trip=True)
        off_trip = factories.ParticipantFactory.create()
        signed_up_not_on_trip = factories.ParticipantFactory.create()
        factories.SignUpFactory.create(participant=signed_up_not_on_trip,
                                       trip=trip,
                                       on_trip=False)

        other_trip_signup = factories.SignUpFactory.create(on_trip=True)

        participants = signup_utils.non_trip_participants(trip)
        self.assertNotIn(on_trip, participants)
        self.assertIn(off_trip, participants)
        self.assertIn(signed_up_not_on_trip, participants)
        self.assertIn(other_trip_signup.participant, participants)
예제 #3
0
 def __init__(self, trip, *args, **kwargs):
     super().__init__(*args, **kwargs)
     non_trip = non_trip_participants(trip)
     self.fields['participant'].queryset = non_trip
     self.fields['participant'].help_text = None  # Disable "Hold command..."
예제 #4
0
 def __init__(self, trip, *args, **kwargs):
     super(LeaderParticipantSignUpForm, self).__init__(*args, **kwargs)
     non_trip = non_trip_participants(trip)
     self.fields['participant'].queryset = non_trip
     self.fields['participant'].help_text = None  # Disable "Hold command..."