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

Commit

Permalink
Merge pull request #26 from nhsuk/CV-1119
Browse files Browse the repository at this point in the history
Cv-1119
  • Loading branch information
Ross-Clark authored Aug 11, 2023
2 parents c475e30 + cfd5a82 commit ccade11
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 145 deletions.
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Useful Imports
from django.db import models
from django.db.models.signals import pre_save

from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
from wagtail.core.models import Page
from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList, PageChooserPanel
from wagtail.models import Page

from wagtailreacttaxonomy.models import TaxonomyMixin, PageTaxonomyPermissionsMixin,\
ModelTaxonomyPermissionsMixin, format_permissions_json
from wagtailreacttaxonomy.edit_handlers import TaxonomyPanel, PermissionsPanel
from wagtailreacttaxonomy.panels import TaxonomyPanel, PermissionsPanel
```

How to use Taxonomy Term Component
Expand Down
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = [
"setuptools>=61.2",
]
build-backend = "setuptools.build_meta"

[project]
name = "wagtail-reacttaxonomy"
version = "0.1"
authors = [
{ name = "Yohan Lebret", email = "[email protected]" },
]
description = "Add React Taxonomy component to a wagtail page and store it as a json in the db"
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 4.0",
"Framework :: Wagtail",
"Framework :: Wagtail :: 3",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
]

[project.license]
text = "MIT"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.urls]
Homepage = "https://github.com/nhsuk/wagtail-reacttaxonomy"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
namespaces = false
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django~=4.0
wagtail~=3.0
psycopg2>=2.8,<2.9
wagtail~=3.0.3
psycopg2-binary>=<2.9.6
python-crontab>=2.5,<2.6
django-cors-headers>=3.5,<3.6
django-storages~=1.12
Expand Down
36 changes: 0 additions & 36 deletions setup.py

This file was deleted.

5 changes: 3 additions & 2 deletions test_page/management/commands/load_test_data_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def handle(self, *args, **options):
self.no_output = options['no_output']

User = get_user_model()
username = os.environ.get('CMS_SUPERUSER_USERNAME', 'superadmin')
username = os.environ.get('CMS_SUPERUSER_USERNAME', 'admin')
if not User.objects.filter(username=username).exists():
# Create superuser
self.stdout.write('1 - Create superuser')
password = os.environ.get('CMS_SUPERUSER_PASSWORD', 'superpassword')
password = os.environ.get('CMS_SUPERUSER_PASSWORD', 'admin')
superuser = User.objects.create_superuser(username, None, password, id=8)
self.stdout.write(self.style.SUCCESS('DONE'))

Expand All @@ -38,3 +38,4 @@ def handle(self, *args, **options):
except Page.DoesNotExist:
pass
self.stdout.write(self.style.SUCCESS('DONE'))
self.stdout.write(self.style.NOTICE('run python3 ./manage.py fixtree'))
26 changes: 26 additions & 0 deletions test_page/migrations/0002_taxtestpage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.0.10 on 2023-08-10 21:05

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0069_log_entry_jsonfield'),
('test_page', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='TaxTestPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('taxonomy_json', models.TextField(blank=True, null=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page', models.Model),
),
]
15 changes: 13 additions & 2 deletions test_page/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from wagtail.models import Page

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


class TestPage(Page, TaxonomyMixin, PageTaxonomyPermissionsMixin):
Expand Down Expand Up @@ -56,4 +56,15 @@ class TestModel(ModelTaxonomyPermissionsMixin):
def __str__(self):
return 'TestModel - {0}'.format(self.id)

pre_save.connect(format_permissions_json, sender=TestModel)
class TaxTestPage(Page, TaxonomyMixin):

taxonomy_term_panels = [
TaxonomyPanel('taxonomy_json', taxonomy_terms_id='test_taxonomy'),
]

edit_handler = TabbedInterface([
ObjectList(Page.content_panels, heading='Content'),
ObjectList(taxonomy_term_panels, heading='Taxonomy'),
])

pre_save.connect(format_permissions_json, sender=TestModel)
100 changes: 0 additions & 100 deletions wagtailreacttaxonomy/edit_handlers.py

This file was deleted.

Loading

0 comments on commit ccade11

Please sign in to comment.