def to_representation(self, obj): # pylint: disable=arguments-differ """Adds team_count to each topic. """ data = super(BulkTeamCountTopicListSerializer, self).to_representation(obj) add_team_count(data, self.context['course_id'], self.context.get('organization_protection_status')) return data
def to_representation(self, obj): # pylint: disable=arguments-differ """Adds team_count to each topic. """ data = super().to_representation(obj) add_team_count( self.context['request'].user, data, self.context['course_id'], self.context.get('organization_protection_status') ) return data
def test_team_counter_add_team_count(self, username, expected_team_count): user = self.users[username] try: organization_protection_status = teams_api.user_organization_protection_status( user, COURSE_KEY1) except ValueError: self.assertFalse(CourseEnrollment.is_enrolled(user, COURSE_KEY1)) return topic = {'id': self.topic_id} teams_api.add_team_count(user, [topic], COURSE_KEY1, organization_protection_status) self.assertEqual(expected_team_count, topic.get('team_count'))