Skip to content

Commit

Permalink
Refactor (#172)
Browse files Browse the repository at this point in the history
* Move things

* Restructure tests

* Refactor templates to project root

* Remove interfaces directory

* Move users from core to to app

* Move middleware to core

* Register auth, core as apps

* Rename base directory and references from controlpanel to ap

* Replace dashboard references with analytical-platform-ui

* Fixes so the container builds and runs

* Fix tests

* RIP Data Platform

* Bump libpq-dev version

* Retry libpq-dev version
  • Loading branch information
michaeljcollinsuk authored Jun 25, 2024
1 parent 70f83d4 commit 659aa43
Show file tree
Hide file tree
Showing 72 changed files with 125 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "analytical-platform-dashboard",
"name": "analytical-platform-ui",
"image": "ghcr.io/ministryofjustice/devcontainer-base:latest",
"features": {
"ghcr.io/devcontainers/features/node:1": {
Expand All @@ -14,7 +14,7 @@
},
"postCreateCommand": "bash scripts/devcontainer/post-create.sh",
"postStartCommand": "bash scripts/devcontainer/post-start.sh",
"runArgs": ["--name=analytical-platform-dashboard-devcontainer"],
"runArgs": ["--name=analytical-platform-ui-devcontainer"],
"customizations": {
"vscode": {
"extensions": [
Expand Down
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ max-line-length = 100
extend-ignore = E203, E704
exclude =
venv
per-file-ignores =
ap/*/migrations/*:E501,W292
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ jobs:
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/analytical-platform-dashboard:${{ github.ref_name }}
tags: ghcr.io/${{ github.repository_owner }}/analytical-platform-ui:${{ github.ref_name }}

- name: Sign
id: sign
run: |
cosign sign --yes ghcr.io/${{ github.repository_owner }}/analytical-platform-dashboard@${{ steps.push.outputs.digest }}
cosign sign --yes ghcr.io/${{ github.repository_owner }}/analytical-platform-ui@${{ steps.push.outputs.digest }}
- name: Verify
id: verify
run: |
cosign verify \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com \
--certificate-identity=https://github.com/${{ github.repository_owner }}/analytical-platform-dashboard/.github/workflows/release.yml@refs/tags/${{ github.ref_name }} \
ghcr.io/${{ github.repository_owner }}/analytical-platform-dashboard@${{ steps.push.outputs.digest }}
--certificate-identity=https://github.com/${{ github.repository_owner }}/analytical-platform-ui/.github/workflows/release.yml@refs/tags/${{ github.ref_name }} \
ghcr.io/${{ github.repository_owner }}/analytical-platform-ui@${{ steps.push.outputs.digest }}
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM public.ecr.aws/docker/library/node:20.11.1 AS build-node

WORKDIR /
COPY package.json package-lock.json ./
COPY controlpanel/interfaces/web/static/app.scss ./controlpanel/interfaces/web/static/app.scss
COPY assets/scss/app.scss ./assets/scss/app.scss

RUN npm install \
&& npm run css
Expand All @@ -13,9 +13,9 @@ RUN apk add --no-cache --virtual .build-deps \
libffi-dev=3.4.4-r3 \
gcc=13.2.1_git20231014-r0 \
musl-dev=1.2.4_git20230717-r4 \
&& apk add --no-cache libpq-dev=16.2-r0
&& apk add --no-cache libpq-dev=16.3-r0

WORKDIR /controlpanel
WORKDIR /ap

RUN mkdir --parents static/assets/fonts \
&& mkdir --parents static/assets/images \
Expand All @@ -27,7 +27,7 @@ COPY --from=build-node node_modules/govuk-frontend/dist/govuk/assets/images/. st
COPY --from=build-node node_modules/govuk-frontend/dist/govuk/all.bundle.js static/assets/js/govuk.js
COPY scripts/container/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY requirements.txt manage.py ./
COPY controlpanel controlpanel
COPY ap ap
COPY tests tests

RUN pip install --no-cache-dir --requirement requirements.txt \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ serve-sso:
aws-sso exec --profile analytical-platform-development:AdministratorAccess -- python manage.py runserver

container:
docker build -t controlpanel .
docker build -t ap .

test: container
@echo
@echo "> Running Python Tests (In Docker)..."
IMAGE_TAG=controlpanel docker compose --file=contrib/docker-compose-test.yml run --rm interfaces
IMAGE_TAG=ap docker compose --file=contrib/docker-compose-test.yml run --rm interfaces
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Analytical Platform Dashboard
# Analytical Platform UI

[![repo standards badge](https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=for-the-badge&label=MoJ%20Compliant&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Fanalytical-platform-dashboard&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAHJElEQVRYhe2YeYyW1RWHnzuMCzCIglBQlhSV2gICKlHiUhVBEAsxGqmVxCUUIV1i61YxadEoal1SWttUaKJNWrQUsRRc6tLGNlCXWGyoUkCJ4uCCSCOiwlTm6R/nfPjyMeDY8lfjSSZz3/fee87vnnPu75z3g8/kM2mfqMPVH6mf35t6G/ZgcJ/836Gdug4FjgO67UFn70+FDmjcw9xZaiegWX29lLLmE3QV4Glg8x7WbFfHlFIebS/ANj2oDgX+CXwA9AMubmPNvuqX1SnqKGAT0BFoVE9UL1RH7nSCUjYAL6rntBdg2Q3AgcAo4HDgXeBAoC+wrZQyWS3AWcDSUsomtSswEtgXaAGWlVI2q32BI0spj9XpPww4EVic88vaC7iq5Hz1BvVf6v3qe+rb6ji1p3pWrmtQG9VD1Jn5br+Knmm70T9MfUh9JaPQZu7uLsR9gEsJb3QF9gOagO7AuUTom1LpCcAkoCcwQj0VmJregzaipA4GphNe7w/MBearB7QLYCmlGdiWSm4CfplTHwBDgPHAFmB+Ah8N9AE6EGkxHLhaHU2kRhXc+cByYCqROs05NQq4oR7Lnm5xE9AL+GYC2gZ0Jm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BnepLsk9p6p35fzwvDSX5eVQvaDOzjnqzTl+1KC53+XzLINHd65O6lD1DnWbepPBhQ3q2jQyW+2oDkkAtdt5udpb7W+Q/OFGA7ol1zxu1tc8zNHqXercfDfQIOZm9fR815Cpt5PnVqsr1F51wI9QnzU63xZ1o/rdPPmt6enV6sXqHPVqdXOCe1rtrg5W7zNI+m712Ir+cer4POiqfHeJSVe1Raemwnm7xD3mD1E/Z3wIjcsTdlZnqO8bFeNB9c30zgVG2euYa69QJ+9G90lG+99bfdIoo5PU4w362xHePxl1slMab6tV72KUxDvzlAMT8G0ZohXq39VX1bNzzxij9K1Qb9lhdGe931B/kR6/zCwY9YvuytCsMlj+gbr5SemhqkyuzE8xau4MP865JvWNuj0b1YuqDkgvH2GkURfakly01Cg7Cw0+qyXxkjojq9Lw+vT2AUY+DlF/otYq1Ixc35re2V7R8aTRg2KUv7+ou3x/14PsUBn3NG51S0XpG0Z9PcOPKWSS0SKNUo9Rv2Mmt/G5WpPF6pHGra7Jv410OVsdaz217AbkAPX3ubkm240belCuudT4Rp5p/DyC2lf9mfq1iq5eFe8/lu+K0YrVp0uret4nAkwlB6vzjI/1PxrlrTp/oNHbzTJI92T1qAT+BfW49MhMg6JUp7ehY5a6Tl2jjmVvitF9fxo5Yq8CaAfAkzLMnySt6uz/1k6bPx59CpCNxGfoSKA30IPoH7cQXdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/analytical-platform-dashboard)
[![repo standards badge](https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=for-the-badge&label=MoJ%20Compliant&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Fanalytical-platform-ui&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAHJElEQ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ou3x/14PsUBn3NG51S0XpG0Z9PcOPKWSS0SKNUo9Rv2Mmt/G5WpPF6pHGra7Jv410OVsdaz217AbkAPX3ubkm240belCuudT4Rp5p/DyC2lf9mfq1iq5eFe8/lu+K0YrVp0uret4nAkwlB6vzjI/1PxrlrTp/oNHbzTJI92T1qAT+BfW49MhMg6JUp7ehY5a6Tl2jjmVvitF9fxo5Yq8CaAfAkzLMnySt6uz/1k6bPx59CpCNxGfoSKA30IPoH7cQXdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/analytical-platform-ui)

## Running Locally

The dashboard is run in a DevContainer via Docker. The DevContainer VSCode extension is recommended, as is Docker Desktop.

For more information on Dev Containers, see the [Data Platform docs.](https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#developing-the-data-platform)
For more information on Dev Containers, see the [Analytical Platform docs.](https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#developing-the-data-platform)


### Building the DevContainer
To build the dev container, ensure docker desktop is running, then open the AP Dashboard project in VSCode. Open the command pallet by hitting command+shift+p and search for ```Dev Containers: Reopen in container``` and hit enter. This will build the dev container.
To build the dev container, ensure docker desktop is running, then open the AP UI project in VSCode. Open the command pallet by hitting command+shift+p and search for ```Dev Containers: Reopen in container``` and hit enter. This will build the dev container.

If you are using a workspace with multiple applications, search for ```Dev Containers: Open folder in Container…``` instead, then select the AP UI folder. Once the dev container has finished building, it should install all the required Python and npm dependencies, as well as run the migrations.

### Environment Variables
There is an example environment file stored on 1Password named ```Analytical Platform Dashboard Env```. Paste the contents into a new file called ```.env``` in the root of the project.
There is an example environment file stored on 1Password named ```Analytical Platform UI Env```. Paste the contents into a new file called ```.env``` in the root of the project.

### Running Development Server
To run the server, you will need to use aws-sso cli. To find the correct profile, run ```aws-sso list``` in the terminal. This will provide you with a link to sign in via SSO. Once signed in, a list of profiles will be displayed. You are looking for the profile name linked to the ```analytical-platform-development``` AccountAlias.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions controlpanel/asgi.py → ap/asgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
ASGI config for controlpanel project.
ASGI config for ap project.
It exposes the ASGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "controlpanel.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ap.settings")

application = get_asgi_application()
File renamed without changes.
6 changes: 6 additions & 0 deletions ap/auth/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AuthConfig(AppConfig):
name = "ap.auth"
label = "oidc_auth"
2 changes: 1 addition & 1 deletion controlpanel/core/auth/oidc.py → ap/auth/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import structlog
from authlib.integrations.django_client import OAuth

from controlpanel.core.models.user import User
from ap.users.models import User

logger = structlog.get_logger(__name__)

Expand Down
10 changes: 10 additions & 0 deletions ap/auth/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path

from . import views

urlpatterns = [
path("authenticate/", views.OIDCAuthenticationView.as_view(), name="authenticate"),
path("login/", views.OIDCLoginView.as_view(), name="login"),
path("logout/", views.LogoutView.as_view(), name="logout"),
path("login-fail/", views.LoginFail.as_view(), name="login-fail"),
]
File renamed without changes.
1 change: 1 addition & 0 deletions ap/auth/views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .views import LoginFail, LogoutView, OIDCAuthenticationView, OIDCLoginView # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.shortcuts import redirect
from django.urls import reverse

from controlpanel.core.auth import OIDCSessionValidator
from ap.auth.oidc import OIDCSessionValidator


class OIDCLoginRequiredMixin(LoginRequiredMixin):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from authlib.common.security import generate_token
from authlib.integrations.django_client import OAuthError

from controlpanel.core.auth import OIDCSubAuthenticationBackend, oauth
from controlpanel.core.auth.utils import pkce_transform
from ap.auth.oidc import OIDCSubAuthenticationBackend, oauth
from ap.auth.utils import pkce_transform


class OIDCLoginView(View):
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions ap/core/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CoreConfig(AppConfig):
name = "ap.core"
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@


def nav_items(request):
data_products_url = reverse("data-products")
return {
"nav_items": [
{"name": "Home", "url": "/", "active": request.get_full_path() == "/"},
{
"name": "Data Products",
"url": data_products_url,
"active": request.get_full_path() == data_products_url,
},
]
}

Expand Down
1 change: 1 addition & 0 deletions ap/core/middleware/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .never_cache import DisableClientSideCachingMiddleware # noqa
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.utils.cache import add_never_cache_headers


# TODO this was copied from Control Panel do we still want/need it?
class DisableClientSideCachingMiddleware:
def __init__(self, get_response):
self.get_response = get_response
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ap/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ap.settings.common import * # noqa
29 changes: 15 additions & 14 deletions controlpanel/settings/common.py → ap/settings/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for controlpanel project.
Django settings for ap project.
Generated by 'django-admin startproject' using Django 4.2.7.
Expand All @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import os
from os.path import abspath, dirname, join
from pathlib import Path
Expand All @@ -17,10 +18,10 @@
import structlog

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent.parent

# Name of the project
PROJECT_NAME = "controlpanel"
PROJECT_NAME = "ap"

# Absolute path of project Django directory
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
Expand Down Expand Up @@ -61,14 +62,14 @@
"govuk_frontend_django",
# Provide structured log service
"django_structlog",
# The core logic of Control panel
"controlpanel.core",
# The frontend part of Control panel
"controlpanel.interfaces.web",
# First party project defined apps
"ap.auth",
"ap.core",
"ap.users",
]

MIDDLEWARE = [
"controlpanel.middleware.DisableClientSideCachingMiddleware",
"ap.core.middleware.DisableClientSideCachingMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
Expand All @@ -83,21 +84,21 @@
# The list of authentication backend used for checking user's access to app
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]

ROOT_URLCONF = "controlpanel.urls"
ROOT_URLCONF = "ap.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"controlpanel.interfaces.web.context_processors.nav_items",
"controlpanel.interfaces.web.context_processors.header_context",
"ap.core.context_processors.nav_items",
"ap.core.context_processors.header_context",
],
},
},
Expand Down Expand Up @@ -206,7 +207,7 @@
SESSION_COOKIE_SECURE = True

# Custom user model class
AUTH_USER_MODEL = "core.User"
AUTH_USER_MODEL = "users.User"

# -- OIDC Settings
AZURE_CLIENT_ID = os.environ.get("AZURE_CLIENT_ID")
Expand Down Expand Up @@ -262,7 +263,7 @@
"handlers": ["console"],
"level": LOG_LEVEL,
},
"controlpanel": {
"ap": {
"handlers": ["console"],
"level": LOG_LEVEL,
},
Expand Down
4 changes: 2 additions & 2 deletions controlpanel/settings/test.py → ap/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# First-party/Local
from controlpanel.settings.common import * # noqa: F403
from ap.settings.common import * # noqa: F403

ENV = "test"

LOG_LEVEL = "WARNING"

LOGGING["loggers"]["django_structlog"]["level"] = LOG_LEVEL # noqa: F405
LOGGING["loggers"]["controlpanel"]["level"] = LOG_LEVEL # noqa: F405
LOGGING["loggers"]["ap"]["level"] = LOG_LEVEL # noqa: F405

AUTHENTICATION_BACKENDS = [
"rules.permissions.ObjectPermissionBackend",
Expand Down
5 changes: 4 additions & 1 deletion controlpanel/urls.py → ap/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.contrib import admin
from django.urls import include, path

from . import views

urlpatterns = [
path("", include("controlpanel.interfaces.urls")),
path("", views.IndexView.as_view(), name="index"),
path("auth/", include("ap.auth.urls")),
path("admin/", admin.site.urls),
]
File renamed without changes.
4 changes: 2 additions & 2 deletions controlpanel/core/apps.py → ap/users/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class CliConfig(AppConfig):
class UsersConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "controlpanel.core"
name = "ap.users"
Loading

0 comments on commit 659aa43

Please sign in to comment.