Skip to content
Snippets Groups Projects
Commit a6fa6771 authored by Tore.Brede's avatar Tore.Brede
Browse files

Merge branch 'GREG-247_sort_org_unit_list_admin' into 'master'

GREG-247: Make the org unit list sorted alphabetically in the admin interface

See merge request !318
parents d7aa8a5f bd476003
No related branches found
No related tags found
1 merge request!318GREG-247: Make the org unit list sorted alphabetically in the admin interface
Pipeline #131182 passed
......@@ -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):
......
......@@ -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):
"""
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment