Skip to content

Commit

Permalink
Merge branch 'release/8.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
marteinn committed Dec 22, 2023
2 parents 09a2258 + f85e41c commit 313f877
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 21 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
wagtail-version:
- 4.1.5
- 4.2.3
- 5.0
- 4.1
- 5.1
- 5.2
services:
postgres:
image: postgis/postgis:12-2.5
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
### Fixed
### Removed

## [8.1.0] - 2023.12.22
### Added
- Add tests for Wagtail 5.1 (@katdom13)
- Add support for Python 5.2 (@marteinn)
- Add support for Python 3.12 (@marteinn)

### Fixed
- Fix broken readme link (@wimfeijen)
- Include contribution guidelones in README (@marteinn)
- Throw Exception if geo string is invalid in GoogleMapsBlock to_python (@marteinn)

### Removed
- Drop support for Python 3.7 (@katdom13)
- Drop support for Wagtail 5.0 (@marteinn)
- Drop support for Wagtail 4.2 (@marteinn)

## [8.0.0] - 2023.05.21
### Fixed
- Add Wagtail 5.0 compability (@marteinn)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.10-slim
MAINTAINER Frojd
LABEL version="v0.1.0"

Expand All @@ -9,7 +9,7 @@ ADD . /app/
WORKDIR /app

RUN apt-get update \
&& apt-get install -y netcat \
&& apt-get install -y netcat-traditional \
binutils libproj-dev gdal-bin \
gettext \
libpq-dev build-essential \
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Wagtail-Geo-Widget is the complete map solution for your Wagtail site.

## Documentation

- [Getting started with Google Maps](https://github.com/Frojd/wagtail-geo-widget/blob/main/getting-started-with-google-maps.md)
- [Getting started with Google Maps](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/getting-started-with-google-maps.md)
- [Getting started with Leaflet](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/getting-started-with-leaflet.md)
- [Settings](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/settings.md)
- [Adding the widget to a Page](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/adding-to-a-page.md)
Expand All @@ -33,12 +33,14 @@ Wagtail-Geo-Widget is the complete map solution for your Wagtail site.

## Contribute

If you have ideas for improvement, please share your thoughts through an issue. We also welcome PR's
If you have ideas for improvement, please share your thoughts through an issue.

- Issue Tracker: [https://github.com/Frojd/wagtail-geo-widget/issues](https://github.com/Frojd/wagtail-geo-widget/issues)
- Source Code: [https://github.com/Frojd/wagtail-geo-widget](https://github.com/Frojd/wagtail-geo-widget)
- [Contribution documentation](https://github.com/Frojd/wagtail-geo-widget/blob/main/docs/contributing.md)

We also welcome Pull Requests (PR). Please note that this project uses git-flow so please use the `develop` branch when creating PR's.


## Security

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started-with-google-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Requirements

- Python 3.7+
- Wagtail 2.15+ and Django
- Python 3.8+
- Wagtail 4.1+ and Django 3.2+
- A Google account


Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started-with-leaflet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Requirements

- Python 3.7+
- Wagtail 2.15+ and Django
- Python 3.8+
- Wagtail 4.1+ and Django 3.2+
- Access to a tile provider for Leaflet, this library includes built in support for Open Street Map


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Wagtail",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
Expand All @@ -53,11 +53,11 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Utilities",
],
extras_require={"test": test_extras},
Expand Down
6 changes: 6 additions & 0 deletions tests/test_latlng_parse.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Dict, cast

from django.test import SimpleTestCase

from wagtailgeowidget.helpers import geosgeometry_str_to_struct
Expand All @@ -6,6 +8,7 @@
class LatLngParseTestCase(SimpleTestCase):
def test_that_basic_parsing_works(self):
struct = geosgeometry_str_to_struct("SRID=5432;POINT(12.0 13.0)")
struct = cast(Dict, struct)

self.assertEqual(struct["srid"], "5432")
self.assertEqual(struct["x"], "12.0")
Expand All @@ -18,13 +21,16 @@ def test_none_is_returned_on_invalid_struct(self):

def test_that_optional_space_between_point_and_data_is_accepted(self):
struct = geosgeometry_str_to_struct("SRID=5432;POINT (12.0 13.0)")
struct = cast(Dict, struct)

self.assertEqual(struct["srid"], "5432")
self.assertEqual(struct["x"], "12.0")
self.assertEqual(struct["y"], "13.0")

def test_negative_coords(self):
struct = geosgeometry_str_to_struct("SRID=5432;POINT(12.0 -13.0)")
struct = cast(Dict, struct)

self.assertEqual(struct["srid"], "5432")
self.assertEqual(struct["x"], "12.0")
self.assertEqual(struct["y"], "-13.0")
4 changes: 2 additions & 2 deletions wagtailgeowidget/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

__title__ = "wagtailgeowidget"
__version__ = "8.0.0"
__build__ = 800
__version__ = "8.1.0"
__build__ = 801
__author__ = "Martin Sandström"
__license__ = "MIT"
__copyright__ = "Copyright 2015-Present Fröjd Interactive"
3 changes: 3 additions & 0 deletions wagtailgeowidget/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def to_python(self, value):
return value

value = geosgeometry_str_to_struct(value)
if not value:
raise Exception("Error: Cannot parse '{}' into struct".format(value))

value = {
"lat": value["y"],
"lng": value["x"],
Expand Down
4 changes: 2 additions & 2 deletions wagtailgeowidget/helpers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import re
from typing import Dict
from typing import Dict, Optional

geos_ptrn = re.compile(
"^SRID=([0-9]{1,});POINT\s?\((-?[0-9\.]{1,})\s(-?[0-9\.]{1,})\)$"
)


def geosgeometry_str_to_struct(value: str) -> Dict:
def geosgeometry_str_to_struct(value: str) -> Optional[Dict]:
"""
Parses a geosgeometry string into struct.
Expand Down
6 changes: 3 additions & 3 deletions wagtailgeowidget/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from typing import Dict

from django import forms
from django.forms import widgets
Expand Down Expand Up @@ -225,9 +226,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


# class GeocoderField(forms.HiddenInput):
class GeocoderField(WidgetWithScript, widgets.TextInput):
geocoder = None
geocoder = geocoders.NOMINATIM

def __init__(self, *args, **kwargs):
self.geocoder = kwargs.pop("geocoder", geocoders.NOMINATIM)
Expand Down Expand Up @@ -257,7 +257,7 @@ def media(self):
)

def render_js_init(self, id_, name, value):
field_by_geocoder = {
field_by_geocoder: Dict[str, str] = {
"nominatim": "NominatimGeocoderField",
"google_maps": "GoogleMapsGeocoderField",
"mapbox": "MapboxGeocoderField",
Expand Down

0 comments on commit 313f877

Please sign in to comment.