@@ -584,6 +584,11 @@ def test_private_nominate_newperson(self):
584584 return self .nominate_newperson_view (public = False )
585585 self .client .logout ()
586586
587+ def test_private_nominate_newperson_who_already_exists (self ):
588+ EmailFactory (address = 'nominee@example.com' )
589+ self .access_member_url (self .private_nominate_newperson_url )
590+ return self .nominate_newperson_view (public = False )
591+
587592 def test_public_nominate_with_automatic_questionnaire (self ):
588593 nomcom = get_nomcom_by_year (self .year )
589594 nomcom .send_questionnaire = True
@@ -715,34 +720,40 @@ def nominate_newperson_view(self, *args, **kwargs):
715720 if not public :
716721 test_data ['nominator_email' ] = nominator_email
717722
718- response = self .client .post (nominate_url , test_data ,follow = True )
719- self .assertTrue (response .redirect_chain )
720- self .assertEqual (response .status_code , 200 )
721- q = PyQuery (response .content )
722- self .assertContains (response , "alert-success" )
723-
724- # check objects
725- email = Email .objects .get (address = candidate_email )
726- Person .objects .get (name = candidate_name )
727- nominee = Nominee .objects .get (email = email )
728- NomineePosition .objects .get (position = position , nominee = nominee )
729- feedback = Feedback .objects .filter (positions__in = [position ],
730- nominees__in = [nominee ],
731- type = FeedbackTypeName .objects .get (slug = 'nomina' )).latest ('id' )
732- if public :
733- self .assertEqual (feedback .author , nominator_email )
734-
735- # to check feedback comments are saved like enrypted data
736- self .assertNotEqual (feedback .comments , comment_text )
737-
738- self .assertEqual (check_comments (feedback .comments , comment_text , self .privatekey_file ), True )
739- Nomination .objects .get (position = position ,
740- candidate_name = candidate_name ,
741- candidate_email = candidate_email ,
742- candidate_phone = candidate_phone ,
743- nominee = nominee ,
744- comments = feedback ,
745- nominator_email = "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
723+ if Email .objects .filter (address = nominee_email ).exists ():
724+ response = self .client .post (nominate_url , test_data ,follow = True )
725+ self .assertFalse (response .redirect_chain )
726+ self .assertEqual (response .status_code , 200 )
727+ self .assertIn ('already in the datatracker' ,unicontent (response ))
728+ else :
729+ response = self .client .post (nominate_url , test_data ,follow = True )
730+ self .assertTrue (response .redirect_chain )
731+ self .assertEqual (response .status_code , 200 )
732+ q = PyQuery (response .content )
733+ self .assertContains (response , "alert-success" )
734+
735+ # check objects
736+ email = Email .objects .get (address = candidate_email )
737+ Person .objects .get (name = candidate_name )
738+ nominee = Nominee .objects .get (email = email )
739+ NomineePosition .objects .get (position = position , nominee = nominee )
740+ feedback = Feedback .objects .filter (positions__in = [position ],
741+ nominees__in = [nominee ],
742+ type = FeedbackTypeName .objects .get (slug = 'nomina' )).latest ('id' )
743+ if public :
744+ self .assertEqual (feedback .author , nominator_email )
745+
746+ # to check feedback comments are saved like enrypted data
747+ self .assertNotEqual (feedback .comments , comment_text )
748+
749+ self .assertEqual (check_comments (feedback .comments , comment_text , self .privatekey_file ), True )
750+ Nomination .objects .get (position = position ,
751+ candidate_name = candidate_name ,
752+ candidate_email = candidate_email ,
753+ candidate_phone = candidate_phone ,
754+ nominee = nominee ,
755+ comments = feedback ,
756+ nominator_email = "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
746757
747758 def test_add_questionnaire (self ):
748759 self .access_chair_url (self .add_questionnaire_url )
0 commit comments