diff --git a/mediathread/projects/models.py b/mediathread/projects/models.py index 781daf88b..4aa2f9453 100644 --- a/mediathread/projects/models.py +++ b/mediathread/projects/models.py @@ -152,7 +152,7 @@ def responses_by_course(self, course, viewer): projects = Project.objects.filter( course=course, project_type=PROJECT_TYPE_COMPOSITION) - # filter down to responses + # filter down to responses only based on the collaboration parent state collaborations = Collaboration.objects.get_for_object_list(projects) collaborations = collaborations.filter(_parent__isnull=False) collaborations = collaborations.order_by('object_pk') diff --git a/mediathread/projects/tests/test_models.py b/mediathread/projects/tests/test_models.py index b51f7980f..f67420394 100644 --- a/mediathread/projects/tests/test_models.py +++ b/mediathread/projects/tests/test_models.py @@ -226,6 +226,7 @@ def test_responses_by_course(self): response = ProjectFactory.create( course=self.sample_course, author=self.student_one, policy='PrivateEditorsAreOwners', parent=self.assignment) + self.assert_responses_by_course(self.student_one, [response], []) self.assert_responses_by_course(self.instructor_one, [], [response]) self.assert_responses_by_course(self.student_two, [], [response]) @@ -267,6 +268,32 @@ def test_responses_by_course(self): self.assert_responses_by_course(self.student_two, [response, response2], []) + def test_many_responses_by_course(self): + # additional responses ensure selected collaborations/projects + # don't line-up by default + + response1 = ProjectFactory.create( + title='Zeta', course=self.sample_course, author=self.student_three, + date_submitted=datetime.now(), policy='PublicEditorsAreOwners', + parent=self.assignment) + + # private response + response2 = ProjectFactory.create( + title='Omega', course=self.sample_course, author=self.student_one, + policy='PrivateEditorsAreOwners', parent=self.assignment) + + response3 = ProjectFactory.create( + title='Beta', course=self.sample_course, author=self.student_two, + date_submitted=datetime.now(), policy='PublicEditorsAreOwners', + parent=self.assignment) + + self.assert_responses_by_course(self.student_one, + [response1, response2, response3], []) + self.assert_responses_by_course(self.instructor_one, + [response1, response3], [response2]) + self.assert_responses_by_course(self.student_two, + [response1, response3], [response2]) + def test_project_clean_date_field(self): try: self.assignment.due_date = datetime(2012, 3, 13, 0, 0)