Correct construction for a reverse URL in an edge case. Fixes #2815. Commit ready for merge.
- Legacy-Id: 16907
This commit is contained in:
parent
f2758fe49c
commit
cca04b6330
|
@ -382,7 +382,7 @@ class NominateNewPersonForm(forms.ModelForm):
|
||||||
def clean_candidate_email(self):
|
def clean_candidate_email(self):
|
||||||
candidate_email = self.cleaned_data['candidate_email']
|
candidate_email = self.cleaned_data['candidate_email']
|
||||||
if Email.objects.filter(address=candidate_email).exists():
|
if Email.objects.filter(address=candidate_email).exists():
|
||||||
normal_url_name = 'ietf.nomcom.views.%s_nominate' % 'public' if self.public else 'private'
|
normal_url_name = 'ietf.nomcom.views.%s_nominate' % ('public' if self.public else 'private')
|
||||||
msg = (('%s is already in the datatracker. '
|
msg = (('%s is already in the datatracker. '
|
||||||
'Use the <a href="%s">normal nomination form</a> to nominate the person '
|
'Use the <a href="%s">normal nomination form</a> to nominate the person '
|
||||||
'with this address. ') %
|
'with this address. ') %
|
||||||
|
|
|
@ -584,6 +584,11 @@ class NomcomViewsTest(TestCase):
|
||||||
return self.nominate_newperson_view(public=False)
|
return self.nominate_newperson_view(public=False)
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
|
|
||||||
|
def test_private_nominate_newperson_who_already_exists(self):
|
||||||
|
EmailFactory(address='nominee@example.com')
|
||||||
|
self.access_member_url(self.private_nominate_newperson_url)
|
||||||
|
return self.nominate_newperson_view(public=False)
|
||||||
|
|
||||||
def test_public_nominate_with_automatic_questionnaire(self):
|
def test_public_nominate_with_automatic_questionnaire(self):
|
||||||
nomcom = get_nomcom_by_year(self.year)
|
nomcom = get_nomcom_by_year(self.year)
|
||||||
nomcom.send_questionnaire = True
|
nomcom.send_questionnaire = True
|
||||||
|
@ -715,34 +720,40 @@ class NomcomViewsTest(TestCase):
|
||||||
if not public:
|
if not public:
|
||||||
test_data['nominator_email'] = nominator_email
|
test_data['nominator_email'] = nominator_email
|
||||||
|
|
||||||
response = self.client.post(nominate_url, test_data,follow=True)
|
if Email.objects.filter(address=nominee_email).exists():
|
||||||
self.assertTrue(response.redirect_chain)
|
response = self.client.post(nominate_url, test_data,follow=True)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertFalse(response.redirect_chain)
|
||||||
q = PyQuery(response.content)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "alert-success")
|
self.assertIn('already in the datatracker',unicontent(response))
|
||||||
|
else:
|
||||||
|
response = self.client.post(nominate_url, test_data,follow=True)
|
||||||
|
self.assertTrue(response.redirect_chain)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
q = PyQuery(response.content)
|
||||||
|
self.assertContains(response, "alert-success")
|
||||||
|
|
||||||
# check objects
|
# check objects
|
||||||
email = Email.objects.get(address=candidate_email)
|
email = Email.objects.get(address=candidate_email)
|
||||||
Person.objects.get(name=candidate_name)
|
Person.objects.get(name=candidate_name)
|
||||||
nominee = Nominee.objects.get(email=email)
|
nominee = Nominee.objects.get(email=email)
|
||||||
NomineePosition.objects.get(position=position, nominee=nominee)
|
NomineePosition.objects.get(position=position, nominee=nominee)
|
||||||
feedback = Feedback.objects.filter(positions__in=[position],
|
feedback = Feedback.objects.filter(positions__in=[position],
|
||||||
nominees__in=[nominee],
|
nominees__in=[nominee],
|
||||||
type=FeedbackTypeName.objects.get(slug='nomina')).latest('id')
|
type=FeedbackTypeName.objects.get(slug='nomina')).latest('id')
|
||||||
if public:
|
if public:
|
||||||
self.assertEqual(feedback.author, nominator_email)
|
self.assertEqual(feedback.author, nominator_email)
|
||||||
|
|
||||||
# to check feedback comments are saved like enrypted data
|
# to check feedback comments are saved like enrypted data
|
||||||
self.assertNotEqual(feedback.comments, comment_text)
|
self.assertNotEqual(feedback.comments, comment_text)
|
||||||
|
|
||||||
self.assertEqual(check_comments(feedback.comments, comment_text, self.privatekey_file), True)
|
self.assertEqual(check_comments(feedback.comments, comment_text, self.privatekey_file), True)
|
||||||
Nomination.objects.get(position=position,
|
Nomination.objects.get(position=position,
|
||||||
candidate_name=candidate_name,
|
candidate_name=candidate_name,
|
||||||
candidate_email=candidate_email,
|
candidate_email=candidate_email,
|
||||||
candidate_phone=candidate_phone,
|
candidate_phone=candidate_phone,
|
||||||
nominee=nominee,
|
nominee=nominee,
|
||||||
comments=feedback,
|
comments=feedback,
|
||||||
nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))
|
nominator_email="%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))
|
||||||
|
|
||||||
def test_add_questionnaire(self):
|
def test_add_questionnaire(self):
|
||||||
self.access_chair_url(self.add_questionnaire_url)
|
self.access_chair_url(self.add_questionnaire_url)
|
||||||
|
|
Loading…
Reference in a new issue