Don't provide links to person pages that we know will 404. Commit ready for merge.

- Legacy-Id: 19193
This commit is contained in:
Robert Sparks 2021-07-02 21:43:50 +00:00
parent 3202a25c52
commit c0ab02c489

View file

@ -23,11 +23,19 @@ def person_by_name(name):
alias = Alias.objects.filter(name=name).first()
return alias.person if alias else None
# CLEANUP: There are several hundred Person objects with no Alias object,
# violating the expectiations of the code. The check for the existance of an
# alias object below matching the person's name avoids presenting a link that
# we know will 404. When the database is corrected and we can expect that the
# Alias for the person's name to always be there, we can remove this extra
# database query (or leave it as a safeguard until it becomes a performance
# issue.)
@register.inclusion_tag('person/person_link.html')
def person_link(person, **kwargs):
title = kwargs.get('title', '')
cls = kwargs.get('class', '')
name = person.name
name = person.name if person.alias_set.filter(name=person.name).exists() else ''
plain_name = person.plain_name()
email = person.email_address()
return {'name': name, 'plain_name': plain_name, 'email': email, 'title': title, 'class': cls}
@ -37,7 +45,7 @@ def person_link(person, **kwargs):
def email_person_link(email, **kwargs):
title = kwargs.get('title', '')
cls = kwargs.get('class', '')
name = email.person.name
name = email.person.name if email.person.alias_set.filter(name=email.person.name).exists() else ''
plain_name = email.person.plain_name()
email = email.address
return {'name': name, 'plain_name': plain_name, 'email': email, 'title': title, 'class': cls}