diff --git a/greg/admin.py b/greg/admin.py index 2d9252c444828ffde1b216a6882189c88b3dd62a..c7a878ebcaa0602e576792f69cb327faeca0c36e 100644 --- a/greg/admin.py +++ b/greg/admin.py @@ -123,10 +123,13 @@ class IdentifierAdmin(VersionAdmin): class OrganizationalUnitAdmin(VersionAdmin): - list_display = ("id", "name_en", "parent") + list_display = ("id", "name_en", "name_nb", "parent") readonly_fields = ("id", "created", "updated") - search_fields = ("name_en", "id") + search_fields = ("name_en", "name_nb", "id") inlines = (OuIdentifierInline,) + # This is mainly to make the org unit list be sorted in the drop-down box + # in the role line under persons + ordering = ("name_nb",) class OrganizationalUnitInline(admin.TabularInline): diff --git a/greg/models.py b/greg/models.py index 43fe9f0799b81f10e58ac83d407b46b80590d762..349515c534dcb56f4f0290ab14d0b416ab5075e6 100644 --- a/greg/models.py +++ b/greg/models.py @@ -521,7 +521,7 @@ class OrganizationalUnit(BaseModel): ) def __str__(self) -> str: - return f"{self.name_en or self.name_nb}" + return f"{self.name_nb} ({self.name_en})" def fetch_tree(self): """ diff --git a/greg/tests/models/test_organizational_unit.py b/greg/tests/models/test_organizational_unit.py index dfbcfa3ebe9621ca45113bd1c6eec4e41a486e55..186b2bb501603d2acde3f42a9c8080a50485d5ab 100644 --- a/greg/tests/models/test_organizational_unit.py +++ b/greg/tests/models/test_organizational_unit.py @@ -17,7 +17,7 @@ def test_org_repr(unit_foo): @pytest.mark.django_db def test_org_str(unit_foo): - assert str(unit_foo) == "foo_unit" + assert str(unit_foo) == " (foo_unit)" @pytest.mark.django_db