Skip to content

"Only my PhD advisees" filter on view-project-people shows no advisees #1325

@jonfroehlich

Description

@jonfroehlich

Bug

On the internal /view-project-people/ page, toggling "Only my PhD advisees" does not show Jon's PhD advisees. In production it shows only Mikey Saugstad (via a pre-existing hardcoded special-case in the template), and no one else.

Root cause

The #1284 refactor changed how the lab director is resolved:

# before
director = Person.objects.filter(last_name='Froehlich').first()
# after (#1284)
director = Person.objects.filter(position__title=Title.DIRECTOR).distinct().first()

In the real data Jon holds a professor title, not a Title.DIRECTOR position (get_prof_titles() is [ASSISTANT_PROF, ASSOCIATE_PROF, FULL_PROF]; PhD students' advisor FK points to Jon, which is only possible if he is professor-titled). So Person.objects.filter(position__title=Title.DIRECTOR) matches nobody, director is None, _build_phd_advisee_ids() returns an empty set, and every person's is_phd_advisee is false.

The existing unit tests didn't catch it because they constructed the director with a Title.DIRECTOR position — encoding the wrong assumption.

Fix

The Makeability Lab has exactly one director/founder for its lifetime (Jon Froehlich), so "who is the director" is an invariant, not something to infer. Introduce a single canonical resolver:

  • Person.DIRECTOR_NAME = ("Jon", "Froehlich") + Person.get_director() classmethod — single source of truth.
  • view_project_people uses Person.get_director(); both the is_director flag and the advisee check derive from it.
  • website/admin/utils.py reads the same Person.DIRECTOR_NAME constant (removes a second, independent hardcoding of Jon's name).
  • Regression test added; the two tests that fabricated a Title.DIRECTOR director updated to use the canonical director.

Notes

  • The template still has a pre-existing hardcoded person.last_name === 'Saugstad' special-case (predates this bug); can be removed in a follow-up now that the server logic is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions