From 2a52a7bdc5017c40ed07debf5c9e35933843968f Mon Sep 17 00:00:00 2001 From: Jon Froehlich Date: Mon, 22 Jun 2026 09:58:46 -0700 Subject: [PATCH] fix(admin): label Position mentor field "Mentor" not "Grad mentor" (#806) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mentor dropdown stopped being grad-only long ago — get_active_mentors_queryset already offers any active senior lab member (PhD/MS/postdoc/director/dev/designer/ research scientist), so a non-grad like a software developer can be selected. Only the admin label still read "Grad mentor", which was misleading. Set verbose_name='Mentor' so the label matches the behavior. The DB column is intentionally not renamed: this repo regenerates migrations non-interactively per environment, where a field rename can't be confirmed and would drop the column (the original blocker in #806). verbose_name fixes the label with no schema change. Co-mentor support (also floated in #806) is intentionally left out — no demand. Co-Authored-By: Claude Opus 4.8 (1M context) --- website/models/position.py | 8 +++++++- website/tests/test_position_mentor_label.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 website/tests/test_position_mentor_label.py diff --git a/website/models/position.py b/website/models/position.py index 09428513..d2807f33 100644 --- a/website/models/position.py +++ b/website/models/position.py @@ -57,7 +57,13 @@ class Position(models.Model): end_date = models.DateField(blank=True, null=True) advisor = models.ForeignKey('Person', blank=True, null=True, related_name='Advisor', on_delete=models.SET_NULL) co_advisor = models.ForeignKey('Person', blank=True, null=True, related_name='Co_Advisor', verbose_name='Co-advisor', on_delete=models.SET_NULL) - grad_mentor = models.ForeignKey('Person', blank=True, null=True, related_name='Grad_Mentor', on_delete=models.SET_NULL) + # Field is named ``grad_mentor`` for historical reasons, but the dropdown allows any active + # senior lab member (not just grad students) — see get_active_mentors_queryset — so the + # user-facing label is simply "Mentor" (issue #806). The DB column is intentionally NOT + # renamed: this repo regenerates migrations non-interactively per-environment, where a field + # rename can't be confirmed and would drop the column. verbose_name fixes the label with no + # schema change. + grad_mentor = models.ForeignKey('Person', blank=True, null=True, related_name='Grad_Mentor', verbose_name='Mentor', on_delete=models.SET_NULL) role = models.CharField(max_length=50, choices=Role.choices, default=Role.MEMBER) title = models.CharField(max_length=50, choices=Title.choices) diff --git a/website/tests/test_position_mentor_label.py b/website/tests/test_position_mentor_label.py new file mode 100644 index 00000000..6eb48110 --- /dev/null +++ b/website/tests/test_position_mentor_label.py @@ -0,0 +1,19 @@ +""" +Regression test for issue #806. + +The Position.grad_mentor field keeps its historical Python/DB name, but the +mentor dropdown is no longer grad-only (see get_active_mentors_queryset), so the +user-facing admin label was changed to simply "Mentor" via verbose_name. This +pins that label so a future edit to the field doesn't silently revert it to the +auto-generated "Grad mentor". +""" + +from django.test import SimpleTestCase + +from website.models import Position + + +class MentorLabelTests(SimpleTestCase): + def test_grad_mentor_field_labeled_mentor(self): + field = Position._meta.get_field("grad_mentor") + self.assertEqual(field.verbose_name, "Mentor")