Skip to content

Commit

Permalink
Merge pull request #84 from Terralego/add_routing_infos
Browse files Browse the repository at this point in the history
Change ci, add routing
  • Loading branch information
submarcos authored Jan 22, 2021
2 parents d473e52 + c94810f commit 2a44647
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore = E501,W503
exclude = **settings/dev.py
exclude = **settings/dev.py, **settings/routing.py
51 changes: 38 additions & 13 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,34 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-18.04
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python-version: [ 3.6, 3.8 ]
django-version: [ 2.2, 3.1 ]
postgres: [ 'postgis/postgis:10-2.5', 'pgrouting/pgrouting:10-2.5-2.6.3' ]
experimental: [false]
include:
- django-version: dev
experimental: true
python-version: 3.8
postgres: 'postgis/postgis:10-2.5'
- django-version: dev
experimental: true
python-version: 3.8
postgres: 'pgrouting/pgrouting:10-2.5-2.6.3'
- django-version: 3.2a1
experimental: true
python-version: 3.8
postgres: 'postgis/postgis:10-2.5'
- django-version: 3.2a1
experimental: true
python-version: 3.8
postgres: 'pgrouting/pgrouting:10-2.5-2.6.3'
services:
postgres:
image: postgis/postgis:10-2.5
image: ${{ matrix.postgres }}
env:
POSTGRES_DB: travis_ci_test
POSTGRES_PASSWORD: travis_ci_test
Expand All @@ -25,13 +49,7 @@ jobs:
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
strategy:
matrix:
python-version: [3.6, 3.8]
django-version: [2.2, 3.1, dev]
include:
- django-version: dev
experimental: true
steps:
- uses: actions/checkout@v2
Expand All @@ -44,7 +62,11 @@ jobs:
run: |
sudo apt-get -y install libproj-dev binutils gdal-bin libgdal-dev
python -m pip install --upgrade pip setuptools wheel
pip install .[dev] -U
if [[ '${{ matrix.postgres }}' == 'pgrouting/pgrouting:10-2.5-2.6.3' ]]; then
pip install .[dev,routing] -U
else
pip install .[dev] -U
fi
if [[ ${{ matrix.django-version }} == dev ]]; then
pip install -e git+https://github.com/django/django@master#egg=django;
else
Expand All @@ -53,9 +75,12 @@ jobs:
- name: Test with coverage
run: |
coverage run ./manage.py test
coverage run -a ./manage.py test --settings=test_terra_geocrud.settings.async terra_geocrud.tests.test_serializers.CrudViewSerializerTestCase.test_exports_with_async_mode
if [[ '${{ matrix.postgres }}' == 'postgis/postgis:10-2.5' ]]; then
coverage run ./manage.py test --exclude-tag=routing
coverage run -a ./manage.py test --exclude-tag=routing --settings=test_terra_geocrud.settings.async terra_geocrud.tests.test_serializers.CrudViewSerializerTestCase.test_exports_with_async_mode
else
coverage run ./manage.py test --tag=routing --settings=test_terra_geocrud.settings.routing
fi
- name: Coverage upload
run: |
pip install codecov
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
1.0.4.dev0 (XXXX-XX-XX)
----------------------------

*
* Add routing settings for each crudview


1.0.3 (2020-12-10)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
],
tests_require=tests_require,
extras_require={
'routing': ['django-geostore-routing'],
'dev': tests_require + [
'django-debug-toolbar',
]
Expand Down
11 changes: 10 additions & 1 deletion terra_geocrud/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ class CrudPropertyInline(OrderableAdmin, NestedTabularInline):
inlines = [PropertyEnumInline, ]


class RoutingSettingsInLine(NestedTabularInline):
classes = ('collapse',)
verbose_name = _('Routing setting')
verbose_name_plural = _('Routing settings')
model = models.RoutingSettings
extra = 0
form = forms.RoutingSettingsForm


@admin_thumbnails.thumbnail('pictogram')
class CrudViewAdmin(OrderableAdmin, DjangoObjectActions, VersionAdmin, NestedModelAdmin):
ordering_field = "order"
Expand All @@ -80,7 +89,7 @@ class CrudViewAdmin(OrderableAdmin, DjangoObjectActions, VersionAdmin, NestedMod
form = forms.CrudViewForm
list_display = ['name', 'group', 'order', 'pictogram_thumbnail']
list_filter = ['group', ]
inlines = [FeatureDisplayGroupTabularInline, CrudPropertyInline, ExtraLayerStyleInLine]
inlines = [FeatureDisplayGroupTabularInline, CrudPropertyInline, ExtraLayerStyleInLine, RoutingSettingsInLine]
readonly_fields = ('ui_schema', )
fieldsets = (
(None, {'fields': (('name', 'object_name', 'object_name_plural', 'layer'), ('group', 'order', 'pictogram', 'pictogram_thumbnail'))}),
Expand Down
20 changes: 18 additions & 2 deletions terra_geocrud/forms.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import tempfile

from django import forms
from django.conf import settings
from django.contrib.gis.forms import GeometryField
from django.contrib.gis.gdal import DataSource
from django.utils.translation import gettext as _
from geostore.models import FeatureExtraGeom
from geostore.models import FeatureExtraGeom, Layer

from . import models
from .models import CrudView
from .models import CrudView, RoutingSettings


def parse_geometry_file(geom_file):
Expand Down Expand Up @@ -93,3 +94,18 @@ def save(self, commit=True):
class Meta:
model = FeatureExtraGeom
fields = "__all__"


class RoutingSettingsForm(forms.ModelForm):
layer = forms.ModelChoiceField(queryset=Layer.objects.filter(routable=True), required=False)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'geostore_routing' not in settings.INSTALLED_APPS:
self.fields['layer'].widget = forms.HiddenInput()
self.fields['provider'] = forms.ChoiceField(choices=RoutingSettings.CHOICES_EXTERNAL,
required=True)

class Meta:
model = RoutingSettings
fields = "__all__"
64 changes: 57 additions & 7 deletions terra_geocrud/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-10-22 09:29+0000\n"
"POT-Creation-Date: 2021-01-22 14:11+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -42,6 +42,12 @@ msgstr ""
msgid "Feature properties"
msgstr ""

msgid "Routing setting"
msgstr ""

msgid "Routing settings"
msgstr ""

msgid "UI schema & properties"
msgstr ""

Expand Down Expand Up @@ -101,20 +107,19 @@ msgstr ""
msgid "Geographic Editor Config"
msgstr ""

msgid ""
"GEOCRUD: Can create / edit / delete views / groups and associated layers."
msgid "CRUD: Can create / edit / delete views / groups and associated layers."
msgstr ""

msgid "GEOCRUD: Can read feature detail."
msgid "CRUD: Can read feature detail."
msgstr ""

msgid "GEOCRUD: Can create feature"
msgid "CRUD: Can create feature"
msgstr ""

msgid "GEOCRUD: Can change feature"
msgid "CRUD: Can change feature"
msgstr ""

msgid "GEOCRUD: Can delete feature"
msgid "CRUD: Can delete feature"
msgstr ""

msgid "You should define geometry with drawing or file."
Expand Down Expand Up @@ -233,6 +238,51 @@ msgid ""
"json_schema.get('type')})"
msgstr ""

msgid "Mapbox"
msgstr ""

msgid "Geostore"
msgstr ""

msgid "Label that will be shown on the list"
msgstr ""

msgid "Provider's name"
msgstr ""

msgid "Mabox transit"
msgstr ""

msgid "Driving"
msgstr ""

msgid "Walking"
msgstr ""

msgid "Cycling"
msgstr ""

msgid "You should define layer with a routable layer"
msgstr ""

msgid "You shouldn't define layer and mapbox_transit"
msgstr ""

msgid "You use the wrong provider"
msgstr ""

msgid "You should define a mapbox_transit with this provider"
msgstr ""

msgid "You should define a layer with this provider"
msgstr ""

msgid "This transit is already used"
msgstr ""

msgid "This layer is already used"
msgstr ""

msgid "VT styles and definitions"
msgstr ""

Expand Down
Binary file modified terra_geocrud/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
88 changes: 81 additions & 7 deletions terra_geocrud/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-10-22 09:29+0000\n"
"POT-Creation-Date: 2021-01-22 14:11+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -42,6 +42,16 @@ msgstr "Propriété"
msgid "Feature properties"
msgstr "Propriétés"

#, fuzzy
#| msgid "Other settings"
msgid "Routing setting"
msgstr "Autres réglages"

#, fuzzy
#| msgid "Other settings"
msgid "Routing settings"
msgstr "Autres réglages"

msgid "UI schema & properties"
msgstr "Propriété et UI schema"

Expand Down Expand Up @@ -104,22 +114,32 @@ msgstr "Géométrie annexes"
msgid "Geographic Editor Config"
msgstr "Config. Editeur Géographique"

msgid ""
"GEOCRUD: Can create / edit / delete views / groups and associated layers."
#, fuzzy
#| msgid ""
#| "GEOCRUD: Can create / edit / delete views / groups and associated layers."
msgid "CRUD: Can create / edit / delete views / groups and associated layers."
msgstr ""
"GEOCRUD: Peut créer / éditier / supprimer les vues / groupes et layers "
"associés."

msgid "GEOCRUD: Can read feature detail."
#, fuzzy
#| msgid "GEOCRUD: Can read feature detail."
msgid "CRUD: Can read feature detail."
msgstr "GEOCRUD: Peut lire les détails d'une feature"

msgid "GEOCRUD: Can create feature"
#, fuzzy
#| msgid "GEOCRUD: Can create feature"
msgid "CRUD: Can create feature"
msgstr "GEOCRUD: Peut créer des features"

msgid "GEOCRUD: Can change feature"
#, fuzzy
#| msgid "GEOCRUD: Can change feature"
msgid "CRUD: Can change feature"
msgstr "GEOCRUD: Peut modifier une feature"

msgid "GEOCRUD: Can delete feature"
#, fuzzy
#| msgid "GEOCRUD: Can delete feature"
msgid "CRUD: Can delete feature"
msgstr "GEOCRUD: Peut supprimer une feature"

msgid "You should define geometry with drawing or file."
Expand Down Expand Up @@ -245,6 +265,60 @@ msgstr ""
"la valeur '{self.value}' doît être de même type que la propriété ({self."
"property.json_schema.get('type')})"

msgid "Mapbox"
msgstr "Mapbox"

msgid "Geostore"
msgstr "Geostore"

msgid "Label that will be shown on the list"
msgstr "Étiquette qui sera affichée sur la liste"

msgid "Provider's name"
msgstr "Nom du fournisseur"

msgid "Mabox transit"
msgstr "Mabox transit"

msgid "Driving"
msgstr "Voiture"

msgid "Walking"
msgstr "Marche"

msgid "Cycling"
msgstr "Vélo"

#, fuzzy
#| msgid "You should define geometry with drawing or file."
msgid "You should define layer with a routable layer"
msgstr ""
"You devez définir la géométrie en la déssinant ou en fournissant un fichier."

msgid "You shouldn't define layer and mapbox_transit"
msgstr "Vous ne devez pas définir layer et mapbox_transit en même temps"

msgid "You use the wrong provider"
msgstr "Vous utilisez le mauvais provider"

#, fuzzy
#| msgid "You should define geometry with drawing or file."
msgid "You should define a mapbox_transit with this provider"
msgstr ""
"Vous devez définir la géométrie en la déssinant ou en fournissant un fichier."

#, fuzzy
#| msgid "You should define geometry with drawing or file."
msgid "You should define a layer with this provider"
msgstr ""
"Vous devez définir la géométrie en la déssinant ou en fournissant un fichier."

msgid "This transit is already used"
msgstr "Ce transit est déjà utilisé"

msgid "This layer is already used"
msgstr "Cette couche est déjà utilisé"

msgid "VT styles and definitions"
msgstr "Style et définition des tuiles vectorielles"

Expand Down
Loading

0 comments on commit 2a44647

Please sign in to comment.