Repository navigation
Add a team page with roster and team competency wheel - #866
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AdrianDAlessandro
left a comment
There was a problem hiding this comment.
Most of the way there. I've made some suggestions below.
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ah ok, that's probably something I didn't think hard enough about when it was included in the glossary before.
| # 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 |
There was a problem hiding this comment.
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.
| ) | ||
| .annotate(contributors=Count("id"), level_total=Sum("skill_level__level")) | ||
| .filter(contributors__gte=MINIMUM_AGGREGATE_CONTRIBUTORS) | ||
| .order_by( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yes, I think a new issue is a good idea
| <h2 class="h4">Managers</h2> | ||
| <ul> | ||
| {% for person in managers %} | ||
| <li>{{ person.get_full_name|default:person.username }}</li> | ||
| {% endfor %} | ||
| </ul> |
There was a problem hiding this comment.
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
| ("manage_team_members", "Can manage team members"), | ||
| ) | ||
|
|
||
| def aggregate_skill_profile(self) -> list[dict[str, str | int]]: |
There was a problem hiding this comment.
Just realised that this is a method of the Team model. This should definitely be in the team_services.py module.
|
Thanks @AdrianDAlessandro . Think I've addressed all your comments. Please take another look. |
AdrianDAlessandro
left a comment
There was a problem hiding this comment.
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
| sorted_memberships = sorted( | ||
| memberships, | ||
| key=lambda membership: _display_name(membership.user).casefold(), | ||
| ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Fair, I've moved the sorting logic.
| 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 |
There was a problem hiding this comment.
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:
| 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
modelmeans it will automatically pull the object related to the slug, so we don't needget_permission_object - We don't need to specify
login_urlbecause 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 theTeamInvitationLinkViewtoo accept_global_permsdefaults to Falseteamis no longer needed because it is created by default asself.objectby using theDetailView
Additionall changes:
- The
self.teamused inget_context_datashould be changed toself.object. - The url should be specified as
path("teams/<slug:slug>/",...(needs to match the field name of theTeammodel).
There was a problem hiding this comment.
Yeah fair, that is nicer.
|
Thanks @AdrianDAlessandro. 3 new commits for you to look at please. |
AdrianDAlessandro
left a comment
There was a problem hiding this comment.
Thanks for the changes! Sorry it took a while to get this review in
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>
15ed23b to
051120b
Compare
Closes #706
Some comments from me before the agentic output below
GLOSSARY.mdand 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.view_teampermission, but no test checks it on this page.SkillProfileclass and does some filtering based on whether the minimum number of users is met. Seems sensible?What follows below is agentic output (from the
/prskill).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.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
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
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
team-detailroute, no roster, no wheel data, no link on My Teams).After:
pytestpasses all 307 tests.mypy ., pre-commit on every changed file, andmkdocs build --strictare all clean.New tests, in pseudocode:
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:
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.