Skip to content

Add a team page with roster and team competency wheel - #866

Merged
AdrianDAlessandro merged 17 commits into
mainfrom
team-slug
Nov 30, 2026
Merged

AdrianDAlessandro merged 17 commits into
mainfrom
team-slug

Conversation

@TinyMarsh

@TinyMarsh TinyMarsh commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #706

Some comments from me before the agentic output below

  • Taking on board @AdrianDAlessandro's comments in Add the authenticated My Teams page #840, I have tried to get things right first time in this PR. I had to do some careful pointing for the agent given that Clarify agent guidance on README content and following test patterns #864 is not fixed yet. Hopefully it has done a decent job this time.
  • I made the executive decision to round skill averages in the aggregated skill wheel. I don't think the skill wheel supports decimals, so it follow the standard round-up behaviour: 1.5 -> 2, etc.
  • superusers can see everything. I didn't change anything here, as it would have added complexity to the implementation. But let me know if you want to change that behaviour.
  • Take a look at the changes to GLOSSARY.md and let me know if you don't agree with the changes I made. These will become particularly relevant when implementing Manager view of team member's skill profile #809.
  • Two scenarios in the description have no test:
    • A former member who has left or been removed gets a 404 on the team page. This works because leaving a team removes the view_team permission, but no test checks it on this page.
    • A member who has assessed nothing appears in the roster and does not change the wheel.
  • The rest of the scenarios are covered. Would you like tests for these two in this PR, or are you happy to leave them?
  • I'll be honest, I'm not really sure what the process is for invoking a skill wheel. The way it is implemented looks sensible; it invokes the SkillProfile class and does some filtering based on whether the minimum number of users is met. Seems sensible?

What follows below is agentic output (from the /pr skill).

Summary

Adds a team page at /teams/<slug>/. It lists the team's managers and members and shows the team competency wheel, which is drawn from the team's aggregate skill profile. Each team on My Teams now links to its page.

GET /teams/<slug>/  (TeamDetailView)
  signed in and terms accepted, else redirect
  has view_team on this team, else 404 (also for unknown slugs)
  roster
    Managers: full name, or username if none, A-Z
    Members:  same
  team competency wheel  <- Team.aggregate_skill_profile()
    per skill, over current members who assessed it (a selected level 0 counts)
    keep the skill only if >= 3 members assessed it
    average rounded to a whole level, halves up
    no skill qualifies -> "Not enough team members have assessed their skills yet."

Skills below the minimum are dropped before the chart data is built, so they never appear in the page source. The page never shows how many members assessed each skill.

Not in this PR:

What researchers will see

Who can open the team page

Who What happens
Not signed in Sent to the login page
Signed in but has not accepted the terms Sent to the terms page
Team member Sees the team page
Team manager Sees the same page as a member. There are no manager-only parts yet
Signed in but not in the team 404, so the page does not reveal that the team exists
Former member who has left or been removed 404
Anyone, for a slug that matches no team 404
Superuser Sees the team page, as with Django's usual permissions

The address uses the team's slug, which does not change when the team is renamed. Links that people have saved keep working.

What the team competency wheel shows

Team situation What the page shows
2 members, both have assessed their skills No wheel. The message "Not enough team members have assessed their skills yet."
3 members, all have assessed some of the same skills A wheel showing only the skills all 3 assessed
3 members, but a skill has only been assessed by 2 of them That skill is left out of the wheel and the page source
Larger team where people assessed different skills Each skill appears once 3 or more members have assessed it
A member who has assessed nothing Listed in the roster, with no effect on the wheel
Members who picked level 0 for a skill Their 0 counts towards the average. For example, levels 0, 0 and 3 give an average of 1
An average that falls exactly halfway Rounded up. For example, levels 1, 1, 2 and 2 show as level 2
A former member's assessments Not counted

The page explains that the wheel shows averages rounded to whole levels, and that a skill only appears once enough members have assessed it.

My Teams

Each team card on My Teams links to the team's page, and the whole card is clickable. The Manager and Member badges are unchanged.

Evidence

  • Before: the new tests failed (no team-detail route, no roster, no wheel data, no link on My Teams).
    After: pytest passes all 307 tests. mypy ., pre-commit on every changed file, and mkdocs build --strict are all clean.

New tests, in pseudocode:

aggregate: levels 1,2,2,0 -> averages round halves up; level 0 counted
aggregate: skill assessed by 2 members -> left out; by 3 -> included
aggregate: former members' assessments ignored
team page: member -> 200; non-member -> 404; unknown slug -> 404
team page: rename keeps the same address; terms not accepted -> redirect
team page: managers and members listed separately, sorted by name
team page: wheel data holds the rounded average; rarely assessed skill absent from HTML
team page: no qualifying skill -> message shown, no wheel script
my teams:  each team name links to its team page

I also checked this by hand with a local server and demo data. The data had teams of 2, 3 and 6 members, a manager who is only a member of another team, a user in no team, and a member who had assessed nothing:

alice, team of 2 -> 200, message shown, no wheel
alice, team of 3 -> 200, wheel with 16 skills
alice, team of 6 -> 200, wheel with 39 skills
frank (no team), any team page -> 404

Merge Danger

Door: two-way

There are no migrations or data changes. Reverting the PR removes the page and the links.

Blast Radius: small

My Teams cards now wrap the team name in a stretched link, so the whole card is clickable. Known limitation: if every member who assessed a skill picked the same lowest (0) or highest (4) level, the average shows everyone's level. This risk was accepted in #706.

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AdrianDAlessandro AdrianDAlessandro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the way there. I've made some suggestions below.

Comment thread docs/dev-guide/architecture.md Outdated
Comment on lines +79 to +82
levels, with halves rounding up. A skill is included only when at least
`MINIMUM_AGGREGATE_CONTRIBUTORS` (three) members have assessed it. Skills below
that minimum are left out of the page and its chart data entirely, and the page
never shows how many members assessed each skill.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is helpful. The point of having this team aggregate skills view is to be able to explore the whole team's skills. I imagine a dashboard with options to select different types of aggregates (min, max, avg, filtering for a " bus factor", etc). If we're restricting skills from being accessible at all, it's probably not very useful to the team.

I also think this protection for trying to not identify individual's skills is just not necessary, this is already a private page, so only team members can see it.

@TinyMarsh TinyMarsh Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I think I included this because I saw it as a requirement somewhere. Honestly I thought I saw it in the GLOSSARY or perhaps somewhere else but I can't see it now so I must have been hallucinating.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so the rule was real. It was in the glossary entry for "Aggregate skill profile" ("It is only shown when enough members contribute that no individual's skill profile can be deduced from it"). I've removed the minimum and rewritten that entry to match.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, that's probably something I didn't think hard enough about when it was included in the glossary before.

Comment thread main/models/team_models.py Outdated
# A skill only appears in a team's aggregate skill profile once this many
# current members have assessed it, so the average does not reveal one or two
# people's assessments.
MINIMUM_AGGREGATE_CONTRIBUTORS = 3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we might like to make configurable to exploring different types of visualisations in future, but for now I think it just prevents being able to get useful information out.

Comment thread main/models/team_models.py Outdated
)
.annotate(contributors=Count("id"), level_total=Sum("skill_level__level"))
.filter(contributors__gte=MINIMUM_AGGREGATE_CONTRIBUTORS)
.order_by(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we do this order_by in other times we pull this data? Seems like this is probably a repeatable pattern we're likely to use in a few places (not just the ordering, but the getting various querysets of SkillProfiles).

I wonder if we should pull this kind of DB-accessor code out into a services module (like team_services.py) but for building skill profiles specifically. Maybe a "visualisations" service, or a more generic "profiles" service. Something to think about, but maybe a refactor to be done in a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but the code that turns skill profiles into wheel data is repeated. Pulling these queries into a service module probably makes sense but it would touch the personal profile pages too so I'd rather do it in a separate PR. Want me to open an issue for it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think a new issue is a good idea

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have created #899

Comment thread main/templates/main/my-teams.html Resolved
Comment thread main/templates/main/team-detail.html Outdated
Comment on lines +10 to +15
<h2 class="h4">Managers</h2>
<ul>
{% for person in managers %}
<li>{{ person.get_full_name|default:person.username }}</li>
{% endfor %}
</ul>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of having dot-point lists we should have a table (to match the kinds of tables we see in the Learning Resources, Tools, etc pages). The table can have both managers and members in it, with a "Role" column that shows a badge that says "Manager" or "Member" (like the badges in the My Teams page). This will require adding a table to tables.py

Comment thread main/models/team_models.py Outdated
("manage_team_members", "Can manage team members"),
)

def aggregate_skill_profile(self) -> list[dict[str, str | int]]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised that this is a method of the Team model. This should definitely be in the team_services.py module.

Comment thread main/views/team_views.py Resolved
Comment thread GLOSSARY.md Resolved
@TinyMarsh

Copy link
Copy Markdown
Contributor Author

Thanks @AdrianDAlessandro . Think I've addressed all your comments. Please take another look.

@AdrianDAlessandro AdrianDAlessandro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual behaviour is all there and works well now. I've just got a few opinionated changes requested about how that behaviour is achieved

Comment thread main/views/team_views.py Outdated
Comment on lines 50 to 53
sorted_memberships = sorted(
memberships,
key=lambda membership: _display_name(membership.user).casefold(),
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this is (or should be) now covered by the table class. So we don't need to sort them or get the display name here anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, I've moved the sorting logic.

Comment thread direct_webapp/settings/settings.py Resolved
Comment thread main/views/team_views.py Resolved
Comment thread main/views/team_views.py Outdated
Comment on lines +29 to +43
class TeamDetailView(TermsAcceptedMixin, PermissionRequiredMixin, TemplateView):
"""Show a team to its members."""

request: AuthenticatedHttpRequest
template_name = "main/team-detail.html"
login_url: str = str(settings.LOGIN_URL)
permission_required = "main.view_team"
accept_global_perms = False
return_404 = True
team: Team

def get_permission_object(self) -> Team:
"""Return the team whose member permission is required."""
self.team = get_object_or_404(Team, slug=self.kwargs["team_slug"])
return self.team

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a DetailView (imported from django.views.generic) as the base class, instead of a TemplateView. This will require a few changes:

Suggested change
class TeamDetailView(TermsAcceptedMixin, PermissionRequiredMixin, TemplateView):
"""Show a team to its members."""
request: AuthenticatedHttpRequest
template_name = "main/team-detail.html"
login_url: str = str(settings.LOGIN_URL)
permission_required = "main.view_team"
accept_global_perms = False
return_404 = True
team: Team
def get_permission_object(self) -> Team:
"""Return the team whose member permission is required."""
self.team = get_object_or_404(Team, slug=self.kwargs["team_slug"])
return self.team
class TeamDetailView(TermsAcceptedMixin, PermissionRequiredMixin, DetailView[Team]):
"""Show a team to its members."""
model = Team
request: AuthenticatedHttpRequest
template_name = "main/team-detail.html"
login_url: str
permission_required = "main.view_team"
return_404 = True

Changes explained:

  • Adding model means it will automatically pull the object related to the slug, so we don't need get_permission_object
  • We don't need to specify login_url because it already is using the default value. The reason it's there is the agent did that to prevent a mypy error, but that error if sufficiently handled by the type hint above. Change this in the TeamInvitationLinkView too
  • accept_global_perms defaults to False
  • team is no longer needed because it is created by default as self.object by using the DetailView

Additionall changes:

  • The self.team used in get_context_data should be changed to self.object.
  • The url should be specified as path("teams/<slug:slug>/",... (needs to match the field name of the Team model).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair, that is nicer.

@TinyMarsh

Copy link
Copy Markdown
Contributor Author

Thanks @AdrianDAlessandro. 3 new commits for you to look at please.

@AdrianDAlessandro AdrianDAlessandro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! Sorry it took a while to get this review in

TinyMarsh and others added 17 commits November 30, 2026 13:04
Average each skill over current members' assessments, counting level 0
and leaving out members who have not assessed it. Round to whole levels,
halves up, and leave out skills assessed by fewer than three members.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Find the team by its slug. Members and superusers can open the page.
Everyone else gets "page not found", whether or not the team exists.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Show managers and other members in separate sections. Use each
person's full name, falling back to their username, and sort each list
alphabetically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Draw the team's aggregate skill profile with the existing skill wheel.
Skills that fewer than three members have assessed are left out of the
page entirely. The page explains that levels are rounded averages, and
shows a message instead of an empty wheel when no skill qualifies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make the team name a stretched link so the whole card opens the team
page. Tests now find each card by its link, because the name is no
longer the only text inside the heading.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The team page said "three" in its explanation, which would go stale if
MINIMUM_AGGREGATE_CONTRIBUTORS changed. Pass the constant to the
template instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AdrianDAlessandro
AdrianDAlessandro merged commit 1116627 into main Nov 30, 2026
7 checks passed
@AdrianDAlessandro
AdrianDAlessandro deleted the team-slug branch November 30, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a "<SlugTeam>" page

2 participants