Skip to content

Commit

Permalink
Merge pull request #3155 from GeotrekCE/2900_champs_labellisation_sen…
Browse files Browse the repository at this point in the history
…tiers

Add certification info on trails
  • Loading branch information
numahell authored Aug 2, 2022
2 parents 90e82f1 + ebb86fc commit bc86f93
Show file tree
Hide file tree
Showing 24 changed files with 713 additions and 48 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CHANGELOG

**New features**

- Add certification label and status fields on trails (#2900)
- Fix downgrade user permissions (is_staff, is_superuser) for external authent (#3156)
- Use permission bypass_structure on attachments and accessibility attachments (#2899)
- Add boolean field 'display_in_legend' to Report Status model
Expand Down
1 change: 1 addition & 0 deletions docs/install/advanced-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,7 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"comments",
"departure",
"arrival",
"certifications",
"date_insert",
"date_update",
"cities",
Expand Down
2 changes: 2 additions & 0 deletions docs/usage/management-modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Il s'agit d'un ensemble linéaire composés d'un ou plusieurs tronçons (entiers

Les sentiers permettent d'avoir une vision de gestionnaire sur un linéaire plus complet que les tronçons (qui sont découpés à chaque intersection) pour en connaitre les statuts, la signalétique, les aménagements, les interventions ainsi que les itinéraires et POI. Il est d'ailleurs possible d'ajouter une intervention sur un sentier complet directement depuis la fiche détail d'un sentier.

Ils permettent également de préciser une ou plusieurs certifications ainsi que leur statut.

A ne pas confondre avec le module Itinéraires qui permet de créer des randonnées publiées sur un portail Geotrek-rando.

Les statuts
Expand Down
21 changes: 20 additions & 1 deletion geotrek/core/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.contrib import admin

from geotrek.core.models import (PathSource, Stake, Usage, Network, Comfort)
from geotrek.core.models import (
PathSource, Stake, Usage, Network, Comfort,
CertificationLabel, CertificationStatus
)
from geotrek.common.mixins.actions import MergeActionMixin


Expand Down Expand Up @@ -39,8 +42,24 @@ class ComfortAdmin(MergeActionMixin, admin.ModelAdmin):
merge_field = "comfort"


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


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


admin.site.register(PathSource, PathSourceAdmin)
admin.site.register(Stake, StakeAdmin)
admin.site.register(Usage, UsageAdmin)
admin.site.register(Network, NetworkAdmin)
admin.site.register(Comfort, ComfortAdmin)
admin.site.register(CertificationLabel, CertificationLabelAdmin)
admin.site.register(CertificationStatus, CertificationStatusAdmin)
12 changes: 9 additions & 3 deletions geotrek/core/filters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf import settings
from django.db.models import Count, F, Q
from django.utils.translation import gettext_lazy as _
from django_filters import BooleanFilter, CharFilter, FilterSet
from django_filters import BooleanFilter, CharFilter, FilterSet, ModelMultipleChoiceFilter

from .models import Topology, Path, Trail
from .models import Topology, Path, Trail, CertificationLabel

from geotrek.altimetry.filters import AltimetryAllGeometriesFilterSet
from geotrek.authent.filters import StructureRelatedFilterSet
Expand Down Expand Up @@ -107,15 +107,21 @@ class Meta(StructureRelatedFilterSet.Meta):


class TrailFilterSet(AltimetryAllGeometriesFilterSet, ValidTopologyFilterSet, ZoningFilterSet, StructureRelatedFilterSet):
"""Trail filter set"""
name = CharFilter(label=_('Name'), lookup_expr='icontains')
departure = CharFilter(label=_('Departure'), lookup_expr='icontains')
arrival = CharFilter(label=_('Arrival'), lookup_expr='icontains')
comments = CharFilter(label=_('Comments'), lookup_expr='icontains')
certification_labels = ModelMultipleChoiceFilter(
field_name="certifications__certification_label",
label=_("Certification labels"),
queryset=CertificationLabel.objects.all(),
)

class Meta(StructureRelatedFilterSet.Meta):
model = Trail
fields = StructureRelatedFilterSet.Meta.fields + \
['name', 'departure', 'arrival', 'comments']
['name', 'departure', 'arrival', 'certification_labels', 'comments']


class TopologyFilterTrail(TopologyFilter):
Expand Down
72 changes: 72 additions & 0 deletions geotrek/core/fixtures/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,77 @@
"fields": {
"comfort": "Difficile"
}
},
{
"model": "core.certificationlabel",
"pk": 1,
"fields": {
"structure": null,
"label": "PDIPR"
}
},
{
"model": "core.certificationlabel",
"pk": 2,
"fields": {
"structure": null,
"label": "PDESI"
}
},
{
"model": "core.certificationlabel",
"pk": 3,
"fields": {
"structure": null,
"label": "RLESI"
}
},
{
"model": "core.certificationlabel",
"pk": 4,
"fields": {
"structure": null,
"label": "PR"
}
},
{
"model": "core.certificationlabel",
"pk": 5,
"fields": {
"structure": null,
"label": "VTT-FFC"
}
},
{
"model": "core.certificationstatus",
"pk": 1,
"fields": {
"structure": null,
"label": "Constitution du dossier"
}
},
{
"model": "core.certificationstatus",
"pk": 2,
"fields": {
"structure": null,
"label": "En cours d'instruction"
}
},
{
"model": "core.certificationstatus",
"pk": 3,
"fields": {
"structure": null,
"label": "Validée"
}
},
{
"model": "core.certificationstatus",
"pk": 4,
"fields": {
"structure": null,
"label": "Rejetée"
}
}
]
39 changes: 38 additions & 1 deletion geotrek/core/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.utils.translation import gettext_lazy as _
from django import forms
from django.forms.models import inlineformset_factory

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Div, Fieldset, Layout

from geotrek.common.forms import CommonForm
from geotrek.core.widgets import LineTopologyWidget
from geotrek.core.models import Path, Trail
from geotrek.core.models import Path, Trail, CertificationTrail
from geotrek.core.fields import TopologyField, SnappedLineStringField


Expand Down Expand Up @@ -104,6 +108,18 @@ def save(self, commit=True):


class TrailForm(TopologyForm):

fieldslayout = [
Div(
'structure',
'name',
'departure',
'arrival',
'comments',
Fieldset(_("Certifications")),
)
]

class Meta(CommonForm.Meta):
model = Trail
fields = CommonForm.Meta.fields + ['structure', 'name', 'departure', 'arrival', 'comments']
Expand All @@ -113,3 +129,24 @@ def __init__(self, *args, **kwargs):
modifiable = self.fields['topology'].widget.modifiable
self.fields['topology'].widget = LineTopologyWidget()
self.fields['topology'].widget.modifiable = modifiable


class CertificationTrailForm(forms.ModelForm):

class Meta:
model = CertificationTrail
fields = ('id', 'certification_label', 'certification_status')

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout('id', 'certification_label', 'certification_status')


CertificationTrailFormSet = inlineformset_factory(
Trail,
CertificationTrail,
form=CertificationTrailForm,
extra=1
)
37 changes: 32 additions & 5 deletions geotrek/core/locale/de/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: 2022-06-03 09:53+0000\n"
"POT-Creation-Date: 2022-07-19 14:34+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 @@ -40,9 +40,6 @@ msgstr ""
msgid "Valid geometry"
msgstr ""

msgid "length"
msgstr ""

msgid "Name"
msgstr ""

Expand Down Expand Up @@ -73,6 +70,9 @@ msgstr ""
msgid "Geometry overlaps another."
msgstr ""

msgid "Certifications"
msgstr ""

msgid "Validity"
msgstr ""

Expand Down Expand Up @@ -212,6 +212,21 @@ msgstr ""
msgid "Network"
msgstr ""

msgid "Certification label"
msgstr ""

msgid "Certification labels"
msgstr ""

msgid "Certification status"
msgstr ""

msgid "Certification statuses"
msgstr ""

msgid "Certification"
msgstr ""

msgid "Management"
msgstr ""

Expand Down Expand Up @@ -276,7 +291,16 @@ msgstr ""
msgid "Cancel"
msgstr ""

msgid "path"
msgid "No certification"
msgstr ""

msgid "Add"
msgstr ""

msgid "Remove"
msgstr ""

msgid "This field is required."
msgstr ""

msgid ""
Expand All @@ -288,6 +312,9 @@ msgid ""
"redirected."
msgstr ""

msgid "path"
msgstr ""

msgid "You should select two paths"
msgstr ""

Expand Down
37 changes: 32 additions & 5 deletions geotrek/core/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: 2022-06-03 09:53+0000\n"
"POT-Creation-Date: 2022-07-19 14:34+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 @@ -40,9 +40,6 @@ msgstr ""
msgid "Valid geometry"
msgstr ""

msgid "length"
msgstr ""

msgid "Name"
msgstr ""

Expand Down Expand Up @@ -73,6 +70,9 @@ msgstr ""
msgid "Geometry overlaps another."
msgstr ""

msgid "Certifications"
msgstr ""

msgid "Validity"
msgstr ""

Expand Down Expand Up @@ -212,6 +212,21 @@ msgstr ""
msgid "Network"
msgstr ""

msgid "Certification label"
msgstr ""

msgid "Certification labels"
msgstr ""

msgid "Certification status"
msgstr ""

msgid "Certification statuses"
msgstr ""

msgid "Certification"
msgstr ""

msgid "Management"
msgstr ""

Expand Down Expand Up @@ -276,7 +291,16 @@ msgstr ""
msgid "Cancel"
msgstr ""

msgid "path"
msgid "No certification"
msgstr ""

msgid "Add"
msgstr ""

msgid "Remove"
msgstr ""

msgid "This field is required."
msgstr ""

msgid ""
Expand All @@ -288,6 +312,9 @@ msgid ""
"redirected."
msgstr ""

msgid "path"
msgstr ""

msgid "You should select two paths"
msgstr ""

Expand Down
Loading

0 comments on commit bc86f93

Please sign in to comment.