Skip to content

Commit

Permalink
Merge pull request #220 from Georiviere/multiple_fix_gra
Browse files Browse the repository at this point in the history
Multiple fix gra
  • Loading branch information
babastienne authored Nov 15, 2023
2 parents 7d37735 + 3ee179c commit eace002
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 74 deletions.
512 changes: 480 additions & 32 deletions georiviere/contribution/fixtures/basic.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion georiviere/contribution/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class ContributionForm(autocomplete.FutureModelForm, CommonForm):
can_delete = False
geomfields = ['geom']

linked_object = autocomplete.Select2GenericForeignKeyModelField(
Expand Down
27 changes: 15 additions & 12 deletions georiviere/contribution/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-15 17:01+0000\n"
"POT-Creation-Date: 2023-11-10 12:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -109,11 +109,11 @@ msgstr "Aucun type"
msgid "Feedback from {email}"
msgstr "Retour utilisateur depuis {email}"

msgid "Contribution potential damage type"
msgstr "Type de contibution dégats potentiels"
msgid "Landing type"
msgstr "Type d'atterrissement"

msgid "Contribution potential damage types"
msgstr "Contribution Dégats potentiels"
msgid "Landing types"
msgstr "Types d'atterrissement"

msgid "Jam type"
msgstr "Type d'embâcle"
Expand Down Expand Up @@ -157,9 +157,6 @@ msgstr "Mortalité piscicole"
msgid "Trampling by livestock (impacting)"
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)"

Expand Down Expand Up @@ -241,16 +238,16 @@ msgid "contributions quantity"
msgstr "Contributions quantité"

msgid "Nature pollution"
msgstr "Nature pollution"
msgstr "Nature de la pollution"

msgid "Natures pollution"
msgstr "Natures pollution"
msgstr "Natures des pollutions"

msgid "Type pollution"
msgstr "Type pollution"
msgstr "Type de pollution"

msgid "Types pollution"
msgstr "Types pollution"
msgstr "Types de pollution"

msgid "Algal development"
msgstr "Développement algal"
Expand Down Expand Up @@ -318,6 +315,12 @@ msgstr "Contentieux"
msgid "Knowledge"
msgstr "Connaissance"

msgid "Observed species"
msgstr "Espèce observée"

msgid "Observation type"
msgstr "Type d'observation"

msgid "None"
msgstr "Aucun"

Expand Down
17 changes: 17 additions & 0 deletions georiviere/contribution/migrations/0009_auto_20231110_1214.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.1.14 on 2023-11-10 12:14

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('contribution', '0008_auto_20230731_1304'),
]

operations = [
migrations.AlterModelOptions(
name='landingtype',
options={'verbose_name': 'Landing type', 'verbose_name_plural': 'Landing types'},
),
]
4 changes: 2 additions & 2 deletions georiviere/contribution/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ class LandingType(models.Model):
label = models.CharField(max_length=128, verbose_name=_("Label"), unique=True)

class Meta:
verbose_name = _("Contribution potential damage type")
verbose_name_plural = _("Contribution potential damage types")
verbose_name = _("Landing type")
verbose_name_plural = _("Landing types")

def __str__(self):
return self.label
Expand Down
26 changes: 11 additions & 15 deletions georiviere/contribution/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_landing(choices, meta):
'landing_type':
{
'type': "string",
'title': str(meta.get_field('landing_type').verbose_name.capitalize()),
'title': str(meta.get_field('landing_type').related_model._meta.verbose_name.capitalize()),
'enum': list(LandingType.objects.values_list('label', flat=True))
}
},
Expand Down Expand Up @@ -111,7 +111,8 @@ def get_disruptive_jam(choices, meta):
{
'type': "string",
'title': str(meta.get_field(
'jam_type').verbose_name.capitalize()),
'jam_type').related_model._meta.verbose_name.capitalize()),
'enum': list(JamType.objects.values_list('label', flat=True))
}
},
}
Expand Down Expand Up @@ -174,7 +175,7 @@ def get_fish_diseases(choices, meta):
{
'type': "string",
'title': str(meta.get_field(
'disease_type').verbose_name.capitalize()),
'disease_type').related_model._meta.verbose_name.capitalize()),
'enum': list(DiseaseType.objects.values_list('label', flat=True))
}
},
Expand All @@ -195,8 +196,7 @@ def get_fish_mortality(choices, meta):
if DeadSpecies.objects.exists():
fish_mortality_property['dead_species'] = {
'type': "string",
'title': str(meta.get_field(
'dead_species').verbose_name.capitalize()),
'title': _("Observed species"),
'enum': list(DeadSpecies.objects.values_list('label', flat=True))
}
fish_mortality = {
Expand Down Expand Up @@ -264,8 +264,7 @@ def get_invasive_species(choices, meta):
if InvasiveSpecies.objects.exists():
invasive_species_property['invasive_species'] = {
'type': "string",
'title': str(meta.get_field(
'invasive_species').verbose_name.capitalize()),
'title': _("Observed species"),
'enum': list(InvasiveSpecies.objects.values_list('label', flat=True))
}
invasive_species = {
Expand Down Expand Up @@ -293,15 +292,13 @@ def get_heritage_species(choices, meta):
if HeritageSpecies.objects.exists():
heritage_species_property['heritage_species'] = {
'type': "string",
'title': str(meta.get_field(
'heritage_species').verbose_name.capitalize()),
'title': _("Observed species"),
'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.capitalize()),
'title': _("Observation type"),
'enum': list(HeritageObservation.objects.values_list('label', flat=True))
}
heritage_species = {
Expand Down Expand Up @@ -329,8 +326,7 @@ def get_fish_species(choices, meta):
if FishSpecies.objects.exists():
fish_species_property['fish_species'] = {
'type': "string",
'title': str(meta.get_field(
'fish_species').verbose_name.capitalize()),
'title': _("Observed species"),
'enum': list(FishSpecies.objects.values_list('label', flat=True))
}
fish_species = {
Expand Down Expand Up @@ -429,14 +425,14 @@ def get_pollution(choices, meta):
pollution_property['nature_pollution'] = {
'type': "string",
'title': str(meta.get_field(
'nature_pollution').verbose_name.capitalize()),
'nature_pollution').related_model._meta.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.capitalize()),
'type_pollution').related_model._meta.verbose_name.capitalize()),
'enum': list(TypePollution.objects.values_list('label', flat=True))
}
pollution = {
Expand Down
6 changes: 6 additions & 0 deletions georiviere/contribution/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,11 @@ def test_crud_status(self):
response = self.client.get(obj.get_update_url())
self.assertEqual(response.status_code, 302)

# Test to delete object
self.login()

response = self.client.get(obj.get_update_url())
self.assertEqual(response.status_code, 200)

def test_document_export(self):
pass
10 changes: 4 additions & 6 deletions georiviere/contribution/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mapentity.views import (MapEntityList, MapEntityDetail, MapEntityFormat, MapEntityLayer, MapEntityJsonList,
MapEntityUpdate)
MapEntityUpdate, MapEntityDelete)


from georiviere.contribution.filters import ContributionFilterSet
Expand Down Expand Up @@ -36,8 +36,6 @@ class ContributionUpdate(MapEntityUpdate):
model = Contribution
form_class = ContributionForm

def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
# We don't want to allow to delete contributions
kwargs['can_delete'] = False
return kwargs

class ContributionDelete(MapEntityDelete):
model = Contribution
17 changes: 11 additions & 6 deletions georiviere/portal/tests/data/json_schema_base_contribution.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
},
"dead_species": {
"type": "string",
"title": "Dead species",
"title": "Observed species",
"enum": [
"Dead species 0",
"Dead species 1",
Expand Down Expand Up @@ -194,7 +194,12 @@
"properties": {
"jam_type": {
"type": "string",
"title": "Jam type"
"title": "Jam type",
"enum": [
"Jam type 0",
"Jam type 1",
"Jam type 2"
]
}
}
}
Expand Down Expand Up @@ -262,7 +267,7 @@
},
"invasive_species": {
"type": "string",
"title": "Invasive species",
"title": "Observed species",
"enum": [
"Invasive species 0",
"Invasive species 1",
Expand All @@ -288,7 +293,7 @@
},
"heritage_species": {
"type": "string",
"title": "Heritage species",
"title": "Observed species",
"enum": [
"Heritage species 0",
"Heritage species 1",
Expand All @@ -297,7 +302,7 @@
},
"heritage_observation": {
"type": "string",
"title": "Heritage observation",
"title": "Observation type",
"enum": [
"Heritage observation 0",
"Heritage observation 1",
Expand All @@ -323,7 +328,7 @@
},
"fish_species": {
"type": "string",
"title": "Fish species",
"title": "Observed species",
"enum": [
"Fish species 0",
"Fish species 1",
Expand Down

0 comments on commit eace002

Please sign in to comment.