Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ietf/person/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ def test_person_profile_without_email(self):
r = self.client.get(url)
self.assertContains(r, person.name, status_code=200)

def test_person_profile_duplicates(self):
# same Person name and email - should not show on the profile as multiple Person records
person = PersonFactory(name="bazquux@example.com", user__email="bazquux@example.com")
url = urlreverse("ietf.person.views.profile", kwargs={ "email_or_name": person.plain_name()})
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.assertNotIn('More than one person', r.content.decode())

# Change that person's name but leave their email address. Create a new person whose name
# is the email address. This *should* be flagged as multiple Person records on the profile.
person.name = 'different name'
person.save()
PersonFactory(name="bazquux@example.com")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.assertIn('More than one person', r.content.decode())

def test_person_profile_404(self):
urls = [
urlreverse("ietf.person.views.profile", kwargs={ "email_or_name": "nonexistent@example.com"}),
Expand Down
8 changes: 5 additions & 3 deletions ietf/person/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ def ajax_select2_search(request, model_name):

return HttpResponse(select2_id_name_json(objs), content_type='application/json')


def profile(request, email_or_name):
aliases = Alias.objects.filter(name=email_or_name)
persons = list(set([ a.person for a in aliases ]))
persons = set(a.person for a in aliases)

if '@' in email_or_name:
emails = Email.objects.filter(address=email_or_name)
persons += list(set([ e.person for e in emails ]))
persons.update(e.person for e in emails)

persons = [ p for p in persons if p and p.id ]
persons = [p for p in persons if p and p.id]
if not persons:
raise Http404
persons.sort(key=lambda p: p.id)
return render(request, 'person/profile.html', {'persons': persons, 'today': timezone.now()})


Expand Down