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
8 changes: 7 additions & 1 deletion website/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions website/tests/test_position_mentor_label.py
Original file line number Diff line number Diff line change
@@ -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")
Loading