diff --git a/docs/changelog.rst b/docs/changelog.rst
index a54fe842db..be9c45f501 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -15,7 +15,8 @@ CHANGELOG
- Add rules fixture on sensitive area (#3470)
- Change condition on signage & blade to select many of them (#3847)
- Allow to set headers in requests from Parsers (#3861)
-- Sort bladeType alphabetically #3821
+- Sort bladeType alphabetically (#3821)
+- Update ``Intervention`` model to have begin & end date (#3825)
**Documentation**
diff --git a/docs/install/advanced-configuration.rst b/docs/install/advanced-configuration.rst
index 9f48cafe2d..3375663dc6 100644
--- a/docs/install/advanced-configuration.rst
+++ b/docs/install/advanced-configuration.rst
@@ -1109,7 +1109,8 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"uuid",
]
COLUMNS_LISTS["intervention_view"] = [
- "date",
+ "begin_date",
+ "end_date",
"type",
"target",
"status",
@@ -1579,7 +1580,8 @@ A (nearly?) exhaustive list of attributes available for display and export as co
]
COLUMNS_LISTS["intervention_export"] = [
"name",
- "date",
+ "begin_date",
+ "end_date",
"type",
"target",
"status",
@@ -2028,6 +2030,7 @@ An exhaustive list of form fields hideable in each module.
"description",
"type",
"subcontracting",
+ "end_date",
"length",
"width",
"height",
@@ -2038,7 +2041,6 @@ An exhaustive list of form fields hideable in each module.
"subcontract_cost",
],
HIDDEN_FORM_FIELDS["project"] = [
- "type",
"type",
"domain",
"end_year",
diff --git a/geotrek/feedback/fixtures/test-integration.json b/geotrek/feedback/fixtures/test-integration.json
index 50ae601bc2..0c32367103 100644
--- a/geotrek/feedback/fixtures/test-integration.json
+++ b/geotrek/feedback/fixtures/test-integration.json
@@ -246,7 +246,7 @@
"pk": 1,
"fields": {
"label": "Intervention résolue",
- "text": "Pris en charge par ##supervisor## le ##intervention_date##"
+ "text": "Pris en charge par ##supervisor## le ##intervention_end_date##"
}
},
{
@@ -299,7 +299,8 @@
],
"target_id": 12,
"name": "Intervention on report",
- "date": "2022-05-17",
+ "begin_date": "2022-05-17",
+ "end_date": "2022-05-17",
"status": 3,
"date_insert": "2012-05-17T14:33:34.307Z",
"date_update": "2012-05-17T14:33:34.307Z"
diff --git a/geotrek/feedback/static/feedback/workflow.js b/geotrek/feedback/static/feedback/workflow.js
index 61827824a6..eb0624f8db 100644
--- a/geotrek/feedback/static/feedback/workflow.js
+++ b/geotrek/feedback/static/feedback/workflow.js
@@ -65,7 +65,7 @@ function display_predefined_email_in_email_field() {
} else {
text = predefined_emails[selected]["text"];
text = text.replace(/##supervisor##/g, resolved_intervention_info["username"]);
- text = text.replace(/##intervention_date##/g, resolved_intervention_info["date"]);
+ text = text.replace(/##intervention_end_date##/g, resolved_intervention_info["end_date"]);
$('#id_message_sentinel').val(text);
$('#id_message_administrators').val(text);
}
diff --git a/geotrek/feedback/templates/feedback/report_detail_attributes.html b/geotrek/feedback/templates/feedback/report_detail_attributes.html
index cae3d272c1..fd53894f73 100644
--- a/geotrek/feedback/templates/feedback/report_detail_attributes.html
+++ b/geotrek/feedback/templates/feedback/report_detail_attributes.html
@@ -125,7 +125,7 @@
{% trans "Attributes" %}
{% if perms.maintenance.add_intervention %}
{% trans "Intervention" %}
- {% with columns="name,status,stake,total_cost,date" %}
+ {% with columns="name,status,stake,total_cost,begin_date,end_date" %}
{% valuetable report.interventions.all columns=columns %}
{% endwith %}
{% if not suricate_workflow_enabled %}
diff --git a/geotrek/feedback/templatetags/feedback_tags.py b/geotrek/feedback/templatetags/feedback_tags.py
index 3a92767d23..3e15cb7e6e 100644
--- a/geotrek/feedback/templatetags/feedback_tags.py
+++ b/geotrek/feedback/templatetags/feedback_tags.py
@@ -63,7 +63,7 @@ def resolved_intervention_info(report):
username = user.username
resolved_intervention_info = {
- "date": report.interventions.first().date.strftime("%d/%m/%Y") if report.interventions else None,
+ "end_date": report.interventions.first().end_date.strftime("%d/%m/%Y") if report.interventions else None,
"username": username
}
return json.dumps(resolved_intervention_info)
diff --git a/geotrek/feedback/tests/test_forms.py b/geotrek/feedback/tests/test_forms.py
index 16b6e97b69..6ef6d85570 100644
--- a/geotrek/feedback/tests/test_forms.py
+++ b/geotrek/feedback/tests/test_forms.py
@@ -42,7 +42,7 @@ def setUpTestData(cls):
cls.filed_report_1 = ReportFactory(status=cls.filed_status, external_uuid=uuid.uuid4())
cls.filed_report_2 = ReportFactory(status=cls.filed_status, external_uuid=uuid.uuid4())
cls.waiting_report = ReportFactory(status=cls.waiting_status, uses_timers=True, external_uuid=uuid.uuid4())
- cls.intervention = ReportInterventionFactory(date=datetime(year=1997, month=4, day=4).date())
+ cls.intervention = ReportInterventionFactory(begin_date=datetime(year=1997, month=11, day=10).date(), end_date=datetime(year=1997, month=11, day=11).date())
cls.waiting_report = ReportFactory(status=cls.waiting_status, uses_timers=True, external_uuid=uuid.uuid4())
cls.solved_intervention_report = ReportFactory(status=cls.solved_intervention_status, external_uuid=uuid.uuid4())
cls.predefined_email_1 = PredefinedEmailFactory()
@@ -257,7 +257,7 @@ def test_workflow_program_step(self):
user = SuperUserFactory(username="admin", password="dadadad")
data = {
'name': "test_interv",
- 'date': "2025-12-12",
+ 'begin_date': "2025-12-12",
'status': 2,
'structure': user.profile.structure.pk,
}
@@ -283,9 +283,11 @@ def test_solving_report_intervention(self, mocked_post):
)
# Trigger resolving intervention
user = SuperUserFactory(username="admin", password="dadadad")
+ end_date = interv.begin_date
data = {
'name': interv.name,
- 'date': interv.date,
+ 'begin_date': interv.begin_date,
+ 'end_date': end_date,
'status': 3, # pk for "Terminée" from fixtures
'structure': user.profile.structure.pk
}
diff --git a/geotrek/feedback/tests/test_template_tags.py b/geotrek/feedback/tests/test_template_tags.py
index 5086590da8..7f132e8713 100644
--- a/geotrek/feedback/tests/test_template_tags.py
+++ b/geotrek/feedback/tests/test_template_tags.py
@@ -22,7 +22,7 @@ def setUpTestData(cls):
cls.user2 = UserFactory(username="Kurt")
UserProfileFactory.create(user=cls.user2)
cls.solved_status = ReportStatusFactory(identifier='solved_intervention', color="#448654")
- cls.intervention_solved_1 = ReportInterventionFactory(date=datetime(year=1997, month=4, day=4).date())
+ cls.intervention_solved_1 = ReportInterventionFactory(begin_date=datetime(year=1997, month=11, day=10).date(), end_date=datetime(year=1997, month=11, day=11).date())
# Simulate user created intervention
LogEntry.objects.log_action(
user_id=cls.user1.pk,
@@ -36,7 +36,7 @@ def setUpTestData(cls):
cls.status_1 = cls.report_1.status
cls.report_1.status = cls.solved_status
cls.report_1.save()
- cls.intervention_solved_2 = ReportInterventionFactory(date=datetime(year=1997, month=5, day=4).date())
+ cls.intervention_solved_2 = ReportInterventionFactory(begin_date=datetime(year=1997, month=11, day=10).date(), end_date=datetime(year=1997, month=11, day=11).date())
# Simulate user created intervention
LogEntry.objects.log_action(
user_id=cls.user2.pk,
@@ -55,11 +55,11 @@ def setUpTestData(cls):
def test_resolved_intervention_username(self):
self.assertEqual(
- "{\"date\": \"04/04/1997\", \"username\": \"Communaut\\u00e9 des Communes des Communaut\\u00e9s Communataires\"}",
+ "{\"end_date\": \"11/11/1997\", \"username\": \"Communaut\\u00e9 des Communes des Communaut\\u00e9s Communataires\"}",
resolved_intervention_info(self.report_1)
)
self.assertEqual(
- "{\"date\": \"04/05/1997\", \"username\": \"Kurt\"}",
+ "{\"end_date\": \"11/11/1997\", \"username\": \"Kurt\"}",
resolved_intervention_info(self.report_2)
)
diff --git a/geotrek/infrastructure/filters.py b/geotrek/infrastructure/filters.py
index e397777700..16fa25b66a 100644
--- a/geotrek/infrastructure/filters.py
+++ b/geotrek/infrastructure/filters.py
@@ -1,4 +1,5 @@
from django.contrib.contenttypes.models import ContentType
+from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from django_filters import CharFilter, MultipleChoiceFilter, ModelMultipleChoiceFilter, ChoiceFilter
from geotrek.altimetry.filters import AltimetryAllGeometriesFilterSet
@@ -36,6 +37,13 @@ class Meta(StructureRelatedFilterSet.Meta):
def filter_intervention_year(self, qs, name, value):
infrastructure_ct = ContentType.objects.get_for_model(Infrastructure)
- interventions = Intervention.objects.filter(target_type=infrastructure_ct, date__year__in=value) \
+ q_1 = Q()
+ for subvalue in value:
+ # Intervention started in year 'subvalue', ended in year 'subvalue',
+ # or was ongoing in year 'subvalue'
+ q_1 = q_1 | Q(begin_date__year__lt=subvalue, end_date__year__gt=subvalue)
+ q = Q(begin_date__year__in=value) | Q(end_date__year__in=value) | q_1
+ q = Q(q, target_type=infrastructure_ct)
+ interventions = Intervention.objects.filter(q) \
.values_list('target_id', flat=True)
return qs.filter(id__in=interventions).distinct()
diff --git a/geotrek/infrastructure/tests/test_filters.py b/geotrek/infrastructure/tests/test_filters.py
index 54493a5e2d..806f9c2e89 100644
--- a/geotrek/infrastructure/tests/test_filters.py
+++ b/geotrek/infrastructure/tests/test_filters.py
@@ -81,11 +81,11 @@ def test_intervention_filter(self):
# Bad signage: intervention with wrong year
bad_topo = self.factory()
- InterventionFactory(target=bad_topo, date=bad_date_year)
+ InterventionFactory(target=bad_topo, begin_date=bad_date_year)
# Good signage: intervention with the good year
good_topo = self.factory()
- InterventionFactory(target=good_topo, date=good_date_year)
+ InterventionFactory(target=good_topo, begin_date=good_date_year)
data = {
'intervention_year': year
@@ -105,11 +105,11 @@ def test_duplicate_implantation_year_filter(self):
# Bad signage: intervention with wrong year
topo_1 = self.factory()
- InterventionFactory(target=topo_1, date=year_t)
+ InterventionFactory(target=topo_1, begin_date=year_t)
# Good signage: intervention with the good year
topo_2 = self.factory()
- InterventionFactory(target=topo_2, date=year_t)
+ InterventionFactory(target=topo_2, begin_date=year_t)
response = self.client.get(model.get_list_url())
self.assertContains(response, '', count=1)
diff --git a/geotrek/maintenance/filters.py b/geotrek/maintenance/filters.py
index 7234b5932e..06d1b8afb4 100644
--- a/geotrek/maintenance/filters.py
+++ b/geotrek/maintenance/filters.py
@@ -2,13 +2,14 @@
from django.conf import settings
from django.contrib.gis.geos import GeometryCollection
from django.utils.translation import gettext_lazy as _
-from django_filters import ChoiceFilter, MultipleChoiceFilter
+from django_filters import ChoiceFilter, MultipleChoiceFilter, DateFromToRangeFilter
from mapentity.filters import PolygonFilter, PythonPolygonFilter
from geotrek.altimetry.filters import AltimetryPointFilterSet
from geotrek.authent.filters import StructureRelatedFilterSet
from geotrek.common.filters import OptionalRangeFilter, RightFilter
+from geotrek.common.widgets import OneLineRangeWidget
from geotrek.zoning.filters import (IntersectionFilterCity, IntersectionFilterDistrict,
IntersectionFilterRestrictedArea, IntersectionFilterRestrictedAreaType,
ZoningFilterSet)
@@ -121,6 +122,13 @@ class AltimetryInterventionFilterSet(AltimetryPointFilterSet):
slope = OptionalRangeFilter(label=_('slope'))
+class CustomDateFromToRangeFilter(DateFromToRangeFilter):
+ def __init__(self, *args, **kwargs):
+ super(DateFromToRangeFilter, self).__init__(*args, **kwargs)
+ self.field.fields[0].label = _('min %s') % self.field.label
+ self.field.fields[1].label = _('max %s') % self.field.label
+
+
class InterventionFilterSet(AltimetryInterventionFilterSet, ZoningFilterSet, StructureRelatedFilterSet):
ON_CHOICES = (('infrastructure', _("Infrastructure")), ('signage', _("Signage")), ('blade', _("Blade")),
('topology', _("Path")), ('trek', _("Trek")), ('poi', _("POI")), ('service', _("Service")),
@@ -130,8 +138,8 @@ class InterventionFilterSet(AltimetryInterventionFilterSet, ZoningFilterSet, Str
ON_CHOICES += (('course', _("Outdoor Course")), ('site', _("Outdoor Site")),)
bbox = PolygonTopologyFilter(lookup_expr='intersects')
- year = MultipleChoiceFilter(choices=lambda: Intervention.objects.year_choices(),
- field_name='date', lookup_expr='year', label=_("Year"))
+ begin_date = CustomDateFromToRangeFilter(lookup_expr='icontains', widget=OneLineRangeWidget(attrs={'type': 'date', 'class': 'minmax-field', 'title': _('Filter by begin date range')},), label=_('begin date'))
+ end_date = CustomDateFromToRangeFilter(lookup_expr='icontains', widget=OneLineRangeWidget(attrs={'type': 'date', 'class': 'minmax-field', 'title': _('Filter by end date range')},), label=_('end date'))
on = ChoiceFilter(field_name='target_type__model', choices=ON_CHOICES, label=_("On"), empty_label=_("On"))
area_type = InterventionIntersectionFilterRestrictedAreaType(label=_('Restricted area type'), required=False,
lookup_expr='intersects')
@@ -148,7 +156,6 @@ class Meta(StructureRelatedFilterSet.Meta):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.form.fields['year'].choices = Intervention.objects.year_choices()
class ProjectFilterSet(StructureRelatedFilterSet):
diff --git a/geotrek/maintenance/forms.py b/geotrek/maintenance/forms.py
index 53cea3caa1..5c95367441 100644
--- a/geotrek/maintenance/forms.py
+++ b/geotrek/maintenance/forms.py
@@ -7,7 +7,6 @@
from django.forms import FloatField
from django.forms.models import inlineformset_factory
from django.utils.translation import gettext_lazy as _
-
from geotrek.common.forms import CommonForm
from geotrek.core.fields import TopologyField
from geotrek.core.models import Topology
@@ -64,8 +63,14 @@ class InterventionForm(CommonForm):
topology = TopologyField(label="")
length = FloatField(required=False, label=_("Length"))
- project = forms.ModelChoiceField(required=False, label=_("Project"),
- queryset=Project.objects.existing())
+ project = forms.ModelChoiceField(
+ required=False, label=_("Project"),
+ queryset=Project.objects.existing()
+ )
+ end_date = forms.DateField(
+ required=False,
+ widget=forms.DateInput(attrs={"data-date-orientation": "bottom auto"}),
+ )
geomfields = ['topology']
leftpanel_scrollable = False
@@ -74,7 +79,8 @@ class InterventionForm(CommonForm):
Div(
'structure',
'name',
- 'date',
+ 'begin_date',
+ 'end_date',
'status',
'disorders',
'type',
@@ -97,7 +103,7 @@ class InterventionForm(CommonForm):
class Meta(CommonForm.Meta):
model = Intervention
fields = CommonForm.Meta.fields + \
- ['structure', 'name', 'date', 'status', 'disorders', 'type', 'description', 'subcontracting', 'length', 'width',
+ ['structure', 'name', 'begin_date', 'end_date', 'status', 'disorders', 'type', 'description', 'subcontracting', 'length', 'width',
'height', 'stake', 'project', 'access', 'material_cost', 'heliport_cost', 'subcontract_cost', 'topology']
def __init__(self, *args, target_type=None, target_id=None, **kwargs):
@@ -143,6 +149,18 @@ def __init__(self, *args, target_type=None, target_id=None, **kwargs):
or self.instance.geom.geom_type == 'LineString'))
self.fields['length'].widget.attrs['readonly'] = editable
+ if 'geotrek.feedback' in settings.INSTALLED_APPS and settings.SURICATE_WORKFLOW_ENABLED:
+ if self.instance.pk and self.instance.target and hasattr(self.instance.target, "report_interventions"):
+ self.fields["end_date"].required = True
+
+ def clean(self, *args, **kwargs):
+ clean_data = super().clean(*args, **kwargs)
+ begin_date = clean_data.get('begin_date')
+ end_date = clean_data.get('end_date')
+ if end_date and begin_date > end_date:
+ self.add_error('end_date', _('Begin date is after end date'))
+ return clean_data
+
def save(self, *args, **kwargs):
target = self.instance.target
if 'geotrek.feedback' in settings.INSTALLED_APPS and settings.SURICATE_WORKFLOW_ENABLED and isinstance(target, Report):
diff --git a/geotrek/maintenance/locale/de/LC_MESSAGES/django.po b/geotrek/maintenance/locale/de/LC_MESSAGES/django.po
index 434260d4a0..b10bb88ad5 100644
--- a/geotrek/maintenance/locale/de/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/de/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -33,6 +33,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr ""
@@ -63,7 +71,16 @@ msgstr ""
msgid "Outdoor Site"
msgstr ""
-msgid "Year"
+msgid "Filter by begin date range"
+msgstr ""
+
+msgid "begin date"
+msgstr ""
+
+msgid "Filter by end date range"
+msgstr ""
+
+msgid "end date"
msgstr ""
msgid "On"
@@ -117,6 +134,12 @@ msgstr ""
msgid "When ?"
msgstr ""
+msgid "Begin date"
+msgstr ""
+
+msgid "End date"
+msgstr ""
+
msgid "Subcontracting"
msgstr ""
diff --git a/geotrek/maintenance/locale/en/LC_MESSAGES/django.po b/geotrek/maintenance/locale/en/LC_MESSAGES/django.po
index 434260d4a0..b10bb88ad5 100644
--- a/geotrek/maintenance/locale/en/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/en/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -33,6 +33,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr ""
@@ -63,7 +71,16 @@ msgstr ""
msgid "Outdoor Site"
msgstr ""
-msgid "Year"
+msgid "Filter by begin date range"
+msgstr ""
+
+msgid "begin date"
+msgstr ""
+
+msgid "Filter by end date range"
+msgstr ""
+
+msgid "end date"
msgstr ""
msgid "On"
@@ -117,6 +134,12 @@ msgstr ""
msgid "When ?"
msgstr ""
+msgid "Begin date"
+msgstr ""
+
+msgid "End date"
+msgstr ""
+
msgid "Subcontracting"
msgstr ""
diff --git a/geotrek/maintenance/locale/es/LC_MESSAGES/django.po b/geotrek/maintenance/locale/es/LC_MESSAGES/django.po
index 434260d4a0..b10bb88ad5 100644
--- a/geotrek/maintenance/locale/es/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/es/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -33,6 +33,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr ""
@@ -63,7 +71,16 @@ msgstr ""
msgid "Outdoor Site"
msgstr ""
-msgid "Year"
+msgid "Filter by begin date range"
+msgstr ""
+
+msgid "begin date"
+msgstr ""
+
+msgid "Filter by end date range"
+msgstr ""
+
+msgid "end date"
msgstr ""
msgid "On"
@@ -117,6 +134,12 @@ msgstr ""
msgid "When ?"
msgstr ""
+msgid "Begin date"
+msgstr ""
+
+msgid "End date"
+msgstr ""
+
msgid "Subcontracting"
msgstr ""
diff --git a/geotrek/maintenance/locale/fr/LC_MESSAGES/django.po b/geotrek/maintenance/locale/fr/LC_MESSAGES/django.po
index fc56a703a6..6637f48ce8 100644
--- a/geotrek/maintenance/locale/fr/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -32,6 +32,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr "Aménagement"
@@ -62,8 +70,17 @@ msgstr "Parcours Outdoor"
msgid "Outdoor Site"
msgstr "Site Outdoor"
-msgid "Year"
-msgstr "Année"
+msgid "Filter by begin date range"
+msgstr "Filtrer par intervalle de date de début"
+
+msgid "begin date"
+msgstr "date de début"
+
+msgid "Filter by end date range"
+msgstr "Filtrer par intervalle de date de fin"
+
+msgid "end date"
+msgstr "date de fin"
msgid "On"
msgstr "Sur"
@@ -101,6 +118,9 @@ msgstr "Tronçons"
msgid "On {}"
msgstr "Sur {}"
+msgid "Begin date is after end date"
+msgstr "La date de début est après la date de fin"
+
msgid "Fundings"
msgstr "Financements"
@@ -116,6 +136,12 @@ msgstr "Date"
msgid "When ?"
msgstr "Quand ?"
+msgid "Begin date"
+msgstr "Date de début"
+
+msgid "End date"
+msgstr "Date de fin"
+
msgid "Subcontracting"
msgstr "Sous-traitance"
@@ -347,6 +373,3 @@ msgstr "Ajouter un financement"
msgid "No intervention related."
msgstr "Pas d'intervention liée."
-
-msgid "Start year is after end year"
-msgstr "L'année de début est après l'année de fin"
diff --git a/geotrek/maintenance/locale/it/LC_MESSAGES/django.po b/geotrek/maintenance/locale/it/LC_MESSAGES/django.po
index 434260d4a0..b10bb88ad5 100644
--- a/geotrek/maintenance/locale/it/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/it/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -33,6 +33,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr ""
@@ -63,7 +71,16 @@ msgstr ""
msgid "Outdoor Site"
msgstr ""
-msgid "Year"
+msgid "Filter by begin date range"
+msgstr ""
+
+msgid "begin date"
+msgstr ""
+
+msgid "Filter by end date range"
+msgstr ""
+
+msgid "end date"
msgstr ""
msgid "On"
@@ -117,6 +134,12 @@ msgstr ""
msgid "When ?"
msgstr ""
+msgid "Begin date"
+msgstr ""
+
+msgid "End date"
+msgstr ""
+
msgid "Subcontracting"
msgstr ""
diff --git a/geotrek/maintenance/locale/nl/LC_MESSAGES/django.po b/geotrek/maintenance/locale/nl/LC_MESSAGES/django.po
index 434260d4a0..b10bb88ad5 100644
--- a/geotrek/maintenance/locale/nl/LC_MESSAGES/django.po
+++ b/geotrek/maintenance/locale/nl/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-12-16 09:52+0000\n"
+"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -33,6 +33,14 @@ msgstr ""
msgid "slope"
msgstr ""
+#, python-format
+msgid "min %s"
+msgstr ""
+
+#, python-format
+msgid "max %s"
+msgstr ""
+
msgid "Infrastructure"
msgstr ""
@@ -63,7 +71,16 @@ msgstr ""
msgid "Outdoor Site"
msgstr ""
-msgid "Year"
+msgid "Filter by begin date range"
+msgstr ""
+
+msgid "begin date"
+msgstr ""
+
+msgid "Filter by end date range"
+msgstr ""
+
+msgid "end date"
msgstr ""
msgid "On"
@@ -117,6 +134,12 @@ msgstr ""
msgid "When ?"
msgstr ""
+msgid "Begin date"
+msgstr ""
+
+msgid "End date"
+msgstr ""
+
msgid "Subcontracting"
msgstr ""
diff --git a/geotrek/maintenance/managers.py b/geotrek/maintenance/managers.py
index 2132bae747..808ef8f73d 100644
--- a/geotrek/maintenance/managers.py
+++ b/geotrek/maintenance/managers.py
@@ -6,7 +6,7 @@
class InterventionManager(NoDeleteManager):
def year_choices(self):
- values = self.existing().filter(date__isnull=False).annotate(year=ExtractYear('date')) \
+ values = self.existing().filter(begin_date__isnull=False).annotate(year=ExtractYear('begin_date')) \
.order_by('-year').distinct().values_list('year', flat=True)
return [(year, year) for year in values]
diff --git a/geotrek/maintenance/migrations/0024_auto_20231206_1627.py b/geotrek/maintenance/migrations/0024_auto_20231206_1627.py
new file mode 100644
index 0000000000..c0e5ab4581
--- /dev/null
+++ b/geotrek/maintenance/migrations/0024_auto_20231206_1627.py
@@ -0,0 +1,34 @@
+# Generated by Django 3.2.21 on 2023-12-06 16:27
+
+import datetime
+from django.db import migrations, models
+
+
+def copy_date_into_begin_date(apps, schema_editor):
+ # Get maintenance models to copy date filed into begin_date
+ Intervention = apps.get_model('maintenance', 'Intervention')
+
+ for inter in Intervention.objects.all():
+ inter.begin_date = inter.date
+ inter.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('maintenance', '0023_intervention_access'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='intervention',
+ name='begin_date',
+ field=models.DateField(default=datetime.datetime.now, verbose_name='Begin date'),
+ ),
+ migrations.AddField(
+ model_name='intervention',
+ name='end_date',
+ field=models.DateField(blank=True, null=True, verbose_name='End date'),
+ ),
+ migrations.RunPython(copy_date_into_begin_date, reverse_code=migrations.RunPython.noop),
+ ]
diff --git a/geotrek/maintenance/migrations/0025_remove_intervention_date.py b/geotrek/maintenance/migrations/0025_remove_intervention_date.py
new file mode 100644
index 0000000000..70f2a24a20
--- /dev/null
+++ b/geotrek/maintenance/migrations/0025_remove_intervention_date.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.2.21 on 2023-12-12 10:39
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('maintenance', '0024_auto_20231206_1627'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='intervention',
+ name='date',
+ ),
+ ]
diff --git a/geotrek/maintenance/models.py b/geotrek/maintenance/models.py
index 8f6a799289..0a860c789e 100755
--- a/geotrek/maintenance/models.py
+++ b/geotrek/maintenance/models.py
@@ -37,7 +37,8 @@ class Intervention(ZoningPropertiesMixin, AddPropertyMixin, GeotrekMapEntityMixi
target = GenericForeignKey('target_type', 'target_id')
name = models.CharField(verbose_name=_("Name"), max_length=128, help_text=_("Brief summary"))
- date = models.DateField(default=datetime.now, verbose_name=_("Date"), help_text=_("When ?"))
+ begin_date = models.DateField(default=datetime.now, blank=False, null=False, verbose_name=_("Begin date"))
+ end_date = models.DateField(blank=True, null=True, verbose_name=_("End date"))
subcontracting = models.BooleanField(verbose_name=_("Subcontracting"), default=False)
# Technical information
@@ -260,7 +261,7 @@ def name_csv_display(self):
return self.name
def __str__(self):
- return "%s (%s)" % (self.name, self.date)
+ return "%s (%s)" % (self.name, self.begin_date)
@classmethod
def get_interventions(cls, obj):
diff --git a/geotrek/maintenance/templates/maintenance/intervention_detail.html b/geotrek/maintenance/templates/maintenance/intervention_detail.html
index 49fe4b9585..660445d5da 100644
--- a/geotrek/maintenance/templates/maintenance/intervention_detail.html
+++ b/geotrek/maintenance/templates/maintenance/intervention_detail.html
@@ -8,8 +8,14 @@
{{ intervention.name }} |
- {{ intervention|verbose:"date" }} |
- {{ intervention.date }} |
+ {{ intervention|verbose:"begin_date" }} |
+ {{ intervention.begin_date }} |
+
+
+ {{ intervention|verbose:"end_date" }} |
+ {% if intervention.end_date %}{{ intervention.end_date }}
+ {% else %}{% trans "None" %}{% endif %}
+ |
{{ intervention|verbose:"stake" }} |
diff --git a/geotrek/maintenance/templates/maintenance/intervention_form.html b/geotrek/maintenance/templates/maintenance/intervention_form.html
index 4f00bbe500..4a888ec7c4 100644
--- a/geotrek/maintenance/templates/maintenance/intervention_form.html
+++ b/geotrek/maintenance/templates/maintenance/intervention_form.html
@@ -24,12 +24,6 @@
{{ block.super }}
|