Adds final test, all three now pass.

This commit is contained in:
Christopher Neugebauer 2016-09-04 14:00:56 +10:00
parent 04eefa4e0e
commit af30063a92
2 changed files with 14 additions and 4 deletions

View file

@ -311,16 +311,15 @@ class SpeakerConditionController(IsMetByFilter, ConditionController):
being a presenter or copresenter of a proposal. ''' being a presenter or copresenter of a proposal. '''
u = user u = user
# User is a presenter # User is a presenter
user_is_presenter = Q( user_is_presenter = Q(
is_presenter=True, is_presenter=True,
proposal_kind__section__presentations__speaker__user=u, proposal_kind__proposalbase__presentation__speaker__user=u,
) )
# User is a copresenter # User is a copresenter
user_is_copresenter = Q( user_is_copresenter = Q(
is_copresenter=True, is_copresenter=True,
proposal_kind__section__presentations__additional_speakers__user=u, proposal_kind__proposalbase__presentation__additional_speakers__user=u,
) )
return queryset.filter(user_is_presenter | user_is_copresenter) return queryset.filter(user_is_presenter | user_is_copresenter)

View file

@ -191,8 +191,19 @@ class SpeakerTestCase(RegistrationCartTestCase):
self._create_flag_for_primary_speaker() self._create_flag_for_primary_speaker()
# USER_1 cannot see PROD_1 until proposal is promoted. # USER_1 cannot see PROD_1 until proposal is promoted.
available = ProductController.available_products(
self.USER_1,
products=[self.PROD_1],
)
self.assertNotIn(self.PROD_1, available)
# promote proposal_2 so that USER_1 becomes a speaker, but of # promote proposal_2 so that USER_1 becomes a speaker, but of
# KIND_2, which is not covered by this condition # KIND_2, which is not covered by this condition
promote_proposal(self.PROPOSAL_2)
# USER_2 cannot see PROD_1 # USER_1 cannot see PROD_1
available_1 = ProductController.available_products(
self.USER_1,
products=[self.PROD_1],
)
self.assertNotIn(self.PROD_1, available_1)