Пример #1
0
def pending_applications_count(chair, activity, just_this_year=True):
    """ Count applications where:

    - All chairs have given recs, rating is needed
    - Viewing user hasn't given a rec
    """
    manager = ratings_utils.ApplicationManager(chair=chair, activity=activity)
    return len(manager.pending_applications(just_this_year))
Пример #2
0
def pending_applications_count(chair, activity_enum):
    """Count applications where:

    - All chairs have given recs, rating is needed
    - Viewing user hasn't given a rec
    """
    manager = ratings_utils.ApplicationManager(
        chair=chair, activity=activity_enum.value
    )
    return len(manager.pending_applications())
Пример #3
0
    def test_everything_needs_rating_with_one_chair(self):
        """ When there's only one chair, every application needs ratings! """
        chair = factories.ParticipantFactory.create()
        perm_utils.make_chair(chair.user, enums.Activity.CLIMBING)
        # Filtering is done in Python, no need to save to db
        app1 = factories.ClimbingLeaderApplicationFactory.create()
        app2 = factories.ClimbingLeaderApplicationFactory.create()

        manager = ratings.ApplicationManager(
            chair=chair, activity=enums.Activity.CLIMBING.value)
        pending_apps = manager.pending_applications()
        self.assertEqual(manager.needs_rating(pending_apps), [app1, app2])
Пример #4
0
    def test_no_recommendations_needed_with_one_chair(self):
        """When there's only one chair, no applications need recommendations!

        Recommendations are a mechanism of multiple chairs coming to a consensus
        on a prospective leader's rating. It doesn't make sense for a chair to
        recommend a rating for a particular participant if there aren't other chairs!
        """
        # Filtering is done in Python, no need to save to db
        pending_recs = [
            factories.ClimbingLeaderApplicationFactory.build() for _ in range(3)
        ]
        with self._mock_for_climbing(num_chairs=1):
            manager = ratings.ApplicationManager(activity=enums.Activity.CLIMBING.value)
            self.assertEqual(manager.needs_rec(pending_recs), [])
Пример #5
0
 def _manager_for(chair_participant):
     return ratings.ApplicationManager(
         chair=chair_participant, activity=enums.Activity.CLIMBING.value)