diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 774e3b7..6ee174c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 097526d..62c100c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Dockerfile b/Dockerfile index 1792c1c..890e12e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-slim +FROM python:3.10-slim MAINTAINER Frojd LABEL version="v0.1.0" @@ -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 \ diff --git a/README.md b/README.md index 742e318..ab693ca 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/getting-started-with-google-maps.md b/docs/getting-started-with-google-maps.md index 476e72f..4452714 100644 --- a/docs/getting-started-with-google-maps.md +++ b/docs/getting-started-with-google-maps.md @@ -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 diff --git a/docs/getting-started-with-leaflet.md b/docs/getting-started-with-leaflet.md index b15d707..d9b5268 100644 --- a/docs/getting-started-with-leaflet.md +++ b/docs/getting-started-with-leaflet.md @@ -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 diff --git a/setup.py b/setup.py index 86a656f..8045460 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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}, diff --git a/tests/test_latlng_parse.py b/tests/test_latlng_parse.py index 7805997..42e3a9b 100644 --- a/tests/test_latlng_parse.py +++ b/tests/test_latlng_parse.py @@ -1,3 +1,5 @@ +from typing import Dict, cast + from django.test import SimpleTestCase from wagtailgeowidget.helpers import geosgeometry_str_to_struct @@ -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") @@ -18,6 +21,7 @@ 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") @@ -25,6 +29,8 @@ def test_that_optional_space_between_point_and_data_is_accepted(self): 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") diff --git a/wagtailgeowidget/__init__.py b/wagtailgeowidget/__init__.py index 4cc8070..eddd765 100644 --- a/wagtailgeowidget/__init__.py +++ b/wagtailgeowidget/__init__.py @@ -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" diff --git a/wagtailgeowidget/blocks.py b/wagtailgeowidget/blocks.py index 033678c..d7ac2bd 100644 --- a/wagtailgeowidget/blocks.py +++ b/wagtailgeowidget/blocks.py @@ -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"], diff --git a/wagtailgeowidget/helpers.py b/wagtailgeowidget/helpers.py index a2d23c7..c249f99 100644 --- a/wagtailgeowidget/helpers.py +++ b/wagtailgeowidget/helpers.py @@ -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. diff --git a/wagtailgeowidget/widgets.py b/wagtailgeowidget/widgets.py index 33b5a70..62bece5 100644 --- a/wagtailgeowidget/widgets.py +++ b/wagtailgeowidget/widgets.py @@ -1,4 +1,5 @@ import json +from typing import Dict from django import forms from django.forms import widgets @@ -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) @@ -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",