feat: make people group labels editable

This commit is contained in:
mohamad
2026-10-29 04:11:36 +08:00
parent cb54e96db6
commit 9a8551ae23
8 changed files with 81 additions and 7 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ from collections import OrderedDict
ROLE_PRIORITY = {"lead": 0, "leader": 0, "organizer": 1, "collaborator": 2}
ROLE_TITLES = {0: "Lead / Leader", 1: "Organizers", 2: "Collaborators"}
ROLE_LABEL_FIELDS = {0: "lead_group_label", 1: "organizer_group_label", 2: "collaborator_group_label"}
def person_sort_key(person):
@@ -10,7 +10,7 @@ def person_sort_key(person):
return (ROLE_PRIORITY.get(role, 3), role if role not in ROLE_PRIORITY else "", person.order, person.pk or 0)
def group_people(people):
def group_people(people, branding):
groups = OrderedDict()
for person in sorted(people, key=person_sort_key):
role = (person.role or "").strip()
@@ -18,7 +18,7 @@ def group_people(people):
key = priority if priority < 3 else role.casefold()
if key not in groups:
groups[key] = {
"title": ROLE_TITLES[priority] if priority < 3 else role or "Other contributors",
"title": getattr(branding, ROLE_LABEL_FIELDS[priority], "") if priority < 3 else role,
"people": [],
}
groups[key]["people"].append(person)