From 24b1745a5c84c3772046ed88b47a638cd41e1e70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:49:10 +0100 Subject: [PATCH 01/26] Bump easy-thumbnails from 2.8.5 to 2.9 (#4247) Bumps [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) from 2.8.5 to 2.9. - [Release notes](https://github.com/SmileyChris/easy-thumbnails/releases) - [Changelog](https://github.com/SmileyChris/easy-thumbnails/blob/master/CHANGES.rst) - [Commits](https://github.com/SmileyChris/easy-thumbnails/compare/2.8.5...2.9.0) --- updated-dependencies: - dependency-name: easy-thumbnails dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index eb3f1f939b..4149932487 100644 --- a/requirements.txt +++ b/requirements.txt @@ -187,7 +187,7 @@ drf-yasg==1.21.5 # via # django-large-image # geotrek (setup.py) -easy-thumbnails==2.8.5 +easy-thumbnails==2.9 # via # geotrek (setup.py) # mapentity From f02b1cfecd86544871b7260f740845a9ae5c42ff Mon Sep 17 00:00:00 2001 From: Justine Fricou Date: Tue, 12 Nov 2024 10:48:56 +0100 Subject: [PATCH 02/26] =?UTF-8?q?=E2=9C=A8=20[FEAT]=20Add=20parser=20for?= =?UTF-8?q?=20schema=5Frandonnee-compliant=20files=20(refs=20#4022)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 4 + geotrek/locale/de/LC_MESSAGES/django.po | 5 +- geotrek/locale/en/LC_MESSAGES/django.po | 5 +- geotrek/locale/es/LC_MESSAGES/django.po | 5 +- geotrek/locale/fr/LC_MESSAGES/django.po | 5 +- geotrek/locale/it/LC_MESSAGES/django.po | 5 +- geotrek/locale/nl/LC_MESSAGES/django.po | 5 +- .../trekking/locale/de/LC_MESSAGES/django.po | 27 +- .../trekking/locale/en/LC_MESSAGES/django.po | 27 +- .../trekking/locale/es/LC_MESSAGES/django.po | 27 +- .../trekking/locale/fr/LC_MESSAGES/django.po | 40 ++- .../trekking/locale/it/LC_MESSAGES/django.po | 27 +- .../trekking/locale/nl/LC_MESSAGES/django.po | 27 +- geotrek/trekking/parsers.py | 279 +++++++++++++++++- .../add_medias_info_after_update.geojson | 46 +++ .../add_medias_info_before_update.geojson | 43 +++ .../correct_trek.geojson | 26 ++ .../del_medias_info_after_update.geojson | 43 +++ .../del_medias_info_before_update.geojson | 53 ++++ .../incorrect_geoms.geojson | 53 ++++ .../incorrect_parking_location.geojson | 24 ++ .../license_not_created.geojson | 32 ++ .../mod_medias_info_after_update.geojson | 39 +++ .../mod_medias_info_before_update.geojson | 39 +++ .../mod_medias_url_after_update.geojson | 32 ++ .../mod_medias_url_before_update.geojson | 32 ++ .../schema_randonnee_parser/no_geom.geojson | 19 ++ .../no_parking_location.geojson | 24 ++ .../schema_randonnee_parser/no_url.geojson | 23 ++ .../schema_randonnee_parser/no_uuid.geojson | 23 ++ .../related_treks.geojson | 57 ++++ ...elated_treks_parent_does_not_exist.geojson | 24 ++ .../with_medias.geojson | 66 +++++ .../with_null_medias.geojson | 24 ++ geotrek/trekking/tests/test_parsers.py | 257 +++++++++++++++- 35 files changed, 1392 insertions(+), 75 deletions(-) create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_after_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_before_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/correct_trek.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_after_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_before_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_geoms.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_parking_location.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/license_not_created.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_after_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_before_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_after_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_before_update.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/no_geom.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/no_parking_location.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/no_uuid.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/related_treks.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/related_treks_parent_does_not_exist.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/with_medias.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/with_null_medias.geojson diff --git a/docs/changelog.rst b/docs/changelog.rst index 5c6e5e780d..631940f52d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,10 @@ CHANGELOG 2.109.3+dev (XXXX-XX-XX) ---------------------------- +**New features** + +- Add parser for schema_randonnee-compliant files (#4022) + 2.109.3 (2024-10-29) ---------------------------- diff --git a/geotrek/locale/de/LC_MESSAGES/django.po b/geotrek/locale/de/LC_MESSAGES/django.po index 2a0fbbe442..11a37277b3 100644 --- a/geotrek/locale/de/LC_MESSAGES/django.po +++ b/geotrek/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: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/locale/en/LC_MESSAGES/django.po b/geotrek/locale/en/LC_MESSAGES/django.po index 2a0fbbe442..11a37277b3 100644 --- a/geotrek/locale/en/LC_MESSAGES/django.po +++ b/geotrek/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: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/locale/es/LC_MESSAGES/django.po b/geotrek/locale/es/LC_MESSAGES/django.po index 2a0fbbe442..11a37277b3 100644 --- a/geotrek/locale/es/LC_MESSAGES/django.po +++ b/geotrek/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: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/locale/fr/LC_MESSAGES/django.po b/geotrek/locale/fr/LC_MESSAGES/django.po index f65a560fb7..035b6bec54 100644 --- a/geotrek/locale/fr/LC_MESSAGES/django.po +++ b/geotrek/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: 2020-09-23 07:10+0000\n" "Last-Translator: Emmanuelle Helly \n" "Language-Team: French 1;\n" "X-Generator: Weblate 4.1.1\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/locale/it/LC_MESSAGES/django.po b/geotrek/locale/it/LC_MESSAGES/django.po index 2a0fbbe442..11a37277b3 100644 --- a/geotrek/locale/it/LC_MESSAGES/django.po +++ b/geotrek/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: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/locale/nl/LC_MESSAGES/django.po b/geotrek/locale/nl/LC_MESSAGES/django.po index 2a0fbbe442..11a37277b3 100644 --- a/geotrek/locale/nl/LC_MESSAGES/django.po +++ b/geotrek/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: 2024-04-03 15:39+0000\n" +"POT-Creation-Date: 2024-11-08 16:28+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,9 +18,6 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Geotrek" -msgstr "" - msgid "English" msgstr "" diff --git a/geotrek/trekking/locale/de/LC_MESSAGES/django.po b/geotrek/trekking/locale/de/LC_MESSAGES/django.po index 04cd56f2bf..ed5d526102 100644 --- a/geotrek/trekking/locale/de/LC_MESSAGES/django.po +++ b/geotrek/trekking/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 15:01+0000\n" +"POT-Creation-Date: 2024-11-08 16:23+0000\n" "PO-Revision-Date: 2015-10-21 11:16+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -476,12 +476,6 @@ msgid "" "{key}" msgstr "" -#, python-brace-format -msgid "" -"One trek has not be generated for {trek_parent_instance[0].name} : could not " -"find trek with UUID {child}" -msgstr "" - msgid "" "An error occured in children generation : {getattr(e, 'message', repr(e))}" msgstr "" @@ -500,6 +494,25 @@ msgid "" "LineString feature" msgstr "" +msgid "Trek geometry is None" +msgstr "" + +#, python-brace-format +msgid "Invalid geometry for field '{src}'. Should contain coordinates" +msgstr "" + +msgid "Bad value for parking geometry: should be a Point" +msgstr "" + +#, python-brace-format +msgid "" +"License '{val}' did not exist in Geotrek-Admin and was automatically created" +msgstr "" + +#, python-brace-format +msgid "License '{val}' does not exist in Geotrek-Admin. Please add it" +msgstr "" + msgid "Attached files" msgstr "" diff --git a/geotrek/trekking/locale/en/LC_MESSAGES/django.po b/geotrek/trekking/locale/en/LC_MESSAGES/django.po index 15cd5b21f2..65b7dbe881 100644 --- a/geotrek/trekking/locale/en/LC_MESSAGES/django.po +++ b/geotrek/trekking/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: 2024-09-03 15:01+0000\n" +"POT-Creation-Date: 2024-11-08 16:23+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -461,12 +461,6 @@ msgid "" "{key}" msgstr "" -#, python-brace-format -msgid "" -"One trek has not be generated for {trek_parent_instance[0].name} : could not " -"find trek with UUID {child}" -msgstr "" - msgid "" "An error occured in children generation : {getattr(e, 'message', repr(e))}" msgstr "" @@ -485,6 +479,25 @@ msgid "" "LineString feature" msgstr "" +msgid "Trek geometry is None" +msgstr "" + +#, python-brace-format +msgid "Invalid geometry for field '{src}'. Should contain coordinates" +msgstr "" + +msgid "Bad value for parking geometry: should be a Point" +msgstr "" + +#, python-brace-format +msgid "" +"License '{val}' did not exist in Geotrek-Admin and was automatically created" +msgstr "" + +#, python-brace-format +msgid "License '{val}' does not exist in Geotrek-Admin. Please add it" +msgstr "" + msgid "Attached files" msgstr "" diff --git a/geotrek/trekking/locale/es/LC_MESSAGES/django.po b/geotrek/trekking/locale/es/LC_MESSAGES/django.po index 0da3b31982..5f1ddf2b0d 100644 --- a/geotrek/trekking/locale/es/LC_MESSAGES/django.po +++ b/geotrek/trekking/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 15:01+0000\n" +"POT-Creation-Date: 2024-11-08 16:23+0000\n" "PO-Revision-Date: 2015-10-21 11:16+0200\n" "Last-Translator: jean-etienne.castagnede@makina-corpus.com\n" "Language-Team: \n" @@ -461,12 +461,6 @@ msgid "" "{key}" msgstr "" -#, python-brace-format -msgid "" -"One trek has not be generated for {trek_parent_instance[0].name} : could not " -"find trek with UUID {child}" -msgstr "" - msgid "" "An error occured in children generation : {getattr(e, 'message', repr(e))}" msgstr "" @@ -485,6 +479,25 @@ msgid "" "LineString feature" msgstr "" +msgid "Trek geometry is None" +msgstr "" + +#, python-brace-format +msgid "Invalid geometry for field '{src}'. Should contain coordinates" +msgstr "" + +msgid "Bad value for parking geometry: should be a Point" +msgstr "" + +#, python-brace-format +msgid "" +"License '{val}' did not exist in Geotrek-Admin and was automatically created" +msgstr "" + +#, python-brace-format +msgid "License '{val}' does not exist in Geotrek-Admin. Please add it" +msgstr "" + msgid "Attached files" msgstr "" diff --git a/geotrek/trekking/locale/fr/LC_MESSAGES/django.po b/geotrek/trekking/locale/fr/LC_MESSAGES/django.po index 91a3abc8ff..d96b44ad64 100644 --- a/geotrek/trekking/locale/fr/LC_MESSAGES/django.po +++ b/geotrek/trekking/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 15:01+0000\n" +"POT-Creation-Date: 2024-11-08 16:23+0000\n" "PO-Revision-Date: 2020-09-22 15:57+0000\n" "Last-Translator: Emmanuelle Helly \n" "Language-Team: French {trek_url}' + trek.save() + for parent_id_local, child_pks in self.related_treks_mapping.items(): + parent_pk = self.id_local_to_pk_mapping.get(parent_id_local) + try: + parent_trek = Trek.objects.get(pk=parent_pk) + except Trek.DoesNotExist: + continue + order = 0 + for child_pk in child_pks: + child_trek = Trek.objects.get(pk=child_pk) + otc, _ = OrderedTrekChild.objects.get_or_create( + parent=parent_trek, + child=child_trek + ) + otc.order = order + otc.save() + order += 1 + super().end() diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_after_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_after_update.geojson new file mode 100644 index 0000000000..c1a4876d10 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_after_update.geojson @@ -0,0 +1,46 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": "Title 1.2", + "auteur": "Author 1.2", + "licence": "License 2", + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "titre": "Title 2.2", + "auteur": "Author 2.2", + "licence": "License 2", + "type_media": "image" + }, + { + "url": "https://test.fr/test3.jpg", + "titre": "Title 3.2", + "auteur": "Author 3.2", + "licence": "License 2", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_before_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_before_update.geojson new file mode 100644 index 0000000000..e6712d598a --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/add_medias_info_before_update.geojson @@ -0,0 +1,43 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": null, + "auteur": null, + "licence": null, + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "type_media": "image" + }, + { + "url": "https://test.fr/test3.jpg", + "titre": "Title 3.1", + "auteur": "Author 3.1", + "licence": "License 1", + "type_media": "pdf" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/correct_trek.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/correct_trek.geojson new file mode 100644 index 0000000000..639af58aaa --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/correct_trek.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "uuid": "be5851a9-87d4-467c-ba95-16d474480976", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "parking_geometrie": "POINT(6.449678851833768 44.733442822460994)" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_after_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_after_update.geojson new file mode 100644 index 0000000000..e20ff8cbcb --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_after_update.geojson @@ -0,0 +1,43 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": null, + "auteur": null, + "licence": null, + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "type_media": "image" + }, + { + "url": "https://test.fr/test3.jpg", + "titre": "Title 3", + "auteur": "Author 3", + "licence": "License 1", + "type_media": "pdf" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_before_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_before_update.geojson new file mode 100644 index 0000000000..5f0f3e383c --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/del_medias_info_before_update.geojson @@ -0,0 +1,53 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": "Title 1", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "titre": "Title 2", + "auteur": "Author 2", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/test3.jpg", + "titre": "Title 3", + "auteur": "Author 3", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/test4.jpg", + "titre": "Title 4", + "auteur": "Author 4", + "licence": "License 1", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_geoms.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_geoms.geojson new file mode 100644 index 0000000000..317b0af8c7 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_geoms.geojson @@ -0,0 +1,53 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "MultiLineString", + "coordinates": [ [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ], [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 2", + "arrivee": "Arrival 2", + "instructions": "Instructions 2" + }, + "geometry": { + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "3", + "producteur": "Producer 1", + "nom_itineraire": "Trek 3", + "pratique": "pédestre", + "depart": "Departure 3", + "arrivee": "Arrival 3", + "instructions": "Instructions 3" + }, + "geometry": { + "type": "LineString" + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_parking_location.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_parking_location.geojson new file mode 100644 index 0000000000..4377b0fb99 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/incorrect_parking_location.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "parking_geometrie": "LINESTRING(973032.3522426573 6409775.480393637, 973028.3125000017 6409771.999999961)" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/license_not_created.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/license_not_created.geojson new file mode 100644 index 0000000000..9ba8e4990f --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/license_not_created.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test.jpg", + "titre": "Title 1", + "auteur": "Author 1", + "licence": "New license", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_after_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_after_update.geojson new file mode 100644 index 0000000000..909cae0490 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_after_update.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": "Title 1.2", + "auteur": "Author 1.2", + "licence": "License 2", + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "titre": "Title 2.2", + "auteur": "Author 2.2", + "licence": "License 2", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_before_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_before_update.geojson new file mode 100644 index 0000000000..efeaff58be --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_info_before_update.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test1.jpg", + "titre": "Title 1.1", + "auteur": "Author 1.1", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/test2.jpg", + "titre": "Title 2.1", + "auteur": "Author 2.1", + "licence": "License 1", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_after_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_after_update.geojson new file mode 100644 index 0000000000..6f8ad8d8cb --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_after_update.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test.png", + "titre": "Title 1", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_before_update.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_before_update.geojson new file mode 100644 index 0000000000..e870d8be9f --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/mod_medias_url_before_update.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/test.jpg", + "titre": "Title 1", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/no_geom.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/no_geom.geojson new file mode 100644 index 0000000000..a00c014c03 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/no_geom.geojson @@ -0,0 +1,19 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/no_parking_location.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/no_parking_location.geojson new file mode 100644 index 0000000000..ffe206ac8d --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/no_parking_location.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "parking_geometrie": null + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson new file mode 100644 index 0000000000..8d2d4a69fc --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson @@ -0,0 +1,23 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/no_uuid.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/no_uuid.geojson new file mode 100644 index 0000000000..8d2d4a69fc --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/no_uuid.geojson @@ -0,0 +1,23 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks.geojson new file mode 100644 index 0000000000..fd6817096a --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks.geojson @@ -0,0 +1,57 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 2", + "arrivee": "Arrival 2", + "instructions": "Instructions 2", + "itineraire_parent": "1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "3", + "producteur": "Producer 1", + "nom_itineraire": "Trek 3", + "pratique": "pédestre", + "depart": "Departure 3", + "arrivee": "Arrival 3", + "instructions": "Instructions 3", + "itineraire_parent": "1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks_parent_does_not_exist.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks_parent_does_not_exist.geojson new file mode 100644 index 0000000000..1c3c87342f --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/related_treks_parent_does_not_exist.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "itineraire_parent": "2" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/with_medias.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/with_medias.geojson new file mode 100644 index 0000000000..6f922d438d --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/with_medias.geojson @@ -0,0 +1,66 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": [ + { + "url": "https://test.fr/404", + "titre": "Title 0", + "auteur": "Author 0", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/none", + "titre": "Title 1", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + }, + { + "url": null, + "titre": "Title 2", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + }, + { + "titre": "Title 3", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + }, + { + "url": "https://test.fr/test.jpg", + "titre": "Title 4", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "pdf" + }, + { + "url": "https://test.fr/test.jpg", + "titre": "Title 5", + "auteur": "Author 1", + "licence": "License 1", + "type_media": "image" + } + ] + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/with_null_medias.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/with_null_medias.geojson new file mode 100644 index 0000000000..119f36d120 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/with_null_medias.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "medias": null + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/test_parsers.py b/geotrek/trekking/tests/test_parsers.py index 99d00aaeef..051de15e89 100644 --- a/geotrek/trekking/tests/test_parsers.py +++ b/geotrek/trekking/tests/test_parsers.py @@ -18,14 +18,15 @@ from geotrek.common.utils import testdata from geotrek.common.utils.file_infos import get_encoding_file -from geotrek.common.models import Theme, FileType, Attachment, Label +from geotrek.common.models import Theme, FileType, Attachment, Label, RecordSource, License from geotrek.common.tests.mixins import GeotrekParserTestMixin +from geotrek.common.parsers import DownloadImportError from geotrek.core.tests.factories import PathFactory from geotrek.trekking.tests.factories import RouteFactory -from geotrek.trekking.models import POI, POIType, Service, Trek, DifficultyLevel, Route +from geotrek.trekking.models import POI, POIType, Service, Trek, DifficultyLevel, Route, Practice, OrderedTrekChild from geotrek.trekking.parsers import ( TrekParser, GeotrekPOIParser, GeotrekServiceParser, GeotrekTrekParser, ApidaeTrekParser, ApidaeTrekThemeParser, - ApidaePOIParser, _prepare_attachment_from_apidae_illustration, RowImportError + ApidaePOIParser, SchemaRandonneeParser, _prepare_attachment_from_apidae_illustration, RowImportError ) @@ -1784,3 +1785,253 @@ def test_it_returns_empty_strings_if_translation_not_found(self): _prepare_attachment_from_apidae_illustration(self.illustration, 'libelleEn'), expected_result ) + + +class SchemaRandonneeParserWithURL(SchemaRandonneeParser): + url = "https://test.com" + + +class SchemaRandonneeParserWithLicenseCreation(SchemaRandonneeParser): + field_options = { + 'attachments': {'create_license': True} + } + + +@skipIf(settings.TREKKING_TOPOLOGY_ENABLED, 'Test without dynamic segmentation only') +class SchemaRandonneeParserTests(TestCase): + @classmethod + def setUpTestData(cls): + FileType.objects.create(type="image") + Practice.objects.create(name="Pédestre") + RecordSource.objects.create(name="Producer 1") + License.objects.create(label="License 1") + License.objects.create(label="License 2") + + def call_import_command_with_file(self, filename, **kwargs): + filename = os.path.join(os.path.dirname(__file__), 'data', 'schema_randonnee_parser', filename) + call_command('import', 'geotrek.trekking.parsers.SchemaRandonneeParser', filename, stdout=kwargs.get('output')) + + def mocked_url(self, url=None, verb=None): + if url and 'jpg' in url: + return Mock(status_code=200, content=b"mocked content jpg", headers={'content-length': 18}) + elif url and 'png' in url: + return Mock(status_code=200, content=b"mocked content png", headers={'content-length': 18}) + elif url and 'none' in url: + return Mock(status_code=200, content=None, headers={'content-length': 0}) + elif url and '404' in url: + raise DownloadImportError('mock error message') + response = { + "type": "FeatureCollection", + "name": "sql_statement", + "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [[6.449592517966364, 44.733424655086957], [6.449539623508488, 44.733394939411369]] + } + } + ] + } + return Mock(json=lambda: response) + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_parse_from_url(self, mocked_request_or_retry): + mocked_request_or_retry.return_value = self.mocked_url() + call_command('import', 'geotrek.trekking.tests.test_parsers.SchemaRandonneeParserWithURL') + self.assertEqual(Trek.objects.count(), 1) + + def test_create_basic_trek(self): + self.call_import_command_with_file('correct_trek.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.eid, "be5851a9-87d4-467c-ba95-16d474480976") + self.assertEqual(trek.geom.srid, settings.SRID) + self.assertEqual(trek.geom.geom_type, 'LineString') + self.assertEqual(trek.geom.num_coords, 2) + self.assertEqual(trek.parking_location.srid, settings.SRID) + self.assertEqual(trek.parking_location.geom_type, 'Point') + self.assertEqual(trek.description, "Instructions 1\n\nhttps://test.com") + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_parse_attachments(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + output = StringIO() + self.call_import_command_with_file('with_medias.geojson', output=output) + self.assertEqual(Trek.objects.count(), 1) + output_value = output.getvalue() + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 1) + attachment = trek.attachments.get() + self.assertEqual(attachment.title, 'Title 5') + self.assertEqual(attachment.author, 'Author 1') + self.assertEqual(attachment.license.label, 'License 1') + self.assertIn("Failed to load attachment: mock error message", output_value) + + def test_medias_is_null(self): + self.call_import_command_with_file('with_null_medias.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 0) + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_update_of_attachments_info(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + self.call_import_command_with_file('mod_medias_info_before_update.geojson') + self.call_import_command_with_file('mod_medias_info_after_update.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 2) + attachment_1 = trek.attachments.get(title='Title 1.2') + self.assertIsNotNone(attachment_1) + self.assertEqual(attachment_1.author, 'Author 1.2') + self.assertEqual(attachment_1.license.label, 'License 2') + attachment_2 = trek.attachments.get(title='Title 2.2') + self.assertIsNotNone(attachment_2) + self.assertEqual(attachment_2.author, 'Author 2.2') + self.assertEqual(attachment_2.license.label, 'License 2') + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_add_attachment_info(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + self.call_import_command_with_file('add_medias_info_before_update.geojson') + self.call_import_command_with_file('add_medias_info_after_update.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 3) + attachment_1 = trek.attachments.get(title='Title 1.2') + self.assertIsNotNone(attachment_1) + self.assertEqual(attachment_1.author, 'Author 1.2') + self.assertEqual(attachment_1.license.label, 'License 2') + attachment_2 = trek.attachments.get(title='Title 2.2') + self.assertIsNotNone(attachment_2) + self.assertEqual(attachment_2.author, 'Author 2.2') + self.assertEqual(attachment_2.license.label, 'License 2') + attachment_3 = trek.attachments.get(title='Title 3.2') + self.assertIsNotNone(attachment_3) + self.assertEqual(attachment_3.author, 'Author 3.2') + self.assertEqual(attachment_3.license.label, 'License 2') + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_mod_attachment_url(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + self.call_import_command_with_file('mod_medias_url_before_update.geojson') + self.call_import_command_with_file('mod_medias_url_after_update.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 1) + attachment = trek.attachments.get() + with attachment.attachment_file.file.open() as f: + self.assertEqual(f.read(), b'mocked content png') + self.assertEqual(attachment.title, 'Title 1') + self.assertEqual(attachment.author, 'Author 1') + self.assertEqual(attachment.license.label, 'License 1') + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_del_attachment_info(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + self.call_import_command_with_file('del_medias_info_before_update.geojson') + self.call_import_command_with_file('del_medias_info_after_update.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 2) + attachments = trek.attachments.all() + self.assertEqual(attachments[0].title, '') + self.assertEqual(attachments[1].title, '') + self.assertEqual(attachments[0].author, '') + self.assertEqual(attachments[1].author, '') + self.assertIsNone(attachments[0].license) + self.assertIsNone(attachments[1].license) + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_license_does_not_exist(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + output = StringIO() + self.call_import_command_with_file('license_not_created.geojson', output=output) + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 1) + output_value = output.getvalue() + self.assertIn("License 'New license' does not exist in Geotrek-Admin. Please add it", output_value) + + @mock.patch('geotrek.common.parsers.Parser.request_or_retry') + def test_license_has_been_created(self, mocked_request_or_retry): + mocked_request_or_retry.side_effect = self.mocked_url + output = StringIO() + parser_name = 'geotrek.trekking.tests.test_parsers.SchemaRandonneeParserWithLicenseCreation' + filename = os.path.join(os.path.dirname(__file__), 'data', 'schema_randonnee_parser', 'license_not_created.geojson') + call_command('import', parser_name, filename, stdout=output) + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.attachments.count(), 1) + attachment = trek.attachments.get() + self.assertEqual(attachment.license.label, 'New license') + output_value = output.getvalue() + self.assertIn("License 'New license' did not exist in Geotrek-Admin and was automatically created", output_value) + + def test_create_related_treks(self): + self.call_import_command_with_file('related_treks.geojson') + self.assertEqual(Trek.objects.count(), 3) + self.assertEqual(OrderedTrekChild.objects.count(), 2) + parent_trek = Trek.objects.get(name="Trek 1") + child_trek_1 = Trek.objects.get(name="Trek 2") + child_trek_2 = Trek.objects.get(name="Trek 3") + self.assertTrue(OrderedTrekChild.objects.filter(parent=parent_trek.pk, child=child_trek_1.pk).exists()) + self.assertTrue(OrderedTrekChild.objects.filter(parent=parent_trek.pk, child=child_trek_2.pk).exists()) + + def test_related_treks_parent_does_not_exist(self): + self.call_import_command_with_file('related_treks_parent_does_not_exist.geojson') + self.assertEqual(Trek.objects.count(), 1) + self.assertEqual(OrderedTrekChild.objects.count(), 0) + + def test_trek_without_uuid(self): + self.call_import_command_with_file('no_uuid.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.eid, "1") + + def test_no_geom(self): + output = StringIO() + self.call_import_command_with_file('no_geom.geojson', output=output) + self.assertEqual(Trek.objects.count(), 0) + output_value = output.getvalue() + self.assertIn("Trek geometry is None", output_value) + + def test_incorrect_geoms(self): + output = StringIO() + self.call_import_command_with_file('incorrect_geoms.geojson', output=output) + self.assertEqual(Trek.objects.count(), 0) + output_value = output.getvalue() + self.assertIn("Invalid geometry type for field 'geometry'. Should be LineString, not MultiLineString", output_value) + self.assertIn("Invalid geometry type for field 'geometry'. Should be LineString, not None", output_value) + self.assertIn("Invalid geometry for field 'geometry'. Should contain coordinates", output_value) + + def test_no_parking_location(self): + self.call_import_command_with_file('no_parking_location.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertIsNone(trek.parking_location) + + def test_incorrect_parking_location(self): + output = StringIO() + self.call_import_command_with_file('incorrect_parking_location.geojson', output=output) + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertIsNone(trek.parking_location) + self.assertIn("Bad value for parking geometry: should be a Point", output.getvalue()) + + def test_no_url(self): + self.call_import_command_with_file('no_url.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.description, 'Instructions 1') From 022e4d6c055e17ca320c480e9ec87df3cdfea78d Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 6 Nov 2024 12:09:22 +0100 Subject: [PATCH 03/26] change doc style to sphinx-immaterial --- docker/Dockerfile | 2 +- docs/conf.py | 91 +++++++++++++++++++++++++++++++++++-------- docs/index.rst | 6 ++- docs/requirements.in | 2 +- docs/requirements.txt | 76 +++++++++++++++++++++--------------- 5 files changed, 126 insertions(+), 51 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0bf0139a0f..a2623483f0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,7 +18,7 @@ ENV TZ=UTC WORKDIR /opt/geotrek-admin RUN mkdir -p /opt/geotrek-admin/var/log /opt/geotrek-admin/var/cache -RUN useradd -M -s /bin/false geotrek && chown geotrek:geotrek -R /opt +RUN useradd -m -d /opt/geotrek-admin -s /bin/false geotrek && chown geotrek:geotrek -R /opt # Install postgis because raster2pgsl is required by manage.py loaddem RUN apt-get update -qq && apt-get install -y -qq \ diff --git a/docs/conf.py b/docs/conf.py index f5ab49151a..080c012509 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,11 +1,14 @@ -import sphinx_rtd_theme # noqa import datetime +import os + +root = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) extensions = [ 'sphinx.ext.todo', - 'sphinx_rtd_theme', + "sphinx_immaterial" ] +html_theme = 'sphinx_immaterial' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -16,29 +19,83 @@ master_doc = 'index' # General information about the project. -project = 'Geotrek' +project = 'Geotrek-admin' copyright = f'2013-{datetime.date.today().year}, Makina Corpus' -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '2.109' -# The full version, including alpha/beta/rc tags. -release = '2.109.3+dev' +release = open(os.path.join(root, "geotrek", "VERSION")).read() exclude_patterns = ['_build'] pygments_style = 'sphinx' -html_theme = 'sphinx_rtd_theme' - html_logo = "_static/logo.svg" + +# Material theme options (see theme.conf for more information) html_theme_options = { - "logo_only": True, - 'style_external_links': True, + "icon": { + "repo": "fontawesome/brands/github", + "edit": "material/file-edit-outline", + }, + "site_url": "https://geotrek.fr/", + "repo_url": "https://github.com/GeotrekCE/Geotrek-admin/", + "repo_name": "Geotrek-admin", + "edit_uri": "blob/main/docs", + "globaltoc_collapse": True, + "features": [ + "navigation.expand", + # "navigation.tabs", + # "toc.integrate", + "navigation.sections", + # "navigation.instant", + # "header.autohide", + "navigation.top", + # "navigation.tracking", + # "search.highlight", + "search.share", + "toc.follow", + "toc.sticky", + "content.tabs.link", + "announce.dismiss", + ], + "palette": [ + { + "media": "(prefers-color-scheme: light)", + "scheme": "default", + "primary": "light-green", + "accent": "light-blue", + "toggle": { + "icon": "material/lightbulb-outline", + "name": "Switch to dark mode", + }, + }, + { + "media": "(prefers-color-scheme: dark)", + "scheme": "slate", + "primary": "deep-orange", + "accent": "lime", + "toggle": { + "icon": "material/lightbulb", + "name": "Switch to light mode", + }, + }, + ], + # END: version_dropdown + "toc_title_is_page_title": True, + # BEGIN: social icons + "social": [ + { + "icon": "fontawesome/brands/github", + "link": "https://github.com/jbms/sphinx-immaterial", + "name": "Source on github.com", + }, + { + "icon": "fontawesome/brands/python", + "link": "https://pypi.org/project/sphinx-immaterial/", + }, + ], + # END: social icons } + html_favicon = "_static/favicon.png" html_static_path = ['_static'] @@ -55,7 +112,9 @@ ('index', 'geotrek', 'Geotrek Documentation', ['Makina Corpus'], 1) ] - +html_sidebars = { + "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"] +} texinfo_documents = [ ('index', 'Geotrek', 'Geotrek Documentation', 'Makina Corpus', 'Geotrek', 'One line description of project.', diff --git a/docs/index.rst b/docs/index.rst index 6ef004b713..189396a60c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,7 @@ -Welcome to Geotrek's documentation! -=================================== +Geotrek-admin's documentation +============================= + +Geotrek-admin is backend management data for Geotrek-rando, Geotrek-mobile and Geotrek-widget. .. toctree:: :caption: 💡 About diff --git a/docs/requirements.in b/docs/requirements.in index 777752c45e..8e8952a4c2 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -1,6 +1,6 @@ -c ../dev-requirements.in -sphinx-rtd-theme>=1.0.0 +sphinx_immaterial sphinx>=4.0.0 sphinx-autobuild sphinx-intl \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt index e4dc5fc7a4..0528b1ade2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,109 +2,123 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --strip-extras docs/requirements.in +# pip-compile # alabaster==0.7.13 # via sphinx -babel==2.15.0 +annotated-types==0.7.0 + # via pydantic +appdirs==1.4.4 + # via sphinx-immaterial +babel==2.16.0 # via # sphinx # sphinx-intl certifi==2024.8.30 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # requests charset-normalizer==3.3.2 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # requests click==8.1.3 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx-intl colorama==0.4.6 # via sphinx-autobuild docutils==0.20.1 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx - # sphinx-rtd-theme idna==3.7 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # requests imagesize==1.4.1 # via sphinx importlib-metadata==6.8.0 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx jinja2==3.1.4 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx -livereload==2.6.3 +livereload==2.7.0 # via sphinx-autobuild markupsafe==2.1.5 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # jinja2 + # sphinx-immaterial packaging==24.0 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx +pydantic==2.9.2 + # via + # pydantic-extra-types + # sphinx-immaterial +pydantic-core==2.23.4 + # via pydantic +pydantic-extra-types==2.10.0 + # via sphinx-immaterial pygments==2.18.0 # via sphinx pytz==2023.3.post1 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # babel requests==2.32.3 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # sphinx -six==1.16.0 - # via - # -c docs/../requirements.txt - # livereload + # sphinx-immaterial snowballstemmer==2.2.0 # via sphinx sphinx==7.1.2 # via - # -r docs/requirements.in + # -r requirements.in # sphinx-autobuild + # sphinx-immaterial # sphinx-intl - # sphinx-rtd-theme - # sphinxcontrib-jquery sphinx-autobuild==2021.3.14 - # via -r docs/requirements.in + # via -r requirements.in +sphinx-immaterial==0.11.14 + # via -r requirements.in sphinx-intl==2.2.0 - # via -r docs/requirements.in -sphinx-rtd-theme==2.0.0 - # via -r docs/requirements.in + # via -r requirements.in sphinxcontrib-applehelp==1.0.4 # via sphinx sphinxcontrib-devhelp==1.0.2 # via sphinx sphinxcontrib-htmlhelp==2.0.1 # via sphinx -sphinxcontrib-jquery==4.1 - # via sphinx-rtd-theme sphinxcontrib-jsmath==1.0.1 # via sphinx sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -tornado==6.4 +tornado==6.4.1 # via livereload +typing-extensions==4.12.2 + # via + # -c ../requirements.txt + # annotated-types + # pydantic + # pydantic-core + # pydantic-extra-types + # sphinx-immaterial urllib3==2.2.2 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # requests zipp==3.20.2 # via - # -c docs/../requirements.txt + # -c ../requirements.txt # importlib-metadata # The following packages are considered to be unsafe in a requirements file: From 4ca8977c561ee85abe3159f5921ecab44483354b Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 6 Nov 2024 14:14:09 +0100 Subject: [PATCH 04/26] harmonyze doc --- docs/conf.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 080c012509..537c746fc4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,10 +61,10 @@ { "media": "(prefers-color-scheme: light)", "scheme": "default", - "primary": "light-green", - "accent": "light-blue", + "primary": "green", + "accent": "light green", "toggle": { - "icon": "material/lightbulb-outline", + "icon": "material/weather-night", "name": "Switch to dark mode", }, }, @@ -74,26 +74,13 @@ "primary": "deep-orange", "accent": "lime", "toggle": { - "icon": "material/lightbulb", + "icon": "material/weather-sunny", "name": "Switch to light mode", }, }, ], # END: version_dropdown "toc_title_is_page_title": True, - # BEGIN: social icons - "social": [ - { - "icon": "fontawesome/brands/github", - "link": "https://github.com/jbms/sphinx-immaterial", - "name": "Source on github.com", - }, - { - "icon": "fontawesome/brands/python", - "link": "https://pypi.org/project/sphinx-immaterial/", - }, - ], - # END: social icons } html_favicon = "_static/favicon.png" From c3e050ba445513f4ff92fa444f0e6c1132d019b4 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 6 Nov 2024 14:20:14 +0100 Subject: [PATCH 05/26] harmonyze doc --- docs/conf.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 537c746fc4..ce87569f5e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -71,15 +71,24 @@ { "media": "(prefers-color-scheme: dark)", "scheme": "slate", - "primary": "deep-orange", - "accent": "lime", + "primary": "green", + "accent": "light green", "toggle": { "icon": "material/weather-sunny", "name": "Switch to light mode", }, }, ], - # END: version_dropdown + "social": [ + { + "icon": "fontawesome/brands/github", + "link": "https://github.com/GeotrekCE/Geotrek-admin" + }, + { + "icon": "fontawesome/brands/linkedin", + "link": "https://www.linkedin.com/company/geotrek-application", + }, + ], "toc_title_is_page_title": True, } @@ -91,19 +100,19 @@ htmlhelp_basename = 'Geotrekdoc' latex_documents = [ - ('index', 'Geotrek.tex', 'Geotrek Documentation', + ('index', 'Geotrek.tex', 'Geotrek-admin Documentation', 'Makina Corpus', 'manual'), ] man_pages = [ - ('index', 'geotrek', 'Geotrek Documentation', + ('index', 'geotrek', 'Geotrek-admin Documentation', ['Makina Corpus'], 1) ] html_sidebars = { "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"] } texinfo_documents = [ - ('index', 'Geotrek', 'Geotrek Documentation', - 'Makina Corpus', 'Geotrek', 'One line description of project.', + ('index', 'Geotrek', 'Geotrek-admin Documentation', + 'Makina Corpus', 'Geotrek-admin', 'One line description of project.', 'Miscellaneous'), ] From 9bc8090874b7e489a72def5d6ebbadf3916aa50d Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 6 Nov 2024 14:33:41 +0100 Subject: [PATCH 06/26] harmonyze doc --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index ce87569f5e..898591e6f4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,6 @@ project = 'Geotrek-admin' copyright = f'2013-{datetime.date.today().year}, Makina Corpus' -release = open(os.path.join(root, "geotrek", "VERSION")).read() exclude_patterns = ['_build'] From e51ca8950d7882021c487a5d181b238017c76744 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 7 Nov 2024 10:29:04 +0100 Subject: [PATCH 07/26] prevent pip 24.3 bug --- .github/workflows/dependencies.yml | 3 +- docker/Dockerfile | 2 +- docs/requirements.in | 2 -- docs/requirements.txt | 57 +++++++++--------------------- 4 files changed, 19 insertions(+), 45 deletions(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 53621e9f69..3fbe11e265 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -18,7 +18,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ['ubuntu-20.04'] + os: ['ubuntu-latest'] python-version: ['3.8'] steps: @@ -31,6 +31,7 @@ jobs: - name: Install dependencies run: | + pip3 install -U "pip<24.3" # prevent relative bug path with pip 24.3 and pip-tools pip3 install -c dev-requirements.txt pip-tools - name: Check dependency graph diff --git a/docker/Dockerfile b/docker/Dockerfile index a2623483f0..8620518639 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -70,7 +70,7 @@ RUN apt-get update -qq && apt-get install -y -qq \ USER geotrek RUN python3 -m venv /opt/venv -RUN /opt/venv/bin/pip install --no-cache-dir -U pip setuptools wheel +RUN /opt/venv/bin/pip install --no-cache-dir -U "pip<24.3" setuptools wheel COPY requirements.txt requirements.txt RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -U diff --git a/docs/requirements.in b/docs/requirements.in index 8e8952a4c2..11a729e7c7 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -1,5 +1,3 @@ --c ../dev-requirements.in - sphinx_immaterial sphinx>=4.0.0 sphinx-autobuild diff --git a/docs/requirements.txt b/docs/requirements.txt index 0528b1ade2..2630f0cf0c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile +# pip-compile --strip-extras docs/requirements.in # alabaster==0.7.13 # via sphinx @@ -15,48 +15,31 @@ babel==2.16.0 # sphinx # sphinx-intl certifi==2024.8.30 - # via - # -c ../requirements.txt - # requests + # via requests charset-normalizer==3.3.2 - # via - # -c ../requirements.txt - # requests + # via requests click==8.1.3 - # via - # -c ../requirements.txt - # sphinx-intl + # via sphinx-intl colorama==0.4.6 # via sphinx-autobuild docutils==0.20.1 - # via - # -c ../requirements.txt - # sphinx + # via sphinx idna==3.7 - # via - # -c ../requirements.txt - # requests + # via requests imagesize==1.4.1 # via sphinx importlib-metadata==6.8.0 - # via - # -c ../requirements.txt - # sphinx + # via sphinx jinja2==3.1.4 - # via - # -c ../requirements.txt - # sphinx + # via sphinx livereload==2.7.0 # via sphinx-autobuild markupsafe==2.1.5 # via - # -c ../requirements.txt # jinja2 # sphinx-immaterial packaging==24.0 - # via - # -c ../requirements.txt - # sphinx + # via sphinx pydantic==2.9.2 # via # pydantic-extra-types @@ -68,28 +51,25 @@ pydantic-extra-types==2.10.0 pygments==2.18.0 # via sphinx pytz==2023.3.post1 - # via - # -c ../requirements.txt - # babel + # via babel requests==2.32.3 # via - # -c ../requirements.txt # sphinx # sphinx-immaterial snowballstemmer==2.2.0 # via sphinx sphinx==7.1.2 # via - # -r requirements.in + # -r docs/requirements.in # sphinx-autobuild # sphinx-immaterial # sphinx-intl sphinx-autobuild==2021.3.14 - # via -r requirements.in + # via -r docs/requirements.in sphinx-immaterial==0.11.14 - # via -r requirements.in + # via -r docs/requirements.in sphinx-intl==2.2.0 - # via -r requirements.in + # via -r docs/requirements.in sphinxcontrib-applehelp==1.0.4 # via sphinx sphinxcontrib-devhelp==1.0.2 @@ -106,20 +86,15 @@ tornado==6.4.1 # via livereload typing-extensions==4.12.2 # via - # -c ../requirements.txt # annotated-types # pydantic # pydantic-core # pydantic-extra-types # sphinx-immaterial urllib3==2.2.2 - # via - # -c ../requirements.txt - # requests + # via requests zipp==3.20.2 - # via - # -c ../requirements.txt - # importlib-metadata + # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # setuptools From 24ac2d750b344c49b0c9eb650dbb0b03735012d5 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 7 Nov 2024 10:29:14 +0100 Subject: [PATCH 08/26] ignore cache dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 78d219f109..d6fad2ef77 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ docs/_build/ /dpkg/ /coverage.lcov /htmlcov/ +/.cache/ From 89db9fe54d67bc74821c79bbd96efee7637e8333 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:11:51 +0000 Subject: [PATCH 09/26] Bump idna from 3.7 to 3.10 Bumps [idna](https://github.com/kjd/idna) from 3.7 to 3.10. - [Release notes](https://github.com/kjd/idna/releases) - [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst) - [Commits](https://github.com/kjd/idna/compare/v3.7...v3.10) --- updated-dependencies: - dependency-name: idna dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4149932487..401cedf336 100644 --- a/requirements.txt +++ b/requirements.txt @@ -208,7 +208,7 @@ gunicorn==22.0.0 # via geotrek (setup.py) html5lib==1.1 # via weasyprint -idna==3.7 +idna==3.10 # via requests importlib-metadata==6.8.0 # via From e6240756184823b65874f9330b3a551921354804 Mon Sep 17 00:00:00 2001 From: Justine Fricou Date: Wed, 13 Nov 2024 10:50:12 +0100 Subject: [PATCH 10/26] Release 2.110.0 --- VERSION | 2 +- debian/changelog | 6 +++--- docs/changelog.rst | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index dc4a9cdf4d..4cc7d115d3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.109.3+dev +2.110.0 diff --git a/debian/changelog b/debian/changelog index 4874c9c01e..a5d247ba8d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -geotrek-admin (2.109.3+dev) UNRELEASED; urgency=medium +geotrek-admin (2.110.0) RELEASED; urgency=medium - * + * New package release - -- Célia Prat Mon, 04 Nov 2024 14:01:07 +0100 + -- Justine Fricou Wed, 13 Nov 2024 10:46:20 +0100 geotrek-admin (2.109.3) RELEASED; urgency=medium diff --git a/docs/changelog.rst b/docs/changelog.rst index 631940f52d..edf206c6d0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,7 +2,7 @@ CHANGELOG ========= -2.109.3+dev (XXXX-XX-XX) +2.110.0 (2024-11-13) ---------------------------- **New features** From 9c81664d05b7136c6667e8f835fc68f01f61028c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:19:59 +0000 Subject: [PATCH 11/26] Bump psycopg2 from 2.9.7 to 2.9.10 Bumps [psycopg2](https://github.com/psycopg/psycopg2) from 2.9.7 to 2.9.10. - [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS) - [Commits](https://github.com/psycopg/psycopg2/commits) --- updated-dependencies: - dependency-name: psycopg2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4149932487..265469bbb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -281,7 +281,7 @@ prompt-toolkit==3.0.47 # via click-repl psutil==5.9.8 # via large-image -psycopg2==2.9.7 +psycopg2==2.9.10 # via geotrek (setup.py) pycparser==2.22 # via cffi From 18b3657e8f32b152e979001280568f6b89fd8629 Mon Sep 17 00:00:00 2001 From: Justine Fricou Date: Wed, 13 Nov 2024 11:11:46 +0100 Subject: [PATCH 12/26] Back to development --- VERSION | 2 +- debian/changelog | 6 ++++++ docs/changelog.rst | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4cc7d115d3..15e9bd1664 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.110.0 +2.110.0+dev diff --git a/debian/changelog b/debian/changelog index a5d247ba8d..2682ce2014 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +geotrek-admin (2.110.0+dev) UNRELEASED; urgency=medium + + * + + -- Justine Fricou Wed, 13 Nov 2024 11:09:31 +0100 + geotrek-admin (2.110.0) RELEASED; urgency=medium * New package release diff --git a/docs/changelog.rst b/docs/changelog.rst index edf206c6d0..e9af4bba3a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,11 @@ CHANGELOG ========= +2.110.0+dev (XXXX-XX-XX) +---------------------------- + + + 2.110.0 (2024-11-13) ---------------------------- From 12d22cf5d2fa7d3a9246aeb8f387468e7ccb398e Mon Sep 17 00:00:00 2001 From: lpofredc Date: Wed, 13 Nov 2024 16:53:39 +0100 Subject: [PATCH 13/26] :bug: [Bug] Fix missing Dockerfile path on make build scripts (fix #4365) --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a89baf4538..6c92554257 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,10 @@ COLOR_DEBUG = \033[36m COLOR_RESET = \033[0m build: - docker build -t geotrek . --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) + docker build -t geotrek -f docker/Dockerfile . --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) -build-no-cache: - docker build -t geotrek --no-cache . +build_no_cache: + docker build -t geotrek -f docker/Dockerfile --no-cache . build_deb: docker pull $(DISTRO) From 49d9afc355788f791c1342839b513b5efc4e8934 Mon Sep 17 00:00:00 2001 From: lpofredc Date: Wed, 13 Nov 2024 17:00:50 +0100 Subject: [PATCH 14/26] :memo: [doc] Update changelog --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index e9af4bba3a..172326f082 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,9 @@ CHANGELOG 2.110.0+dev (XXXX-XX-XX) ---------------------------- +**Bug fixes** + +- Fix missing Dockerfile path on make build scripts 2.110.0 (2024-11-13) From 5ffe2cf63b493e63dcae190c3cef6cb5f9dc7c57 Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Wed, 13 Nov 2024 11:22:09 +0100 Subject: [PATCH 15/26] =?UTF-8?q?=F0=9F=93=9D=20[DOC]=20Update=20release?= =?UTF-8?q?=20and=20maintenance=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 4 ++++ docs/contribute/contributing.rst | 10 +++++----- docs/install/maintenance.rst | 4 +--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 172326f082..b49866c94b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -9,6 +9,10 @@ CHANGELOG - Fix missing Dockerfile path on make build scripts +**Documentation** + +- Update documentation for release and update obsolete example + 2.110.0 (2024-11-13) ---------------------------- diff --git a/docs/contribute/contributing.rst b/docs/contribute/contributing.rst index 47a37182bc..04a996d7b0 100644 --- a/docs/contribute/contributing.rst +++ b/docs/contribute/contributing.rst @@ -103,16 +103,16 @@ Release On master branch: -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) +* Update files *VERSION* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) * Run ``dch -r -D RELEASED``, update version in the same way and save -* Commit with message 'Release x.y.z' and push to ``master`` -* Create new release on Github, with tag X.Y.Z, click on "Generate release notes" +* Commit with message 'Release X.Y.Z' and push to ``master`` +* Create new release with name 'Geotrek-admin X.Y.Z' on Github, with tag X.Y.Z, click on "Generate release notes" * Wait for release to be published through CI -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to add ``+dev`` suffix +* Update files *VERSION* and *docs/changelog.rst* to add ``+dev`` suffix * Run ``dch -v +dev --no-force-save-on-release`` and save * Commit with message 'Back to development' and push to ```master`` -* When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.github/workflows/test.yml`` file for details) +* When creating a new release 'X.Y.Z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.github/workflows/test.yml`` file for details) Other ways to contribute ------------------------- diff --git a/docs/install/maintenance.rst b/docs/install/maintenance.rst index 66c7a72fee..2b2322b465 100644 --- a/docs/install/maintenance.rst +++ b/docs/install/maintenance.rst @@ -34,11 +34,9 @@ Application restore If you restore Geotrek-admin on a new server, you will have to install PostgreSQL and PostGIS and create a database user first. Otherwise go directly to the database creation step. -Example for Ubuntu 18: - .. code-block:: bash - sudo apt install postgresql-10 postgresql-10-postgis-2.5 + sudo apt install postgresql-14 postgresql-14-postgis-3 sudo -u postgres psql -c "CREATE USER geotrek PASSWORD 'geotrek';" From f3d07162db11164bed99460c08451ec4cfff47b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 04:10:12 +0000 Subject: [PATCH 16/26] Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1af6712e6..462145d8eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -184,7 +184,7 @@ jobs: name: coverage_${{ matrix.os }}_${{ matrix.tests-env }} path: . - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: files: ./coverage.xml env_vars: OS,ENV From db46b9542a8e9be3bd327ec6bc27d6b5be04e129 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 04:38:26 +0000 Subject: [PATCH 17/26] Bump django-compressor from 4.4 to 4.5.1 Bumps [django-compressor](https://github.com/django-compressor/django-compressor) from 4.4 to 4.5.1. - [Changelog](https://github.com/django-compressor/django-compressor/blob/develop/docs/changelog.txt) - [Commits](https://github.com/django-compressor/django-compressor/compare/4.4...4.5.1) --- updated-dependencies: - dependency-name: django-compressor dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f0a2038b56..c0877f4a7b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -131,7 +131,7 @@ django-clearcache==1.2.1 # via geotrek (setup.py) django-colorfield==0.11.0 # via geotrek (setup.py) -django-compressor==4.4 +django-compressor==4.5.1 # via mapentity django-crispy-forms==2.3 # via From f2d85cd7b7467d6cf1ccd45a489ee9a32b7b57ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 04:38:38 +0000 Subject: [PATCH 18/26] Bump zope-interface from 6.4.post2 to 7.1.1 Bumps [zope-interface](https://github.com/zopefoundation/zope.interface) from 6.4.post2 to 7.1.1. - [Changelog](https://github.com/zopefoundation/zope.interface/blob/master/CHANGES.rst) - [Commits](https://github.com/zopefoundation/zope.interface/compare/6.4.post2...7.1.1) --- updated-dependencies: - dependency-name: zope-interface dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f0a2038b56..43acdf69f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -408,7 +408,7 @@ zodbpickle==4.0 # via zodb zope-deferredimport==5.0 # via persistent -zope-interface==6.4.post2 +zope-interface==7.1.1 # via # btrees # datetime From 3853263d138753add6b97113f9023d7be2dca0c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:46:01 +0000 Subject: [PATCH 19/26] Bump cross-spawn from 7.0.3 to 7.0.5 in /cypress Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.5. - [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md) - [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.5) --- updated-dependencies: - dependency-name: cross-spawn dependency-type: indirect ... Signed-off-by: dependabot[bot] --- cypress/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/package-lock.json b/cypress/package-lock.json index 66abd3b86c..c65edd1d41 100644 --- a/cypress/package-lock.json +++ b/cypress/package-lock.json @@ -475,9 +475,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2117,9 +2117,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", From 249535625887169d0f6a7bfe9fa228d536aae4f8 Mon Sep 17 00:00:00 2001 From: Justine Fricou Date: Mon, 18 Nov 2024 11:10:39 +0100 Subject: [PATCH 20/26] =?UTF-8?q?=F0=9F=92=AB=20[IMPR]=20Remove=20overridi?= =?UTF-8?q?ng=20of=20SchemaRandonneeParser's=20filetype=5Fname=20attribute?= =?UTF-8?q?=20(#4022)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 4 ++++ geotrek/trekking/parsers.py | 1 - geotrek/trekking/tests/test_parsers.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b49866c94b..2b0fc2c2a5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,10 @@ CHANGELOG 2.110.0+dev (XXXX-XX-XX) ---------------------------- +**Improvements** + +- Remove overriding of SchemaRandonneeParser's filetype_name attribute (#4022) + **Bug fixes** - Fix missing Dockerfile path on make build scripts diff --git a/geotrek/trekking/parsers.py b/geotrek/trekking/parsers.py index f7ce974908..e3eed00c19 100644 --- a/geotrek/trekking/parsers.py +++ b/geotrek/trekking/parsers.py @@ -1327,7 +1327,6 @@ class SchemaRandonneeParser(AttachmentParserMixin, Parser): eid = 'eid' separator = ',' srid = 4326 - filetype_name = 'image' fields = { 'eid': ('uuid', 'id_local'), diff --git a/geotrek/trekking/tests/test_parsers.py b/geotrek/trekking/tests/test_parsers.py index 051de15e89..a214f588c1 100644 --- a/geotrek/trekking/tests/test_parsers.py +++ b/geotrek/trekking/tests/test_parsers.py @@ -1801,7 +1801,7 @@ class SchemaRandonneeParserWithLicenseCreation(SchemaRandonneeParser): class SchemaRandonneeParserTests(TestCase): @classmethod def setUpTestData(cls): - FileType.objects.create(type="image") + FileType.objects.create(type="Photographie") Practice.objects.create(name="Pédestre") RecordSource.objects.create(name="Producer 1") License.objects.create(label="License 1") From 7877bfd46ba4a77e9f4959d977bd7ead47a00366 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 21 Nov 2024 13:54:59 +0100 Subject: [PATCH 21/26] bump appy to 1.0.18 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 43acdf69f2..d74ff7f0fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ # amqp==5.2.0 # via kombu -appy==1.0.15 +appy==1.0.18 # via django-appypod asgiref==3.8.1 # via django From 353ca8b18943670ebda1a2b759a9e4686055c66c Mon Sep 17 00:00:00 2001 From: Justine Fricou Date: Thu, 14 Nov 2024 15:07:31 +0100 Subject: [PATCH 22/26] =?UTF-8?q?=F0=9F=90=9B=20[BUG]=20Fix=20schema=5Fran?= =?UTF-8?q?donnee=20parser=20url=20update=20issues=20(#4022)=20-=20fix=20u?= =?UTF-8?q?rl=20being=20duplicated=20in=20description=20after=20new=20impo?= =?UTF-8?q?rt=20if=20description=20is=20null=20or=20was=20not=20updated=20?= =?UTF-8?q?-=20description=20and=20url=20are=20now=20parsed=20in=20a=20fil?= =?UTF-8?q?ter=5Fdescription=20method=20rather=20than=20in=20the=20end=20m?= =?UTF-8?q?ethod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 1 + geotrek/trekking/parsers.py | 29 ++++++------- .../description_and_url.geojson | 24 +++++++++++ .../description_no_url.geojson | 24 +++++++++++ .../find_url_in_description.geojson | 40 ++++++++++++++++++ ....geojson => no_description_no_url.geojson} | 3 +- .../update_url_after.geojson | 41 +++++++++++++++++++ .../update_url_before.geojson | 41 +++++++++++++++++++ .../url_no_description.geojson | 24 +++++++++++ geotrek/trekking/tests/test_parsers.py | 30 +++++++++++++- 10 files changed, 240 insertions(+), 17 deletions(-) create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/description_and_url.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/description_no_url.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/find_url_in_description.geojson rename geotrek/trekking/tests/data/schema_randonnee_parser/{no_url.geojson => no_description_no_url.geojson} (91%) create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/update_url_after.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson create mode 100644 geotrek/trekking/tests/data/schema_randonnee_parser/url_no_description.geojson diff --git a/docs/changelog.rst b/docs/changelog.rst index 2b0fc2c2a5..3b77ed494d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,6 +12,7 @@ CHANGELOG **Bug fixes** - Fix missing Dockerfile path on make build scripts +- Fix SchemaRandonneeParser url update when description is null or was not updated (#4022) **Documentation** diff --git a/geotrek/trekking/parsers.py b/geotrek/trekking/parsers.py index e3eed00c19..92825d2101 100644 --- a/geotrek/trekking/parsers.py +++ b/geotrek/trekking/parsers.py @@ -1338,7 +1338,7 @@ class SchemaRandonneeParser(AttachmentParserMixin, Parser): 'arrival': 'arrivee', 'duration': 'duree', 'difficulty': 'difficulte', - 'description': 'instructions', + 'description': ('instructions', 'url'), 'ambiance': 'presentation', 'description_teaser': 'presentation_courte', 'advice': 'recommandations', @@ -1391,14 +1391,12 @@ class SchemaRandonneeParser(AttachmentParserMixin, Parser): 'attachments': 'medias', 'id_local': 'id_local', 'itineraire_parent': 'itineraire_parent', - 'url': 'url', } def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.related_treks_mapping = defaultdict(list) self.id_local_to_pk_mapping = {} - self.trek_urls = {} if self.url: response = self.request_or_retry(self.url) self.root = response.json() @@ -1453,6 +1451,19 @@ def filter_parking_location(self, src, val): except ValueError: self.add_warning(_("Bad value for parking geometry: should be a Point")) + def filter_description(self, src, val): + instructions, url = val + if not instructions and not url: + return None + description = "" + if instructions: + description += instructions + if instructions and url: + description += "\n\n" + if url: + description += f'{url}' + return description + def filter_attachments(self, src, val): """Handles images only""" if val is None: @@ -1548,10 +1559,6 @@ def get_or_create_license(self, license_label): self.add_warning(_("License '{val}' does not exist in Geotrek-Admin. Please add it").format(val=license_label)) return license - def save_url(self, src, val): - if val: - self.trek_urls[self.obj.pk] = val - def save_id_local(self, src, val): if val: self.id_local_to_pk_mapping[val] = self.obj.pk @@ -1562,14 +1569,8 @@ def save_itineraire_parent(self, src, val): def end(self): """ - After all treks have been created: - - concatenate the `url` field into the description - - add children + After all treks have been created, add parent/children relationships """ - for trek_pk, trek_url in self.trek_urls.items(): - trek = Trek.objects.get(pk=trek_pk) - trek.description = f'{trek.description}\n\n{trek_url}' - trek.save() for parent_id_local, child_pks in self.related_treks_mapping.items(): parent_pk = self.id_local_to_pk_mapping.get(parent_id_local) try: diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/description_and_url.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/description_and_url.geojson new file mode 100644 index 0000000000..b1c460ea3f --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/description_and_url.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "url": "https://test.com" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/description_no_url.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/description_no_url.geojson new file mode 100644 index 0000000000..f87f9b7f04 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/description_no_url.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1", + "url": null + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/find_url_in_description.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/find_url_in_description.geojson new file mode 100644 index 0000000000..bc934850df --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/find_url_in_description.geojson @@ -0,0 +1,40 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 2" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/no_description_no_url.geojson similarity index 91% rename from geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson rename to geotrek/trekking/tests/data/schema_randonnee_parser/no_description_no_url.geojson index 8d2d4a69fc..250dde234f 100644 --- a/geotrek/trekking/tests/data/schema_randonnee_parser/no_url.geojson +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/no_description_no_url.geojson @@ -12,7 +12,8 @@ "pratique": "pédestre", "depart": "Departure 1", "arrivee": "Arrival 1", - "instructions": "Instructions 1" + "instructions": null, + "url": null }, "geometry": { "type": "LineString", diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_after.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_after.geojson new file mode 100644 index 0000000000..11faa1780a --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_after.geojson @@ -0,0 +1,41 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": null + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "url": "https://test2.com", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 2" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson new file mode 100644 index 0000000000..5b232be4ff --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson @@ -0,0 +1,41 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "url": "https://test1.com", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 2" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/url_no_description.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/url_no_description.geojson new file mode 100644 index 0000000000..b4d6978506 --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/url_no_description.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": null, + "url": "https://test.com" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/test_parsers.py b/geotrek/trekking/tests/test_parsers.py index a214f588c1..be5e62b70b 100644 --- a/geotrek/trekking/tests/test_parsers.py +++ b/geotrek/trekking/tests/test_parsers.py @@ -2030,8 +2030,34 @@ def test_incorrect_parking_location(self): self.assertIsNone(trek.parking_location) self.assertIn("Bad value for parking geometry: should be a Point", output.getvalue()) - def test_no_url(self): - self.call_import_command_with_file('no_url.geojson') + def test_description_and_url(self): + self.call_import_command_with_file('description_and_url.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.description, 'Instructions 1\n\nhttps://test.com') + + def test_description_no_url(self): + self.call_import_command_with_file('description_no_url.geojson') self.assertEqual(Trek.objects.count(), 1) trek = Trek.objects.get() self.assertEqual(trek.description, 'Instructions 1') + + def test_url_no_description(self): + self.call_import_command_with_file('url_no_description.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.description, 'https://test.com') + + def test_no_description_no_url(self): + self.call_import_command_with_file('no_description_no_url.geojson') + self.assertEqual(Trek.objects.count(), 1) + trek = Trek.objects.get() + self.assertEqual(trek.description, '') + + def test_update_url(self): + self.call_import_command_with_file('update_url_before.geojson') + self.call_import_command_with_file('update_url_after.geojson') + trek1 = Trek.objects.get(eid="1") + self.assertEqual(trek1.description, "https://test.com") + trek2 = Trek.objects.get(eid="2") + self.assertEqual(trek2.description, "Instructions 2\n\nhttps://test2.com") From f5c0c7c3b1cd16e8cc95f1daf27276580e9e380c Mon Sep 17 00:00:00 2001 From: bruhnild Date: Fri, 22 Nov 2024 18:07:10 +0100 Subject: [PATCH 23/26] Add note about nginx configuration file --- docs/install/configuration.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/install/configuration.rst b/docs/install/configuration.rst index 47631332a6..a6b9394e63 100644 --- a/docs/install/configuration.rst +++ b/docs/install/configuration.rst @@ -71,11 +71,13 @@ After this, edit ``nginx.conf.in`` to add your certificate. If you generate it with letsencrypt : You can use certbot to add the certificate in your configuration. -But you will have to move the configuration automatically added into ``nginx.conf``, to the file ``nginx.conf.in`` -in ``/opt/geotrek-admin/var/conf/`` directory +But you will have to move the configuration automatically added into ``nginx.conf``, to the file ``nginx.conf.in`` in ``/opt/geotrek-admin/var/conf/`` directory. -You have to move the configuration to the file ``nginx.conf.in`` because ``nginx.conf`` is automatically -changed during command ``dpkg-reconfigure geotrek-admin``. +You have to move the configuration to the file ``nginx.conf.in`` because ``nginx.conf`` is automatically changed during command ``dpkg-reconfigure geotrek-admin``. + +.. note:: + + You need to replace the ``$`` from Certbot with ``${DOLLAR}`` everywhere in the ``nginx.conf.in`` file, then run the command ``sudo dpkg-reconfigure geotrek-admin`` to regenerate the file. Mandatory settings From cf42ec63eddcdbba545dd5ff46e7ac25450675aa Mon Sep 17 00:00:00 2001 From: bruhnild Date: Fri, 22 Nov 2024 18:10:51 +0100 Subject: [PATCH 24/26] Updatechangelog --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2b0fc2c2a5..bfb3e24b19 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,7 @@ CHANGELOG **Documentation** - Update documentation for release and update obsolete example +- Add note about certbot ssl configuration in nginx 2.110.0 (2024-11-13) From 2be460cf1fd9d688b9e5801b1cdb88843a768f2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 04:39:15 +0000 Subject: [PATCH 25/26] Bump gunicorn from 22.0.0 to 23.0.0 Bumps [gunicorn](https://github.com/benoitc/gunicorn) from 22.0.0 to 23.0.0. - [Release notes](https://github.com/benoitc/gunicorn/releases) - [Commits](https://github.com/benoitc/gunicorn/compare/22.0.0...23.0.0) --- updated-dependencies: - dependency-name: gunicorn dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d74ff7f0fa..3bcc03ec3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -204,7 +204,7 @@ geojson==3.1.0 # tif2geojson gpxpy==1.6.2 # via mapentity -gunicorn==22.0.0 +gunicorn==23.0.0 # via geotrek (setup.py) html5lib==1.1 # via weasyprint From fef19d4a2931d02e5c89bd4be58f744db17371ff Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Mon, 25 Nov 2024 11:13:03 +0100 Subject: [PATCH 26/26] fix deps --- requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c0877f4a7b..74cc763d99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -105,6 +105,7 @@ django==4.2.16 # django-appypod # django-celery-results # django-clearcache + # django-compressor # django-crispy-forms # django-embed-video # django-filter @@ -309,7 +310,7 @@ pytz==2023.3.post1 # drf-yasg pyvips==2.2.3 # via large-image-source-vips -rcssmin==1.1.1 +rcssmin==1.1.2 # via django-compressor redis==5.1.1 # via geotrek (setup.py) @@ -323,7 +324,7 @@ requests==2.32.3 # django-embed-video # landez # mapentity -rjsmin==1.2.1 +rjsmin==1.2.2 # via django-compressor ruamel-yaml==0.18.6 # via drf-yasg