Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit c475e30

Browse files
Merge pull request #25 from angloc/review/update-paths
Review/update paths
2 parents 60e77b6 + 90d2f3c commit c475e30

File tree

14 files changed

+160
-49
lines changed

14 files changed

+160
-49
lines changed

.devcontainer/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4+
ARG VARIANT="3.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
12+
# COPY requirements.txt /tmp/pip-tmp/
13+
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
14+
# && rm -rf /tmp/pip-tmp
15+
16+
# [Optional] Uncomment this section to install additional OS packages.
17+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
# && apt-get -y install --no-install-recommends <your-package-list-here>
19+
20+
# [Optional] Uncomment this line to install global node packages.
21+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": "..",
8+
"args": {
9+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
10+
// Append -bullseye or -buster to pin to an OS version.
11+
// Use -bullseye variants on local on arm64/Apple Silicon.
12+
"VARIANT": "3.10-bullseye",
13+
// Options
14+
"NODE_VERSION": "lts/*"
15+
}
16+
},
17+
18+
// Set *default* container specific settings.json values on container create.
19+
"settings": {
20+
"python.defaultInterpreterPath": "/usr/local/bin/python",
21+
"python.linting.enabled": true,
22+
"python.linting.pylintEnabled": true,
23+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
24+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
25+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
26+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
27+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
28+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
29+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
30+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
31+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
32+
},
33+
34+
// Add the IDs of extensions you want installed when the container is created.
35+
"extensions": [
36+
"ms-python.python",
37+
"ms-python.vscode-pylance"
38+
],
39+
40+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
41+
// "forwardPorts": [],
42+
43+
// Use 'postCreateCommand' to run commands after the container is created.
44+
"postCreateCommand": "./scripts/install-hooks.sh",
45+
46+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
47+
"remoteUser": "vscode",
48+
"features": {
49+
"docker-from-docker": "latest",
50+
"git": "latest"
51+
},
52+
//"runArgs": ["--init"],
53+
//"overrideCommand": false,
54+
"remoteEnv": {
55+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
56+
// Uncomment below if host is Windows/WSL (untested)
57+
// per https://docs.docker.com/compose/reference/envvars/
58+
// "COMPOSE_FORCE_WINDOWS_HOST": "true"
59+
},
60+
61+
62+
}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Docker configuration for backend development. Not created for production use.
22
# It does not include front-end .
33
# Main production build is done using Dockerfile in the root of the project
4-
FROM breneser/mssql-python-nodejs
4+
FROM python:3.10-bullseye
55

66
WORKDIR /code
77
ADD requirements.txt /code/
8-
RUN pip install -r requirements.txt
8+
RUN python -V && pip install --upgrade pip && pip install -r requirements.txt
99
ADD . /code

README.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ INSTALLED_APPS = [
1515
]
1616
```
1717

18+
Useful Imports
19+
--------------
20+
```python
21+
from django.db import models
22+
from django.db.models.signals import pre_save
23+
24+
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
25+
from wagtail.core.models import Page
26+
27+
from wagtailreacttaxonomy.models import TaxonomyMixin, PageTaxonomyPermissionsMixin,\
28+
ModelTaxonomyPermissionsMixin, format_permissions_json
29+
from wagtailreacttaxonomy.edit_handlers import TaxonomyPanel, PermissionsPanel
30+
```
31+
1832
How to use Taxonomy Term Component
1933
----------------------------------
2034

@@ -99,26 +113,50 @@ pre_save.connect(format_permissions_json, sender=TestModel)
99113
How to contribute
100114
-----------------
101115

102-
### Requirements
116+
### Getting started
117+
118+
#### With devcontainer and VSCode (recommended)
119+
120+
* Open repository folder in container
121+
122+
#### Build locally (old school)
123+
124+
##### Requirements
103125
* Docker
104126
* docker-compose
105-
You'll get all this lot installed nicely with (https://docs.docker.com/docker-for-mac/install).
106127

128+
You'll get all this lot installed nicely with https://docs.docker.com/docker-for-mac/install.
107129

108-
### Setup locally
109-
Add git hook
130+
### Add git hook
110131
```
111132
./scripts/install-hooks.sh
112133
```
113-
Build the image
134+
Now you are set
135+
136+
### Build the containers
114137
```
115138
docker-compose build
116139
```
117-
Run the containers
140+
### Create super user
141+
```
142+
docker-compose run --rm web python manage.py createsuperuser
143+
```
144+
### Exercise the application
145+
146+
#### Run the containers
118147
```
119148
docker-compose up
120149
```
121-
Create super user:
150+
151+
#### Browse to http://localhost:8000/admin and make your changes with live reload
152+
153+
1. Log in as superuser
154+
1. You will see a Taxonomy Terms entry in the admin menu
155+
1. Use this entry to upload and save the JSON text of your taxonomy
156+
1. Taxonomies are stored in your Django media folder (media in the test configuration)
157+
158+
### Run tests as required
159+
122160
```
123-
docker-compose run --rm web python manage.py createsuperuser
161+
docker-compose run --rm web python manage.py test
124162
```

config/settings/base.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1919
BASE_DIR = os.path.dirname(PROJECT_DIR)
2020

21+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
2122

2223
# Quick-start development settings - unsuitable for production
2324
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
@@ -40,7 +41,7 @@
4041
'wagtail.images',
4142
'wagtail.search',
4243
'wagtail.admin',
43-
'wagtail.core',
44+
'wagtail',
4445
'wagtail.contrib.settings',
4546
'wagtail.api.v2',
4647
'wagtail.contrib.modeladmin',
@@ -72,7 +73,6 @@
7273
'django.contrib.messages.middleware.MessageMiddleware',
7374
'django.middleware.clickjacking.XFrameOptionsMiddleware',
7475
'django.middleware.security.SecurityMiddleware',
75-
'wagtail.core.middleware.SiteMiddleware',
7676
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
7777
]
7878

@@ -178,17 +178,11 @@
178178

179179
# Base URL to use when referring to full URLs within the Wagtail admin backend -
180180
# e.g. in notification emails. Don't include '/admin' or a trailing slash
181-
BASE_URL = 'http://example.com'
181+
WAGTAILADMIN_BASE_URL = 'http://example.com'
182182

183183
# WAGTAILIMAGES_IMAGE_MODEL = 'wagtailapiimagerendition.CustomImage'
184184
WAGTAIL_USAGE_COUNT_ENABLED = True
185185

186-
# DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
187-
AZURE_ACCOUNT_NAME = os.environ.get('AZURE_ACCOUNT_NAME') # eg. 'campaignstorage'
188-
AZURE_ACCOUNT_KEY = os.environ.get('AZURE_ACCOUNT_KEY') # eg. '<secret key>'
189-
AZURE_CONTAINER = os.environ.get('AZURE_CONTAINER') # eg. 'campaign-resource-centre'
190-
AZURE_FILE_SHARE = os.environ.get('AZURE_FILE_SHARE')
191-
192186
ENV = os.environ.get('CMS_ENV', 'local')
193187

194188
# INITIALIZER = os.environ.get('INITIALIZER', False)

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
ports:
99
- "5432:5432"
1010
volumes:
11-
- ./db:/var/lib/postgresql/data
11+
- ${LOCAL_WORKSPACE_FOLDER:-.}/db:/var/lib/postgresql/data
1212
web:
1313
environment:
1414
HAY_DEBUG: "True"
@@ -26,7 +26,7 @@ services:
2626
build: .
2727
command: bash -c "./scripts/wait-for-it.sh db:5432 -- python3 ./manage.py migrate && python3 manage.py load_test_data_fixtures && python3 ./manage.py runserver 0.0.0.0:8000"
2828
volumes:
29-
- .:/code
29+
- ${LOCAL_WORKSPACE_FOLDER:-.}:/code
3030
ports:
3131
- "8000:8000"
3232
depends_on:

requirements.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
Django>=3.1,<3.2
2-
wagtail>=2.10,<2.11
1+
Django~=4.0
2+
wagtail~=3.0
33
psycopg2>=2.8,<2.9
44
python-crontab>=2.5,<2.6
55
django-cors-headers>=3.5,<3.6
6-
django-storages>=1.10,<1.11
7-
azure>=4,<5
6+
django-storages~=1.12
87
coverage>=5.2,<5.3
98
gunicorn>=20.0,<20.1
109
flake8>=3.8,<3.9
11-
django-debug-toolbar>=2.2,<2.3
10+
django-debug-toolbar~=3.2
1211
factory-boy>=3.0,<3.1
13-
django_extensions>=3.0,<3.1
12+
django_extensions~=3.1
1413
safety

test_page/management/commands/load_test_data_fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.core.management import call_command
55
from django.core.management.base import BaseCommand
66

7-
from wagtail.core.models import Page
7+
from wagtail.models import Page
88

99
class Command(BaseCommand):
1010
""" Command """

test_page/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from django.db import models
22
from django.db.models.signals import pre_save
33

4-
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
5-
from wagtail.core.models import Page
4+
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
5+
from wagtail.models import Page
66

77
from wagtailreacttaxonomy.models import TaxonomyMixin, PageTaxonomyPermissionsMixin, ModelTaxonomyPermissionsMixin, format_permissions_json
88
from wagtailreacttaxonomy.edit_handlers import TaxonomyPanel, PermissionsPanel

tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from wagtail.tests.utils import WagtailPageTests
1+
from wagtail.test.utils import WagtailPageTests
22

33

44
class TestNameClassTests(WagtailPageTests):

0 commit comments

Comments
 (0)