From 5771fafda10032167b7659c3f8d56d18f7aec4a0 Mon Sep 17 00:00:00 2001 From: LePetitTim Date: Mon, 15 May 2023 23:02:11 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8=20Add=20watershed=20types=20porta?= =?UTF-8?q?ls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 1 + georiviere/portal/serializers/map.py | 4 ++-- .../portal/tests/test_views/test_zoning.py | 16 ++++++++++------ georiviere/portal/urls.py | 2 +- georiviere/portal/views/zoning.py | 4 +++- .../migrations/0002_watershedtype_portals.py | 19 +++++++++++++++++++ georiviere/watershed/models.py | 3 +++ 7 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 georiviere/watershed/migrations/0002_watershedtype_portals.py diff --git a/docs/changelog.rst b/docs/changelog.rst index 9ee0bf21..985f5412 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ CHANGELOG * Add linked objects on contributions * Add portal SEO informations * Add min zoom, max zoom extent portal +* Add public portals on watershed types allowing to publish them 1.1.0 (2023-13-06) diff --git a/georiviere/portal/serializers/map.py b/georiviere/portal/serializers/map.py index 20e4b42c..8caeb735 100644 --- a/georiviere/portal/serializers/map.py +++ b/georiviere/portal/serializers/map.py @@ -44,7 +44,7 @@ def get_geojson_url(self, obj): layer_type = obj.layer_type.split('-') # TODO: Make lang dynamic reverse_kwargs = {'lang': 'fr', 'format': 'geojson'} - if layer_type[0] in ['pois', 'streams', 'contributions']: + if layer_type[0] in ['waterhseds', 'pois', 'streams', 'contributions']: reverse_kwargs['portal_pk'] = obj.portal.pk if len(layer_type) == 2: # If the layer type is poi, it's separated by category. @@ -59,7 +59,7 @@ def get_url(self, obj): return None # TODO: Make lang dynamic reverse_kwargs = {'lang': 'fr'} - if layer_type[0] in ['pois', 'streams', 'contributions']: + if layer_type[0] in ['waterhseds', 'pois', 'streams', 'contributions']: reverse_kwargs['portal_pk'] = obj.portal.pk return reverse(f'api_portal:{layer_type[0]}-list', kwargs=reverse_kwargs) diff --git a/georiviere/portal/tests/test_views/test_zoning.py b/georiviere/portal/tests/test_views/test_zoning.py index fb7f01b4..ce3ee339 100644 --- a/georiviere/portal/tests/test_views/test_zoning.py +++ b/georiviere/portal/tests/test_views/test_zoning.py @@ -1,7 +1,8 @@ from django.test import TestCase from django.urls import reverse -from georiviere.watershed.tests.factories import WatershedFactory +from georiviere.portal.tests.factories import PortalFactory +from georiviere.watershed.tests.factories import WatershedFactory, WatershedTypeFactory from geotrek.zoning.tests.factories import CityFactory, DistrictFactory @@ -9,11 +10,14 @@ class WatershedViewTest(TestCase): @classmethod def setUpTestData(cls): - cls.watershed = WatershedFactory.create() + cls.portal = PortalFactory.create() + watershed_type = WatershedTypeFactory.create() + watershed_type.portals.add(cls.portal) + cls.watershed = WatershedFactory.create(watershed_type=watershed_type) def test_watershed_detail_geojson_structure(self): url = reverse('api_portal:watersheds-detail', - kwargs={'pk': self.watershed.pk, 'lang': 'fr', 'format': 'geojson'}) + kwargs={'portal_pk': self.portal.pk, 'pk': self.watershed.pk, 'lang': 'fr', 'format': 'geojson'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) @@ -21,7 +25,7 @@ def test_watershed_detail_geojson_structure(self): def test_watershed_list_geojson_structure(self): url = reverse('api_portal:watersheds-list', - kwargs={'lang': 'fr', 'format': 'geojson'}) + kwargs={'portal_pk': self.portal.pk, 'lang': 'fr', 'format': 'geojson'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) @@ -29,7 +33,7 @@ def test_watershed_list_geojson_structure(self): def test_watershed_detail_json(self): url = reverse('api_portal:watersheds-detail', - kwargs={'pk': self.watershed.pk, 'lang': 'fr', 'format': 'json'}) + kwargs={'portal_pk': self.portal.pk, 'pk': self.watershed.pk, 'lang': 'fr', 'format': 'json'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) @@ -37,7 +41,7 @@ def test_watershed_detail_json(self): def test_watershed_list_json(self): url = reverse('api_portal:watersheds-list', - kwargs={'lang': 'fr', 'format': 'json'}) + kwargs={'portal_pk': self.portal.pk, 'lang': 'fr', 'format': 'json'}) response = self.client.get(url) self.assertEqual(response.status_code, 200) diff --git a/georiviere/portal/urls.py b/georiviere/portal/urls.py index 691b5366..9cbc9b73 100644 --- a/georiviere/portal/urls.py +++ b/georiviere/portal/urls.py @@ -25,11 +25,11 @@ router.register(r'(?P[a-z]{2})/(?P\d+)/flatpages', FlatPageViewSet, basename='flatpages') router.register(r'(?P[a-z]{2})/(?P\d+)/contributions', ContributionViewSet, basename='contributions') +router.register(r'(?P[a-z]{2})/(?P\d+)/watersheds', WatershedViewSet, basename='watersheds') router.register(r'(?P[a-z]{2})/portal', PortalViewSet, basename='portal') router.register(r'(?P[a-z]{2})/cities', CityViewSet, basename='cities') router.register(r'(?P[a-z]{2})/districts', DistrictViewSet, basename='districts') -router.register(r'(?P[a-z]{2})/watersheds', WatershedViewSet, basename='watersheds') router.register(r'(?P[a-z]{2})/sensitivities', SensitivityViewSet, basename='sensitivities') app_name = 'api_portal' diff --git a/georiviere/portal/views/zoning.py b/georiviere/portal/views/zoning.py index d98fd571..88e47a7d 100644 --- a/georiviere/portal/views/zoning.py +++ b/georiviere/portal/views/zoning.py @@ -56,7 +56,9 @@ class WatershedViewSet(viewsets.ReadOnlyModelViewSet): renderer_classes = [CamelCaseJSONRenderer, GeoJSONRenderer, ] def get_queryset(self): - return Watershed.objects.annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)) + portal_pk = self.kwargs['portal_pk'] + queryset = Watershed.objects.select_related('watershed_type').filter(watershed_type__portals__id=portal_pk) + return queryset.annotate(geom_transformed=Transform(F('geom'), settings.API_SRID)) def get_serializer_class(self): """ Use specific Serializer for GeoJSON """ diff --git a/georiviere/watershed/migrations/0002_watershedtype_portals.py b/georiviere/watershed/migrations/0002_watershedtype_portals.py new file mode 100644 index 00000000..5954083c --- /dev/null +++ b/georiviere/watershed/migrations/0002_watershedtype_portals.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.14 on 2023-05-15 21:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('portal', '0003_auto_20230515_2019'), + ('watershed', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='watershedtype', + name='portals', + field=models.ManyToManyField(blank=True, related_name='watersheds', to='portal.Portal', verbose_name='Published portals'), + ), + ] diff --git a/georiviere/watershed/models.py b/georiviere/watershed/models.py index 65dbfe81..d238af3a 100644 --- a/georiviere/watershed/models.py +++ b/georiviere/watershed/models.py @@ -9,6 +9,9 @@ class WatershedType(models.Model): name = models.CharField(max_length=200, verbose_name=_("Name")) color = ColorField(verbose_name=_("Color"), default='#444444', help_text=_("Color shown on map")) + portals = models.ManyToManyField('portal.Portal', + blank=True, related_name='watersheds', + verbose_name=_("Published portals")) class Meta: verbose_name = _("Watershed type") From 234f0d18c7045073ae39315a67019a0eac26c746 Mon Sep 17 00:00:00 2001 From: LePetitTim Date: Wed, 31 May 2023 13:23:36 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=90=9B=20Fix=20serializer=20portal=20?= =?UTF-8?q?map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- georiviere/portal/serializers/map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/georiviere/portal/serializers/map.py b/georiviere/portal/serializers/map.py index 8caeb735..c1de1a4a 100644 --- a/georiviere/portal/serializers/map.py +++ b/georiviere/portal/serializers/map.py @@ -44,7 +44,7 @@ def get_geojson_url(self, obj): layer_type = obj.layer_type.split('-') # TODO: Make lang dynamic reverse_kwargs = {'lang': 'fr', 'format': 'geojson'} - if layer_type[0] in ['waterhseds', 'pois', 'streams', 'contributions']: + if layer_type[0] in ['watersheds', 'pois', 'streams', 'contributions']: reverse_kwargs['portal_pk'] = obj.portal.pk if len(layer_type) == 2: # If the layer type is poi, it's separated by category. @@ -59,7 +59,7 @@ def get_url(self, obj): return None # TODO: Make lang dynamic reverse_kwargs = {'lang': 'fr'} - if layer_type[0] in ['waterhseds', 'pois', 'streams', 'contributions']: + if layer_type[0] in ['watersheds', 'pois', 'streams', 'contributions']: reverse_kwargs['portal_pk'] = obj.portal.pk return reverse(f'api_portal:{layer_type[0]}-list', kwargs=reverse_kwargs) From 5e172451976304bf4179cc2626786576f33ed1be Mon Sep 17 00:00:00 2001 From: LePetitTim Date: Mon, 31 Jul 2023 15:02:33 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=93=9D=20Add=20documentation=20transl?= =?UTF-8?q?ation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/install/advanced_settings.rst | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/install/advanced_settings.rst b/docs/install/advanced_settings.rst index 59751d33..a456ca73 100644 --- a/docs/install/advanced_settings.rst +++ b/docs/install/advanced_settings.rst @@ -29,3 +29,55 @@ Some settings come from Geotrek-admin or Mapentity, on which Georiviere is based * `Map layers colors and style `_ See `Geotrek-admin documentation `_ for further information. + + +Override translations +--------------------- + +You can override default translation files available in each module + +Don't edit these default files, use them to find which words you want to override. + +Create the custom translations destination folder: + +Create a ``django.po`` file in ``var/conf/extra_locale`` directory. +You can do one folder and one ``django.po`` file for each language +(example ``var/conf/extra_locale/fr/LC_MESSAGES/django.po`` for French translation overriding) + +Override the translations that you want in these files. + +Example of content for the French translation overriding: + +:: + + # MY FRENCH CUSTOM TRANSLATION + # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER + # This file is distributed under the same license as the PACKAGE package. + # FIRST AUTHOR , YEAR. + # + msgid "" + msgstr "" + "Report-Msgid-Bugs-To: \n" + "POT-Creation-Date: 2018-11-15 15:32+0200\n" + "PO-Revision-Date: 2018-11-15 15:33+0100\n" + "Last-Translator: \n" + "Language-Team: LANGUAGE \n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "Project-Id-Verésion: PACKAGE VERSION\n" + "Plural-Forms: nplurals=2; plural=(n > 1);\n" + "Project-Id-Version: \n" + "X-Generator: Poedit 1.5.4\n" + + msgid "City" + msgstr "Région" + + msgid "District" + msgstr "Pays" + +Apply changes (French translation in this example) : + +:: + + sudo docker-compose run --rm web update.sh From 840086a0525d8659543e2a9ee09b10d7a8cc0f74 Mon Sep 17 00:00:00 2001 From: LePetitTim Date: Mon, 31 Jul 2023 15:12:53 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=8C=90=20Add=20in=20meters=20contribu?= =?UTF-8?q?tions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../locale/en/LC_MESSAGES/django.po | 39 +++++++++++--- .../locale/fr/LC_MESSAGES/django.po | 52 ++++++++++++++----- .../migrations/0008_auto_20230731_1304.py | 33 ++++++++++++ georiviere/contribution/models.py | 10 ++-- 4 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 georiviere/contribution/migrations/0008_auto_20230731_1304.py diff --git a/georiviere/contribution/locale/en/LC_MESSAGES/django.po b/georiviere/contribution/locale/en/LC_MESSAGES/django.po index 154e2469..7defeb16 100644 --- a/georiviere/contribution/locale/en/LC_MESSAGES/django.po +++ b/georiviere/contribution/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: 2023-07-25 12:41+0000\n" +"POT-Creation-Date: 2023-07-31 13:06+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,6 +42,9 @@ msgstr "" msgid "Type" msgstr "" +msgid "Linked object" +msgstr "" + msgid "Label" msgstr "" @@ -75,6 +78,12 @@ msgstr "" msgid "Description of the contribution" msgstr "" +msgid "Published" +msgstr "" + +msgid "Make it visible on portal" +msgstr "" + msgid "Portal" msgstr "" @@ -96,7 +105,8 @@ msgstr "" msgid "No category" msgstr "" -msgid "Published" +#, python-brace-format +msgid "Feedback from {email}" msgstr "" msgid "Contribution potential damage type" @@ -150,16 +160,16 @@ msgstr "" msgid "Landing type" msgstr "" -msgid "Excessive cutting length in meters" +msgid "Excessive cutting length (in meters)" msgstr "" -msgid "Length bank erosion" +msgid "Length bank erosion (in meters)" msgstr "" msgid "Distance between the foot of the bank and the foot of the erosion." msgstr "" -msgid "Bank height" +msgid "Bank height (in meters)" msgstr "" msgid "" @@ -194,10 +204,10 @@ msgstr "" msgid "Fish species" msgstr "" -msgid "Home area" +msgid "Home area (in square meters)" msgstr "" -msgid "Home area in meters" +msgid "Home area in square meters" msgstr "" msgid "Number heritage species" @@ -310,3 +320,18 @@ msgstr "" msgid "None" msgstr "" + +#, python-format +msgid "%(email)s has sent a contribution." +msgstr "" + +#, python-format +msgid "Severity : %(severity)s" +msgstr "" + +#, python-format +msgid "" +"\n" +"Lat : %(lat)s / Lon : %(lng)s\n" +"http://www.openstreetmap.org/?mlat=%(lat)s&mlon=%(lng)s\n" +msgstr "" diff --git a/georiviere/contribution/locale/fr/LC_MESSAGES/django.po b/georiviere/contribution/locale/fr/LC_MESSAGES/django.po index 6115749a..f1a58e12 100644 --- a/georiviere/contribution/locale/fr/LC_MESSAGES/django.po +++ b/georiviere/contribution/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-25 12:41+0000\n" +"POT-Creation-Date: 2023-07-31 13:06+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,6 +42,9 @@ msgstr "Catégorie" msgid "Type" msgstr "Type" +msgid "Linked object" +msgstr "Objet lié" + msgid "Label" msgstr "Label" @@ -75,6 +78,12 @@ msgstr "Description" msgid "Description of the contribution" msgstr "Description de la gravité" +msgid "Published" +msgstr "Publié" + +msgid "Make it visible on portal" +msgstr "Rendre visible sur le portail" + msgid "Portal" msgstr "Portail" @@ -96,8 +105,9 @@ msgstr "Nom" msgid "No category" msgstr "Aucune catégorie" -msgid "Published" -msgstr "Publié" +#, python-brace-format +msgid "Feedback from {email}" +msgstr "Retour utilisateur depuis {email}" msgid "Contribution potential damage type" msgstr "Type de contibution dégats potentiels" @@ -150,17 +160,17 @@ msgstr "Piétinement par le bétail (impactant)" msgid "Landing type" msgstr "Type d'atterrissement" -msgid "Excessive cutting length in meters" -msgstr "Longueur coupe abusive en mètres" +msgid "Excessive cutting length (in meters)" +msgstr "Longueur coupe abusive (en mètres)" -msgid "Length bank erosion" -msgstr "Longueur de l'érosion de la berge" +msgid "Length bank erosion (in meters)" +msgstr "Longueur de l'érosion de la berge (en mètres)" msgid "Distance between the foot of the bank and the foot of the erosion." msgstr "Distance entre le pied de berge et le pied de l'érosion" -msgid "Bank height" -msgstr "Hauteur de berge" +msgid "Bank height (in meters)" +msgstr "Hauteur de berge (en mètres)" msgid "" "Bank height (measured between the foot of the bank and the top of the bank) " @@ -194,11 +204,11 @@ msgstr "Observations patrimoniale" msgid "Fish species" msgstr "Espèce piscicole" -msgid "Home area" -msgstr "Surface du foyer" +msgid "Home area (in square meters)" +msgstr "Surface du foyer (en mètres carrés)" -msgid "Home area in meters" -msgstr "Surface du foyer en mètres" +msgid "Home area in square meters" +msgstr "Surface du foyer en mètres carrés" msgid "Number heritage species" msgstr "Nombre d'individus patrimoniale" @@ -310,3 +320,19 @@ msgstr "Connaissance" msgid "None" msgstr "Aucun" + +#, python-format +msgid "%(email)s has sent a contribution." +msgstr "%(email)s has sent a contribution." + +#, python-format +#| msgid "Severity types" +msgid "Severity : %(severity)s" +msgstr "Sévérité : %(severity)s" + +#, python-format +msgid "" +"\n" +"Lat : %(lat)s / Lon : %(lng)s\n" +"http://www.openstreetmap.org/?mlat=%(lat)s&mlon=%(lng)s\n" +msgstr "" diff --git a/georiviere/contribution/migrations/0008_auto_20230731_1304.py b/georiviere/contribution/migrations/0008_auto_20230731_1304.py new file mode 100644 index 00000000..1ee67b3b --- /dev/null +++ b/georiviere/contribution/migrations/0008_auto_20230731_1304.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1.14 on 2023-07-31 13:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('contribution', '0007_auto_20230725_1541'), + ] + + operations = [ + migrations.AlterField( + model_name='contributionfaunaflora', + name='home_area', + field=models.FloatField(blank=True, default=0.0, help_text='Home area in square meters', null=True, verbose_name='Home area (in square meters)'), + ), + migrations.AlterField( + model_name='contributionpotentialdamage', + name='bank_height', + field=models.FloatField(blank=True, default=0.0, help_text='Bank height (measured between the foot of the bank and the top of the bank) in meters', null=True, verbose_name='Bank height (in meters)'), + ), + migrations.AlterField( + model_name='contributionpotentialdamage', + name='excessive_cutting_length', + field=models.FloatField(blank=True, default=0.0, null=True, verbose_name='Excessive cutting length (in meters)'), + ), + migrations.AlterField( + model_name='contributionpotentialdamage', + name='length_bank_erosion', + field=models.FloatField(blank=True, default=0.0, help_text='Distance between the foot of the bank and the foot of the erosion.', null=True, verbose_name='Length bank erosion (in meters)'), + ), + ] diff --git a/georiviere/contribution/models.py b/georiviere/contribution/models.py index 06dde03f..57812bde 100644 --- a/georiviere/contribution/models.py +++ b/georiviere/contribution/models.py @@ -277,14 +277,14 @@ class TypeChoice(models.IntegerChoices): landing_type = models.ForeignKey(LandingType, on_delete=models.PROTECT, null=True, verbose_name=_("Landing type")) excessive_cutting_length = models.FloatField(default=0.0, null=True, blank=True, - verbose_name=_("Excessive cutting length in meters")) + verbose_name=_("Excessive cutting length (in meters)")) jam_type = models.ForeignKey(JamType, on_delete=models.PROTECT, null=True) length_bank_erosion = models.FloatField(default=0.0, null=True, blank=True, - verbose_name=_("Length bank erosion"), + verbose_name=_("Length bank erosion (in meters)"), help_text=_('Distance between the foot of the bank and the foot of ' 'the erosion.')) bank_height = models.FloatField(default=0.0, null=True, blank=True, - verbose_name=_("Bank height"), + verbose_name=_("Bank height (in meters)"), help_text=_('Bank height (measured between the foot of the bank and the top ' 'of the bank) in meters')) disease_type = models.ForeignKey(DiseaseType, on_delete=models.PROTECT, null=True) @@ -362,8 +362,8 @@ class TypeChoice(models.IntegerChoices): verbose_name=_("Type"), ) home_area = models.FloatField(default=0.0, null=True, blank=True, - verbose_name=_("Home area"), - help_text=_('Home area in meters')) + verbose_name=_("Home area (in square meters)"), + help_text=_('Home area in square meters')) invasive_species = models.ForeignKey(InvasiveSpecies, on_delete=models.PROTECT, null=True) number_heritage_species = models.IntegerField(default=0, null=True, blank=True, verbose_name=_("Number heritage species")) From 62bbaa46da3dfc7c2a1828d0f8b65e679d0b6888 Mon Sep 17 00:00:00 2001 From: LePetitTim Date: Mon, 31 Jul 2023 17:15:15 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=A8=20Update=20json=20schema=20contri?= =?UTF-8?q?bution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- georiviere/contribution/schema.py | 38 +++++++++---------- .../data/json_schema_base_contribution.json | 36 +++++++++--------- ...ma_base_contribution_without_subtypes.json | 16 ++++---- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/georiviere/contribution/schema.py b/georiviere/contribution/schema.py index cfbce0f0..98f5f60f 100644 --- a/georiviere/contribution/schema.py +++ b/georiviere/contribution/schema.py @@ -69,7 +69,7 @@ def get_landing(choices, meta): 'landing_type': { 'type': "string", - 'title': meta.get_field('landing_type').verbose_name.title(), + 'title': str(meta.get_field('landing_type').verbose_name.capitalize()), 'enum': list(LandingType.objects.values_list('label', flat=True)) } }, @@ -90,7 +90,7 @@ def get_excessive_cutting_riparian_forest(choices, meta): { 'type': "number", 'title': str(meta.get_field( - 'excessive_cutting_length').verbose_name.title()), + 'excessive_cutting_length').verbose_name.capitalize()), } }, } @@ -111,7 +111,7 @@ def get_disruptive_jam(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'jam_type').verbose_name.title()), + 'jam_type').verbose_name.capitalize()), } }, } @@ -132,7 +132,7 @@ def get_bank_erosion(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'length_bank_erosion').verbose_name.title()), + 'length_bank_erosion').verbose_name.capitalize()), } }, } @@ -153,7 +153,7 @@ def get_river_bed_incision(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'bank_height').verbose_name.title()), + 'bank_height').verbose_name.capitalize()), } }, } @@ -174,7 +174,7 @@ def get_fish_diseases(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'disease_type').verbose_name.title()), + 'disease_type').verbose_name.capitalize()), 'enum': list(DiseaseType.objects.values_list('label', flat=True)) } }, @@ -189,14 +189,14 @@ def get_fish_mortality(choices, meta): { 'type': "number", 'title': str(meta.get_field( - 'number_death').verbose_name.title()) + 'number_death').verbose_name.capitalize()) }, } if DeadSpecies.objects.exists(): fish_mortality_property['dead_species'] = { 'type': "string", 'title': str(meta.get_field( - 'dead_species').verbose_name.title()), + 'dead_species').verbose_name.capitalize()), 'enum': list(DeadSpecies.objects.values_list('label', flat=True)) } fish_mortality = { @@ -258,14 +258,14 @@ def get_invasive_species(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'home_area').verbose_name.title()) + 'home_area').verbose_name.capitalize()) }, } if InvasiveSpecies.objects.exists(): invasive_species_property['invasive_species'] = { 'type': "string", 'title': str(meta.get_field( - 'invasive_species').verbose_name.title()), + 'invasive_species').verbose_name.capitalize()), 'enum': list(InvasiveSpecies.objects.values_list('label', flat=True)) } invasive_species = { @@ -287,21 +287,21 @@ def get_heritage_species(choices, meta): { 'type': "number", 'title': str(meta.get_field( - 'number_heritage_species').verbose_name.title()) + 'number_heritage_species').verbose_name.capitalize()) }, } if HeritageSpecies.objects.exists(): heritage_species_property['heritage_species'] = { 'type': "string", 'title': str(meta.get_field( - 'heritage_species').verbose_name.title()), + 'heritage_species').verbose_name.capitalize()), 'enum': list(HeritageSpecies.objects.values_list('label', flat=True)) } if HeritageObservation.objects.exists(): heritage_species_property['heritage_observation'] = { 'type': "string", 'title': str(meta.get_field( - 'heritage_observation').verbose_name.title()), + 'heritage_observation').verbose_name.capitalize()), 'enum': list(HeritageObservation.objects.values_list('label', flat=True)) } heritage_species = { @@ -323,14 +323,14 @@ def get_fish_species(choices, meta): { 'type': "number", 'title': str(meta.get_field( - 'number_fish_species').verbose_name.title()) + 'number_fish_species').verbose_name.capitalize()) }, } if FishSpecies.objects.exists(): fish_species_property['fish_species'] = { 'type': "string", 'title': str(meta.get_field( - 'fish_species').verbose_name.title()), + 'fish_species').verbose_name.capitalize()), 'enum': list(FishSpecies.objects.values_list('label', flat=True)) } fish_species = { @@ -388,7 +388,7 @@ def get_overflow(choices, meta): { 'type': "string", 'title': str(meta.get_field( - 'landmark').verbose_name.title()) + 'landmark').verbose_name.capitalize()) }, } } @@ -408,7 +408,7 @@ def get_quantity_condition(): 'properties': { 'type': { 'type': "string", - 'title': str(meta_quantity.get_field('type').verbose_name.title()), + 'title': str(meta_quantity.get_field('type').verbose_name.capitalize()), 'enum': list(quantity_choices.labels) } }, @@ -429,14 +429,14 @@ def get_pollution(choices, meta): pollution_property['nature_pollution'] = { 'type': "string", 'title': str(meta.get_field( - 'nature_pollution').verbose_name.title()), + 'nature_pollution').verbose_name.capitalize()), 'enum': list(NaturePollution.objects.values_list('label', flat=True)) } if TypePollution.objects.exists(): pollution_property['type_pollution'] = { 'type': "string", 'title': str(meta.get_field( - 'type_pollution').verbose_name.title()), + 'type_pollution').verbose_name.capitalize()), 'enum': list(TypePollution.objects.values_list('label', flat=True)) } pollution = { diff --git a/georiviere/portal/tests/data/json_schema_base_contribution.json b/georiviere/portal/tests/data/json_schema_base_contribution.json index 1dea0487..8a9d8422 100644 --- a/georiviere/portal/tests/data/json_schema_base_contribution.json +++ b/georiviere/portal/tests/data/json_schema_base_contribution.json @@ -95,7 +95,7 @@ "properties": { "excessive_cutting_length": { "type": "number", - "title": "Excessive Cutting Length In Meters" + "title": "Excessive cutting length (in meters)" } } } @@ -112,7 +112,7 @@ "properties": { "length_bank_erosion": { "type": "string", - "title": "Length Bank Erosion" + "title": "Length bank erosion (in meters)" } } } @@ -129,7 +129,7 @@ "properties": { "bank_height": { "type": "string", - "title": "Bank Height" + "title": "Bank height (in meters)" } } } @@ -146,11 +146,11 @@ "properties": { "number_death": { "type": "number", - "title": "Number Death" + "title": "Number death" }, "dead_species": { "type": "string", - "title": "Dead Species", + "title": "Dead species", "enum": [ "Dead species 0", "Dead species 1", @@ -172,7 +172,7 @@ "properties": { "landing_type": { "type": "string", - "title": "Landing Type", + "title": "Landing type", "enum": [ "Landing type 0", "Landing type 1", @@ -194,7 +194,7 @@ "properties": { "jam_type": { "type": "string", - "title": "Jam Type" + "title": "Jam type" } } } @@ -211,7 +211,7 @@ "properties": { "disease_type": { "type": "string", - "title": "Disease Type", + "title": "Disease type", "enum": [ "Disease type 0", "Disease type 1", @@ -258,11 +258,11 @@ "properties": { "home_area": { "type": "string", - "title": "Home Area" + "title": "Home area (in square meters)" }, "invasive_species": { "type": "string", - "title": "Invasive Species", + "title": "Invasive species", "enum": [ "Invasive species 0", "Invasive species 1", @@ -284,11 +284,11 @@ "properties": { "number_heritage_species": { "type": "number", - "title": "Number Heritage Species" + "title": "Number heritage species" }, "heritage_species": { "type": "string", - "title": "Heritage Species", + "title": "Heritage species", "enum": [ "Heritage species 0", "Heritage species 1", @@ -297,7 +297,7 @@ }, "heritage_observation": { "type": "string", - "title": "Heritage Observation", + "title": "Heritage observation", "enum": [ "Heritage observation 0", "Heritage observation 1", @@ -319,11 +319,11 @@ "properties": { "number_fish_species": { "type": "number", - "title": "Number Fish Species" + "title": "Number fish species" }, "fish_species": { "type": "string", - "title": "Fish Species", + "title": "Fish species", "enum": [ "Fish species 0", "Fish species 1", @@ -345,7 +345,7 @@ "properties": { "type": { "type": "string", - "title": "Water Level Type", + "title": "Water level type", "enum": [ "Dry", "In the process of drying out", @@ -412,7 +412,7 @@ "properties": { "nature_pollution": { "type": "string", - "title": "Nature Pollution", + "title": "Nature pollution", "enum": [ "Nature pollution 0", "Nature pollution 1", @@ -421,7 +421,7 @@ }, "type_pollution": { "type": "string", - "title": "Type Pollution", + "title": "Type pollution", "enum": [ "Type pollution 0", "Type pollution 1", diff --git a/georiviere/portal/tests/data/json_schema_base_contribution_without_subtypes.json b/georiviere/portal/tests/data/json_schema_base_contribution_without_subtypes.json index b253c752..4681863f 100644 --- a/georiviere/portal/tests/data/json_schema_base_contribution_without_subtypes.json +++ b/georiviere/portal/tests/data/json_schema_base_contribution_without_subtypes.json @@ -86,7 +86,7 @@ "properties": { "excessive_cutting_length": { "type": "number", - "title": "Excessive Cutting Length In Meters" + "title": "Excessive cutting length (in meters)" } } } @@ -103,7 +103,7 @@ "properties": { "length_bank_erosion": { "type": "string", - "title": "Length Bank Erosion" + "title": "Length bank erosion (in meters)" } } } @@ -120,7 +120,7 @@ "properties": { "bank_height": { "type": "string", - "title": "Bank Height" + "title": "Bank height (in meters)" } } } @@ -137,7 +137,7 @@ "properties": { "number_death": { "type": "number", - "title": "Number Death" + "title": "Number death" } } } @@ -179,7 +179,7 @@ "properties": { "home_area": { "type": "string", - "title": "Home Area" + "title": "Home area (in square meters)" } } } @@ -196,7 +196,7 @@ "properties": { "number_heritage_species": { "type": "number", - "title": "Number Heritage Species" + "title": "Number heritage species" } } } @@ -213,7 +213,7 @@ "properties": { "number_fish_species": { "type": "number", - "title": "Number Fish Species" + "title": "Number fish species" } } } @@ -230,7 +230,7 @@ "properties": { "type": { "type": "string", - "title": "Water Level Type", + "title": "Water level type", "enum": [ "Dry", "In the process of drying out",