diff --git a/lms/djangoapps/teams/management/commands/reindex_course_team.py b/lms/djangoapps/teams/management/commands/reindex_course_team.py index 706ff3096a..92c764f16c 100644 --- a/lms/djangoapps/teams/management/commands/reindex_course_team.py +++ b/lms/djangoapps/teams/management/commands/reindex_course_team.py @@ -52,10 +52,10 @@ class Command(BaseCommand): from ...search_indexes import CourseTeamIndexer if options['all']: - if len(options['course_team_ids']) > 0: + if options['course_team_ids']: raise CommandError('Course teams cannot be specified when --all is also specified') else: - if len(options['course_team_ids']) == 0: + if not options['course_team_ids']: raise CommandError('At least one course_team_id or --all needs to be specified') if not settings.FEATURES.get('ENABLE_TEAMS', False): diff --git a/lms/djangoapps/teams/models.py b/lms/djangoapps/teams/models.py index 67cfc6219f..fc4cf8525d 100644 --- a/lms/djangoapps/teams/models.py +++ b/lms/djangoapps/teams/models.py @@ -101,6 +101,8 @@ class CourseTeam(models.Model): .. no_pii: """ + def __unicode__(self): + return '[CourseTeam id={}]'.format(self.team_id) class Meta(object): app_label = "teams" @@ -188,6 +190,9 @@ class CourseTeamMembership(models.Model): .. no_pii: """ + def __unicode__(self): + return "[CourseTeamMembership user={}, team={}]".format(self.user, self.team) + class Meta(object): app_label = "teams" unique_together = (('user', 'team'),) @@ -223,7 +228,7 @@ class CourseTeamMembership(models.Model): ) super(CourseTeamMembership, self).__setattr__(name, value) - def save(self, *args, **kwargs): + def save(self, *args, **kwargs): # pylint: disable=arguments-differ """Customize save method to set the last_activity_at if it does not currently exist. Also resets the team's size if this model is being created. @@ -237,7 +242,7 @@ class CourseTeamMembership(models.Model): if should_reset_team_size: self.team.reset_team_size() - def delete(self, *args, **kwargs): + def delete(self, *args, **kwargs): # pylint: disable=arguments-differ """Recompute the related team's team_size after deleting a membership""" super(CourseTeamMembership, self).delete(*args, **kwargs) self.team.reset_team_size() diff --git a/lms/djangoapps/teams/serializers.py b/lms/djangoapps/teams/serializers.py index 150f58e5ef..3b6d8949e1 100644 --- a/lms/djangoapps/teams/serializers.py +++ b/lms/djangoapps/teams/serializers.py @@ -23,7 +23,7 @@ class CountryField(serializers.Field): COUNTRY_CODES = list(dict(countries).keys()) - def to_representation(self, obj): + def to_representation(self, obj): # pylint: disable=arguments-differ """ Represent the country as a 2-character unicode identifier. """ @@ -165,14 +165,14 @@ class MembershipSerializer(serializers.ModelSerializer): read_only_fields = ("date_joined", "last_activity_at") -class BaseTopicSerializer(serializers.Serializer): +class BaseTopicSerializer(serializers.Serializer): # pylint: disable=abstract-method """Serializes a topic without team_count.""" description = serializers.CharField() name = serializers.CharField() id = serializers.CharField() # pylint: disable=invalid-name -class TopicSerializer(BaseTopicSerializer): +class TopicSerializer(BaseTopicSerializer): # pylint: disable=abstract-method """ Adds team_count to the basic topic serializer, checking if team_count is already present in the topic data, and if not, querying the CourseTeam @@ -195,7 +195,7 @@ class BulkTeamCountTopicListSerializer(serializers.ListSerializer): # pylint: d List serializer for efficiently serializing a set of topics. """ - def to_representation(self, obj): + 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"]) diff --git a/lms/djangoapps/teams/tests/test_models.py b/lms/djangoapps/teams/tests/test_models.py index a78a2eb3fd..3a41ae370e 100644 --- a/lms/djangoapps/teams/tests/test_models.py +++ b/lms/djangoapps/teams/tests/test_models.py @@ -133,7 +133,7 @@ class TeamSignalsTest(EventTestMixin, SharedModuleStoreTestCase): DISCUSSION_TOPIC_ID = 'test_topic' - def setUp(self): + def setUp(self): # pylint: disable=arguments-differ """Create a user with a team to test signals.""" super(TeamSignalsTest, self).setUp('lms.djangoapps.teams.utils.tracker') self.user = UserFactory.create(username="user") diff --git a/lms/djangoapps/teams/views.py b/lms/djangoapps/teams/views.py index bf95e1a532..9cda3afd40 100644 --- a/lms/djangoapps/teams/views.py +++ b/lms/djangoapps/teams/views.py @@ -166,7 +166,7 @@ class TeamsDashboardView(GenericAPIView): "team_memberships_url": reverse('team_membership_list', request=request), "my_teams_url": reverse('teams_list', request=request), "team_membership_detail_url": reverse('team_membership_detail', args=['team_id', user.username]), - "languages": [[lang[0], _(lang[1])] for lang in settings.ALL_LANGUAGES], + "languages": [[lang[0], _(lang[1])] for lang in settings.ALL_LANGUAGES], # pylint: disable=translation-of-non-string "countries": list(countries), "disable_courseware_js": True, "teams_base_url": reverse('teams_dashboard', request=request, kwargs={'course_id': course_id}), @@ -885,7 +885,7 @@ class TopicDetailView(APIView): topics = [t for t in course_module.teams_topics if t['id'] == topic_id] - if len(topics) == 0: + if not topics: return Response(status=status.HTTP_404_NOT_FOUND) serializer = TopicSerializer(topics[0], context={'course_id': course_id})