Skip to content

Commit

Permalink
Merge pull request #3663 from IdrissaD/feat/add_circulation_model
Browse files Browse the repository at this point in the history
Feat/add circulation model - #3578
  • Loading branch information
Chatewgne authored Nov 29, 2023
2 parents 94eee3c + 81b9a37 commit 75dc5bb
Show file tree
Hide file tree
Showing 31 changed files with 609 additions and 33 deletions.
1 change: 1 addition & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ if [ "$MANAGE_DB" = "true" ] && [ -z "$2" ]; then
geotrek loaddata -v0 cirkwi || true
geotrek loaddata -v0 basic || true
geotrek loaddata -v0 licenses || true
geotrek loaddata -v0 circulations || true
for dir in `ls -d /opt/geotrek-admin/lib/python3*/site-packages/geotrek/*/fixtures/upload`; do
cd $dir > /dev/null
cp -r * /opt/geotrek-admin/var/media/upload/
Expand Down
1 change: 1 addition & 0 deletions docker/load_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cd /opt/geotrek-admin
./manage.py loaddata cirkwi
./manage.py loaddata basic
./manage.py loaddata licenses
./manage.py loaddata circulations

# copy media files for fixtures
for dir in `find geotrek/ -type d -name upload`; do pushd `dirname $$dir` > /dev/null && cp -R $dir/* /opt/geotrek-admin/var/media/upload/ && popd > /dev/null; done
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
2.101.4+dev (XXXX-XX-XX)
------------------------

**New features**

-Land: Add ``CirculationEdge`` model to manage circulation types and authorization types in the land module (#3578)

**Improvements**

- Add rules fixture on sensitive area (#3470)
Expand Down
40 changes: 40 additions & 0 deletions docs/install/advanced-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ Color of the different layers on the map
COLORS_POOL = {'land': ['#f37e79', '#7998f3', '#bbf379', '#f379df', '#f3bf79', '#9c79f3', '#7af379'],
'physical': ['#f3799d', '#79c1f3', '#e4f379', '#de79f3', '#79f3ba', '#f39779', '#797ff3'],
'circulation': ['#f3799d', '#79c1f3', '#e4f379', '#de79f3', '#79f3ba', '#f39779', '#797ff3'],
'competence': ['#a2f379', '#f379c6', '#79e9f3', '#f3d979', '#b579f3', '#79f392', '#f37984'],
'signagemanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
'workmanagement': ['#79a8f3', '#cbf379', '#f379ee', '#79f3e3', '#79f3d3'],
Expand Down Expand Up @@ -619,6 +620,16 @@ You can insert licenses of attachments with this command :
sudo geotrek loaddata /opt/geotrek-admin/lib/python*/site-packages/geotrek/common/fixtures/licenses.json
Land
~~~~~~~

You can insert circulation and authorization types with this command :

::

sudo geotrek loaddata /opt/geotrek-admin/lib/python*/site-packages/geotrek/land/fixtures/circulations.json


Outdoor
~~~~~~~

Expand Down Expand Up @@ -1011,6 +1022,15 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"agreement",
"uuid",
]
COLUMNS_LISTS["circulationedge_view"] = [
"eid",
"min_elevation",
"max_elevation",
"date_update",
"length_2d",
"date_insert",
"uuid",
]
COLUMNS_LISTS["physicaledge_view"] = [
"eid",
"date_insert",
Expand Down Expand Up @@ -1414,6 +1434,24 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"slope",
"uuid",
]
COLUMNS_LISTS["circulationedge_export"] = [
"eid",
"circulation_type",
"authorization_type",
"date_insert",
"date_update",
"cities",
"districts",
"areas",
"length",
"length_2d",
"ascent",
"descent",
"min_elevation",
"max_elevation",
"slope",
"uuid",
]
COLUMNS_LISTS["physicaledge_export"] = [
"eid",
"physical_type",
Expand Down Expand Up @@ -2180,6 +2218,8 @@ An exhaustive list of form fields hideable in each module.
"locked",
"uid",
"origin"
],
HIDDEN_FORM_FIELDS["circulationedge"] = [
]
Expand Down
2 changes: 1 addition & 1 deletion geotrek/altimetry/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_success_without_replace_update_altimetry_nds(self):
output_stdout = StringIO()
filename = os.path.join(os.path.dirname(__file__), 'data', 'elevation.tif')
self.trek = TrekFactory.create(geom=LineString((605600, 6650000), (605900, 6650010), srid=2154))
with self.assertNumQueries(21): # 5 for loaddem initial + 16 with selects and update geom
with self.assertNumQueries(22): # 5 for loaddem initial + 17 with selects and update geom
call_command('loaddem', filename, update_altimetry=True, verbosity=2, stdout=output_stdout)
self.assertIn('DEM successfully loaded.', output_stdout.getvalue())
self.assertIn('Everything looks fine, we can start loading DEM', output_stdout.getvalue())
Expand Down
30 changes: 28 additions & 2 deletions geotrek/authent/fixtures/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
["change_geom_landedge", "land", "landedge"],
["delete_landedge", "land", "landedge"],
["export_landedge", "land", "landedge"],
["add_circulationedge", "land", "circulationedge"],
["change_circulationedge", "land", "circulationedge"],
["change_geom_circulationedge", "land", "circulationedge"],
["delete_circulationedge", "land", "circulationedge"],
["export_circulationedge", "land", "circulationedge"],
["add_physicaledge", "land", "physicaledge"],
["change_physicaledge", "land", "physicaledge"],
["change_geom_physicaledge", "land", "physicaledge"],
Expand All @@ -114,8 +119,13 @@
["add_landtype", "land", "landtype"],
["change_landtype", "land", "landtype"],
["delete_landtype", "land", "landtype"],


["add_circulationtype", "land", "circulationtype"],
["change_circulationtype", "land", "circulationtype"],
["delete_circulationtype", "land", "circulationtype"],
["add_authorizationtype", "land", "authorizationtype"],
["change_authorizationtype", "land", "authorizationtype"],
["delete_authorizationtype", "land", "authorizationtype"],


["add_intervention", "maintenance", "intervention"],
["change_intervention", "maintenance", "intervention"],
Expand Down Expand Up @@ -173,6 +183,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down Expand Up @@ -274,6 +285,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down Expand Up @@ -344,6 +356,11 @@
["change_geom_landedge", "land", "landedge"],
["delete_landedge", "land", "landedge"],
["export_landedge", "land", "landedge"],
["add_circulationedge", "land", "circulationedge"],
["change_circulationedge", "land", "circulationedge"],
["change_geom_circulationedge", "land", "circulationedge"],
["delete_circulationedge", "land", "circulationedge"],
["export_circulationedge", "land", "circulationedge"],
["add_physicaledge", "land", "physicaledge"],
["change_physicaledge", "land", "physicaledge"],
["change_geom_physicaledge", "land", "physicaledge"],
Expand Down Expand Up @@ -381,6 +398,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down Expand Up @@ -428,6 +446,11 @@
["change_geom_landedge", "land", "landedge"],
["delete_landedge", "land", "landedge"],
["export_landedge", "land", "landedge"],
["add_circulationedge", "land", "circulationedge"],
["change_circulationedge", "land", "circulationedge"],
["change_geom_circulationedge", "land", "circulationedge"],
["delete_circulationedge", "land", "circulationedge"],
["export_circulationedge", "land", "circulationedge"],
["add_physicaledge", "land", "physicaledge"],
["change_physicaledge", "land", "physicaledge"],
["change_geom_physicaledge", "land", "physicaledge"],
Expand Down Expand Up @@ -465,6 +488,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down Expand Up @@ -557,6 +581,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down Expand Up @@ -672,6 +697,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down
1 change: 1 addition & 0 deletions geotrek/authent/fixtures/minimal.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
["read_competenceedge", "land", "competenceedge"],
["read_landedge", "land", "landedge"],
["read_physicaledge", "land", "physicaledge"],
["read_circulationedge", "land", "circulationedge"],
["read_signagemanagementedge", "land", "signagemanagementedge"],
["read_workmanagementedge", "land", "workmanagementedge"],

Expand Down
3 changes: 3 additions & 0 deletions geotrek/common/mixins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CustomColumnsMixin:
'PhysicalEdgeList': 'physicaledge_view',
'PhysicalEdgeJsonList': 'physicaledge_view',
'PhysicalEdgeFormatList': 'physicaledge_export',
'CirculationEdgeList': 'circulationedge_view',
'CirculationEdgeJsonList': 'circulationedge_view',
'CirculationEdgeFormatList': 'circulationedge_export',
'CompetenceEdgeList': 'competenceedge_view',
'CompetenceEdgeJsonList': 'competenceedge_view',
'CompetenceEdgeFormatList': 'competenceedge_export',
Expand Down
18 changes: 17 additions & 1 deletion geotrek/land/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin

from geotrek.common.mixins.actions import MergeActionMixin
from .models import PhysicalType, LandType
from .models import PhysicalType, LandType, CirculationType, AuthorizationType


class PhysicalTypeAdmin(MergeActionMixin, admin.ModelAdmin):
Expand All @@ -18,5 +18,21 @@ class LandTypeAdmin(MergeActionMixin, admin.ModelAdmin):
merge_field = "name"


class CirculationTypeAdmin(MergeActionMixin, admin.ModelAdmin):
list_display = ('name', 'structure', )
search_fields = ('name', 'structure')
list_filter = ('structure',)
merge_field = "name"


class AuthorizationTypeAdmin(MergeActionMixin, admin.ModelAdmin):
list_display = ('name', 'structure', )
search_fields = ('name', 'structure')
list_filter = ('structure',)
merge_field = "name"


admin.site.register(PhysicalType, PhysicalTypeAdmin)
admin.site.register(LandType, LandTypeAdmin)
admin.site.register(CirculationType, CirculationTypeAdmin)
admin.site.register(AuthorizationType, AuthorizationTypeAdmin)
25 changes: 24 additions & 1 deletion geotrek/land/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

from .models import (
CompetenceEdge, LandEdge, LandType, PhysicalEdge, PhysicalType,
SignageManagementEdge, WorkManagementEdge,
SignageManagementEdge, WorkManagementEdge, CirculationEdge, CirculationType,
AuthorizationType
)


Expand All @@ -23,6 +24,12 @@ class Meta(MapEntityFilterSet.Meta):
fields = ['physical_type']


class CirculationEdgeFilterSet(ValidTopologyFilterSet, MapEntityFilterSet):
class Meta(MapEntityFilterSet.Meta):
model = CirculationEdge
fields = ['circulation_type', 'authorization_type']


class LandEdgeFilterSet(ValidTopologyFilterSet, MapEntityFilterSet):
class Meta(MapEntityFilterSet.Meta):
model = LandEdge
Expand Down Expand Up @@ -63,6 +70,20 @@ def values_to_edges(self, values):
return PhysicalEdge.objects.filter(physical_type__in=values)


class TopologyFilterCirculationType(TopologyFilter):
model = CirculationType

def values_to_edges(self, values):
return CirculationEdge.objects.filter(circulation_type__in=values)


class TopologyFilterAuthorizationType(TopologyFilter):
model = AuthorizationType

def values_to_edges(self, values):
return CirculationEdge.objects.filter(authorization_type__in=values)


class TopologyFilterLandType(TopologyFilter):
model = LandType

Expand Down Expand Up @@ -95,6 +116,8 @@ def add_edge_filters(filter_set):
filter_set.add_filters({
'land_type': TopologyFilterLandType(label=_('Land edge'), required=False),
'physical_type': TopologyFilterPhysicalType(label=_('Physical edge'), required=False),
'circulation_type': TopologyFilterCirculationType(label=_('Circulation edge'), required=False),
'authorization_type': TopologyFilterAuthorizationType(label=_('Circulation edge'), required=False),
'competence': TopologyFilterCompetenceEdge(label=_('Competence edge'), required=False),
'signage': TopologyFilterSignageManagementEdge(label=_('Signage management edge'), required=False),
'work': TopologyFilterWorkManagementEdge(label=_('Work management edge'), required=False),
Expand Down
51 changes: 51 additions & 0 deletions geotrek/land/fixtures/circulations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"pk": 1,
"model": "land.circulationtype",
"fields": {
"name": "Pédestre"
}
},
{
"pk": 2,
"model": "land.circulationtype",
"fields": {
"name": "Cycliste"
}
},
{
"pk": 3,
"model": "land.circulationtype",
"fields": {
"name": "Motorisée"
}
},
{
"pk": 4,
"model": "land.circulationtype",
"fields": {
"name": "Équestre"
}
},
{
"pk": 1,
"model": "land.authorizationtype",
"fields": {
"name": "Autorisée"
}
},
{
"pk": 2,
"model": "land.authorizationtype",
"fields": {
"name": "Interdite"
}
},
{
"pk": 3,
"model": "land.authorizationtype",
"fields": {
"name": "Réglementée"
}
}
]
8 changes: 7 additions & 1 deletion geotrek/land/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from geotrek.core.widgets import LineTopologyWidget
from geotrek.core.forms import TopologyForm
from .models import (PhysicalEdge, LandEdge, CompetenceEdge, WorkManagementEdge,
SignageManagementEdge)
SignageManagementEdge, CirculationEdge)


class EdgeForm(TopologyForm):
Expand All @@ -24,6 +24,12 @@ class Meta(EdgeForm.Meta):
fields = EdgeForm.Meta.fields + ['land_type', 'owner', 'agreement']


class CirculationEdgeForm(EdgeForm):
class Meta(EdgeForm.Meta):
model = CirculationEdge
fields = EdgeForm.Meta.fields + ['circulation_type', 'authorization_type']


class OrganismForm(EdgeForm):
class Meta(EdgeForm.Meta):
fields = EdgeForm.Meta.fields + ['organization']
Expand Down
Loading

0 comments on commit 75dc5bb

Please sign in to comment.