Skip to content

Commit

Permalink
Merge pull request #43 from chnm/feature/wagtail
Browse files Browse the repository at this point in the history
Adding Wagtail support for editable pages
  • Loading branch information
hepplerj authored Aug 29, 2024
2 parents faa94f1 + 43eb29b commit abe7cf9
Show file tree
Hide file tree
Showing 16 changed files with 533 additions and 25 deletions.
44 changes: 39 additions & 5 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
# Application definition

INSTALLED_APPS = [
"accounts",
"manuscript",
"map",
"pages",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail",
"modelcluster",
"taggit",
"admin_interface",
"colorfield",
"django.contrib.admin",
Expand All @@ -59,9 +75,6 @@
"django_browser_reload",
"import_export",
"django_dbml",
"accounts",
"manuscript",
"map",
]

MIDDLEWARE = [
Expand All @@ -75,6 +88,7 @@
"django.middleware.locale.LocaleMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django_browser_reload.middleware.BrowserReloadMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
]

ROOT_URLCONF = "config.urls"
Expand Down Expand Up @@ -173,12 +187,32 @@
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_ROOT = str(BASE_DIR / "staticfiles")
STATIC_URL = "static/"
STATIC_URL = "/static/"
STATICFILES_DIRS = [
BASE_DIR / "static",
]
MEDIA_ROOT = str(BASE_DIR / "media")
MEDIA_URL = "media/"
MEDIA_URL = "/media/"

ADMINS = [
("Jason Heppler", "jheppler@gmu.edu"),
]
MANAGERS = ADMINS

# Wagtail settings
WAGTAIL_SITE_NAME = "La Sfera"
WAGTAILADMIN_BASE_URL = "https://dev.lasfera.rrchnm.org"
WAGTAILDOCS_EXTENSIONS = [
"csv",
"docx",
"key",
"odt",
"pdf",
"rtf",
"txt",
"xlsx",
]
TAGGIT_CASE_INSENSITIVE = True

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
Expand Down
6 changes: 6 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os.path

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import include, path
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls

urlpatterns = [
path("", include("manuscript.urls")),
Expand All @@ -12,5 +16,7 @@
path("login/", auth_views.LoginView.as_view(), name="login"),
path("logout/", auth_views.LogoutView.as_view(), name="logout"),
path("prose/", include("prose.urls")),
path("cms/", include(wagtailadmin_urls)),
path("pages/", include(wagtail_urls)),
path("__reload__/", include("django_browser_reload.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
19 changes: 19 additions & 0 deletions manuscript/migrations/0099_alter_location_country.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.2 on 2024-08-27 19:51

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("manuscript", "0098_linecode_associated_folio"),
]

operations = [
migrations.AlterField(
model_name="location",
name="country",
field=models.CharField(
blank=True, max_length=255, null=True, verbose_name="Modern location"
),
),
]
Empty file added pages/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions pages/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions pages/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PagesConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "pages"
58 changes: 58 additions & 0 deletions pages/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 5.0.2 on 2024-08-27 19:26

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


class Migration(migrations.Migration):
initial = True

dependencies = [
("wagtailcore", "0094_alter_page_locale"),
]

operations = [
migrations.CreateModel(
name="AboutPage",
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",
),
),
("body", wagtail.fields.RichTextField(blank=True)),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
migrations.CreateModel(
name="SpecificationsPage",
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",
),
),
("body", wagtail.fields.RichTextField(blank=True)),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
]
18 changes: 18 additions & 0 deletions pages/migrations/0002_aboutpage_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-08-27 19:51

import wagtail.fields
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("pages", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="aboutpage",
name="team",
field=wagtail.fields.RichTextField(blank=True),
),
]
39 changes: 39 additions & 0 deletions pages/migrations/0003_sitepage_delete_specificationspage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 5.0.2 on 2024-08-27 20:17

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


class Migration(migrations.Migration):
dependencies = [
("pages", "0002_aboutpage_team"),
("wagtailcore", "0094_alter_page_locale"),
]

operations = [
migrations.CreateModel(
name="SitePage",
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",
),
),
("body", wagtail.fields.RichTextField(blank=True)),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
migrations.DeleteModel(
name="SpecificationsPage",
),
]
Empty file added pages/migrations/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions pages/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from wagtail.admin.panels import FieldPanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.fields import RichTextField
from wagtail.models import Page


class AboutPage(RoutablePageMixin, Page):
body = RichTextField(blank=True)
team = RichTextField(blank=True)

content_panels = Page.content_panels + [
FieldPanel("body", classname="full"),
FieldPanel("team", classname="full"),
]


class SitePage(Page):
body = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel("body", classname="full"),
]
3 changes: 3 additions & 0 deletions pages/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Loading

0 comments on commit abe7cf9

Please sign in to comment.