Skip to content

Commit

Permalink
Merge branch 'feature/wagtail_2.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
marteinn committed Jan 30, 2018
2 parents be545ab + 00dedf7 commit 42f3ed4
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 285 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ venv*
.idea

example/wagtailgeowidget
example/wagtail
example/wagtail-2.0b1
2 changes: 2 additions & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
example/wagtail
example/wagtail-2*
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Google Maps widget for Wagtail that supports both GeoDjango PointField, Stream
## Requirements

- Python 2.7 / Python 3.5+
- Wagtail 1.8+ and Django
- Wagtail 1.13+ and Django
- A API key for Google Maps


Expand Down Expand Up @@ -96,7 +96,7 @@ The panel accepts an `address_field` if you want to use the map in coordination
```python
from django.db import models
from django.utils.translation import ugettext as _
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtailgeowidget.edit_handlers import GeoPanel


Expand All @@ -120,8 +120,8 @@ For more examples, look at the [example](https://github.com/Frojd/wagtail-geo-wi
To add a map in a StreamField, import and use the GeoBlock.

```python
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import StreamField
from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtailgeowidget.blocks import GeoBlock

class GeoStreamPage(Page):
Expand Down Expand Up @@ -152,7 +152,7 @@ The data is stored as a json struct and you can access it by using value.lat / v
Make sure you define a field representing the address at the same level as your GeoBlock, either in the StreamField or in a StructBlock.

```python
from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtailgeowidget.blocks import GeoBlock


Expand Down Expand Up @@ -198,7 +198,7 @@ The panel accepts an `address_field` if you want to use the map in coordination
```python
from django.contrib.gis.db import models
from django.utils.translation import ugettext as _
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtailgeowidget.edit_handlers import GeoPanel


Expand All @@ -224,6 +224,28 @@ For more examples, look at the [example](https://github.com/Frojd/wagtail-geo-wi
- `GEO_WIDGET_ZOOM`: Default zoom level for map (required, 7 is default).


## FAQ

### This library no longer works on Wagtail 1.13 LTS!

Wagtail 2.0 introduced a couple of breaking changes regarding the field api that required us to rewrite the `GeoPanel` component. To keep compability with Wagtail 1.13 we have moved the original `GeoPanel` to the package `wagtailgeowidget.legacy_edit_handlers`.

```python
from wagtail.wagtailcore.models import Page
from wagtailgeowidget.legacy_edit_handlers import GeoPanel

class StandardPage(Page):
location = models.CharField(max_length=250, blank=True, null=True)

content_panels = Page.content_panels + [
GeoPanel('location')
]

```

Please note that this edit handler will be removed as soon as the Wagtail 1.13 expires (which is April 2018).


## Roadmap

- [x] Editable map widget for GeoDjango PointerField
Expand Down
37 changes: 22 additions & 15 deletions example/examplesite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

import wagtail

from . import get_env

PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -24,22 +26,25 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

WAGTAIL_APPS = [
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
]


# Application definition

INSTALLED_APPS = [
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
'wagtail.wagtailsites',
'wagtail.wagtailusers',
'wagtail.wagtailsnippets',
'wagtail.wagtaildocs',
'wagtail.wagtailimages',
'wagtail.wagtailsearch',
'wagtail.wagtailadmin',
'wagtail.wagtailcore',

INSTALLED_APPS = WAGTAIL_APPS + [
'modelcluster',
'taggit',

Expand All @@ -63,13 +68,15 @@
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',

'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
]

MIDDLEWARE += [
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

ROOT_URLCONF = 'examplesite.urls'
Expand Down
9 changes: 5 additions & 4 deletions example/examplesite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from django.conf.urls import include, url
from django.contrib import admin

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

from search import views as search_views
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls

urlpatterns = [
url(r'^django-admin/', include(admin.site.urls)),
url(r'^django-admin/', admin.site.urls),

url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
Expand Down
58 changes: 54 additions & 4 deletions example/geopage/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,78 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-27 19:05
from __future__ import unicode_literals
# Generated by Django 2.0.1 on 2018-01-30 19:12

import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
import wagtail.core.blocks
import wagtail.core.fields
import wagtailgeowidget.blocks


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0032_add_bulk_delete_page_permission'),
('wagtailcore', '0040_page_draft_title'),
]

operations = [
migrations.CreateModel(
name='ClassicGeoPage',
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')),
('address', models.CharField(blank=True, max_length=250, null=True)),
('location', models.CharField(blank=True, max_length=250, null=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='GeoLocation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255)),
('address', models.CharField(blank=True, max_length=250, null=True)),
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
],
),
migrations.CreateModel(
name='GeoPage',
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')),
('address', models.CharField(blank=True, max_length=250, null=True)),
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='GeoStreamPage',
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.core.fields.StreamField((('map', wagtailgeowidget.blocks.GeoBlock()), ('map_struct', wagtail.core.blocks.StructBlock((('address', wagtail.core.blocks.CharBlock(required=True)), ('map', wagtailgeowidget.blocks.GeoBlock(address_field='address'))), icon='user'))))),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='GeoPageRelatedLocations',
fields=[
('geolocation_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='geopage.GeoLocation')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='related_locations', to='geopage.GeoPage')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
bases=('geopage.geolocation', models.Model),
),
]
26 changes: 0 additions & 26 deletions example/geopage/migrations/0002_auto_20170327_1909.py

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions example/geopage/migrations/0004_auto_20170327_1916.py

This file was deleted.

22 changes: 0 additions & 22 deletions example/geopage/migrations/0005_auto_20170327_1919.py

This file was deleted.

29 changes: 0 additions & 29 deletions example/geopage/migrations/0006_geostreampage.py

This file was deleted.

Loading

0 comments on commit 42f3ed4

Please sign in to comment.