Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Organogram #435

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
FROM digital_workspace/wagtail:latest

ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN NODE_MAJOR=18

RUN adduser pwuser

RUN poetry run playwright install-deps
RUN poetry run playwright install

RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y --no-install-recommends \
nodejs
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install nodejs -y

RUN npm install
RUN npm run build
Expand Down
152 changes: 152 additions & 0 deletions src/peoplefinder/templates/peoplefinder/organogram.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@

{% load markdown %}
{% load webpack_static from webpack_loader %}


{% load workspace_navigation static %}
{% load render_bundle webpack_static from webpack_loader %}
{% load static wagtailcore_tags %}
{% load cookie_banner %}
{% load site_alert %}
{% load git_info %}
<!DOCTYPE html>
<html lang="en" class="govuk-template ">
<head>
{% if request.in_preview_panel %}<base target="_blank">{% endif %}
<meta charset="utf-8" />
<title>Organogram</title>
<meta name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#cd1632" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon"
sizes="16x16 32x32 48x48"
href="{% static 'core/favicon.ico' %}"
type="image/x-icon" />
<link rel="mask-icon"
href="{% webpack_static 'govuk-mask-icon.svg' %}"
color="#0b0c0c">
<link rel="apple-touch-icon"
href="{% static 'core/apple-touch-icon.png' %}">
<meta name="robots" content="noindex, nofollow">
<meta property="og:image"
content="{% webpack_static 'govuk-opengraph-image.png' %}">
{% render_bundle 'main' 'css' %}
</head>
<body class="govuk-template__body ">
<a href="#main-content"
data-module="govuk-skip-link"
class="govuk-skip-link">Skip to main content</a>
<div class="govuk-width-container">
<main class="govuk-main-wrapper "
id="main-content"
role="main"
tabindex="1">






<div style="display:flex; justify-content:center">
{% if manager %}
<div class="pf-team-card" style="max-width:33%">
<p class="govuk-body-s mb-0">
<a class="govuk-link" href="{% url 'organogram-person' manager.slug %}">{{ manager.full_name }}</a>
</p>
<p class="govuk-body-s">
{% for role in manager.roles.all %}
{% if role.job_title %}
{{ role.job_title }} in
{% else %}
Member of
{% endif %}
{{ role.team.name }}
<br>
{% endfor %}
</p>
</div>
{% endif %}
</div>
<div style="display:flex; justify-content:center">|</div>

<div style="display:flex; justify-content:center">

<div style="display:flex; gap:5px; border: 3px solid black;">
{% if profile.photo %}
<img src="{{ profile.photo.url }}" style="width:40px; height:40px;">
{% else %}
<img src="{% webpack_static 'no-photo-large.png' %}"
style="width:40px;
height:40px">
{% endif %}
<div>
{% if not profile.is_active %}
<div>
<strong class="govuk-tag govuk-tag--orange">Inactive</strong>
</div>
{% endif %}
<div>
<a class="govuk-link govuk-body govuk-!-font-weight-bold"
href="{% url 'profile-view' profile.slug %}">{{ profile.full_name }}</a>
</div>
<div class="govuk-body-s">
{% for role in roles %}
{% if role.job_title %}
{{ role.job_title }} in
{% else %}
Member of
{% endif %}
{{ role.team.name }}
<br>
{% endfor %}
</div>
</div>
</div>
</div>

{% if manages_profiles %}
<div style="display:flex;
justify-content:center;
gap:5px;
overflow-x:scroll;
overflow-y: hidden">
{% for profile in manages_profiles %}
<div style="max-width:33%; text-align:center">
|
<br>
<div class="pf-team-card">
<p class="govuk-body-s mb-0">
<a class="govuk-link" href="{% url 'organogram-person' profile.slug %}">{{ profile.full_name }}</a>
</p>
<p class="govuk-body-s">
{% for role in profile.roles.all %}
{% if role.job_title %}
{{ role.job_title }} in
{% else %}
Member of
{% endif %}
{{ role.team.name }}
<br>
{% endfor %}
</p>
</div>
</div>
{% endfor %}
</div>
<div style="clear:both">&nbsp;</div>
{% endif %}








</main>
</div>
{% render_bundle 'main' 'js' %}
{% git_info %}
</body>
</html>
5 changes: 5 additions & 0 deletions src/peoplefinder/templates/peoplefinder/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ <h2 class="govuk-summary-card__title">{{ profile_section.title }}</h2>
{% endif %}
{% endfor %}

<iframe src="{% url 'organogram-person' profile.slug %}"
style="border: 1px solid #b1b4b6;
width: 100%;
height: 380px"></iframe>

{% if perms.peoplefinder.view_auditlog %}
<details class="govuk-details" data-module="govuk-details">
<summary class="govuk-details__summary">
Expand Down
44 changes: 30 additions & 14 deletions src/peoplefinder/templates/peoplefinder/team.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,51 @@ <h2 class="govuk-heading-s">About the team</h2>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{% if sub_teams %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">People in {{ team.short_name }}</h2>
</div>
{% if sub_teams %}
<div class="govuk-grid-column-one-half text-right separated">
<a class="govuk-link inline-block"
href="{% url 'team-people' team.slug %}">View everyone in {{ team.short_name }} and sub-teams</a>
</div>
{% endif %}
</div>
{% if direct_team_members %}
<ul class="pf-team-member-cards">
{% for member in direct_team_members %}
<li>{% include 'peoplefinder/components/team-member-card.html' with member=member %}</li>
{% endfor %}
</ul>
{% else %}
<p class="govuk-body-s">This team has no direct members</p>
{% endif %}
</div>
</div>

{% if sub_teams %}

<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">Teams within {{ team.short_name }}</h2>
</div>
<div class="govuk-grid-column-one-half text-right separated">
<a class="govuk-link inline-block"
href="{% url 'team-people' team.slug %}">View all people</a>
<a class="govuk-link inline-block"
href="{% url 'team-tree' team.slug %}">View all sub-teams</a>
<a class="govuk-link inline-block"
href="{% url 'team-people-outside-subteams' team.slug %}">View {{ people_outside_subteams_count }} people not assigned to a team</a>
</div>
</div>
<ul class="pf-team-cards">
{% for team in sub_teams %}
<li>{% include 'peoplefinder/components/team-card.html' with team=team %}</li>
{% endfor %}
</ul>
{% else %}
<h2 class="govuk-heading-m">People in {{ team.short_name }}</h2>
<ul class="pf-team-member-cards">
{% for member in members %}
<li>{% include 'peoplefinder/components/team-member-card.html' with member=member %}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</div>
{% endif %}

{% if perms.peoplefinder.change_team and perms.peoplefinder.view_auditlog %}
<details class="govuk-details" data-module="govuk-details">
Expand Down
8 changes: 8 additions & 0 deletions src/peoplefinder/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
TeamPeopleView,
TeamTreeView,
)
from peoplefinder.views.organogram import OrganogramView

people_urlpatterns = [
path("", PeopleHome.as_view(), name="people-home"),
Expand All @@ -50,6 +51,13 @@
ProfileLegacyView.as_view(),
name="profile-legacy-view",
),
# designed to be viewed inside an iframe
path(
"<uuid:profile_slug>/organogram/",
OrganogramView.as_view(),
name="organogram-person",
),

# Redirects to profile-edit-section with edit_section=personal
path(
"<uuid:profile_slug>/blank-teams-form/",
Expand Down
36 changes: 36 additions & 0 deletions src/peoplefinder/views/organogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.views.decorators.clickjacking import xframe_options_sameorigin
from django.views.generic import DetailView
from django.utils.decorators import method_decorator

from peoplefinder.models import Person
from peoplefinder.services.team import TeamService
from peoplefinder.views.base import PeoplefinderView


@method_decorator(xframe_options_sameorigin, name="dispatch")
class OrganogramView(DetailView, PeoplefinderView):
template_name = "peoplefinder/organogram.html"
model = Person
context_object_name = "profile"
slug_url_kwarg = "profile_slug"

def get_queryset(self):
return super().get_queryset().active()

def get_context_data(self, **kwargs: dict) -> dict:
context = super().get_context_data(**kwargs)

profile = context["profile"]
roles = profile.roles.select_related("team").all()
context["roles"] = roles
context["manager"] = profile.manager
context["manages_profiles"] = self.get_queryset().filter(manager=profile)

if roles:
team = roles[0].team
context["team"] = team
context["parent_teams"] = list(TeamService().get_all_parent_teams(team)) + [
team
]

return context
10 changes: 10 additions & 0 deletions src/peoplefinder/views/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,18 @@ def get_context_data(self, **kwargs: dict) -> dict:
):
context["team_audit_log"] = AuditLogService.get_audit_log(team)

direct_members = self.get_direct_team_members(team, context["sub_teams"])
context["direct_team_members"] = direct_members

return context

def get_direct_team_members(self, team: Team, sub_teams: QuerySet) -> QuerySet:
return (
TeamMember.active.filter(team=team)
.order_by("person__first_name", "person__last_name")
.distinct("person", "person__first_name", "person__last_name")
)


@method_decorator(transaction.atomic, name="post")
class TeamEditView(PermissionRequiredMixin, UpdateView, PeoplefinderView):
Expand Down