diff --git a/georiviere/knowledge/admin.py b/georiviere/knowledge/admin.py index 4c448019..d6e60620 100644 --- a/georiviere/knowledge/admin.py +++ b/georiviere/knowledge/admin.py @@ -1,23 +1,21 @@ from django.contrib import admin from georiviere.knowledge.models import ( - Vegetation, VegetationState, VegetationStrata, VegetationType, + VegetationState, VegetationStrata, VegetationType, VegetationAgeClassDiversity, VegetationThicknessType, VegetationSpecificDiversity, - Work, WorkBankEffect, WorkFishContinuityEffect, WorkSedimentEffect, + WorkBankEffect, WorkFishContinuityEffect, WorkSedimentEffect, WorkWaterEffect, WorkBedEffect, WorkStreamInfluence, WorkMaterial, WorkState, WorkType, KnowledgeType, FollowUpType ) admin.site.register(KnowledgeType, admin.ModelAdmin) -admin.site.register(Vegetation) admin.site.register(VegetationAgeClassDiversity, admin.ModelAdmin) admin.site.register(VegetationSpecificDiversity, admin.ModelAdmin) admin.site.register(VegetationState, admin.ModelAdmin) admin.site.register(VegetationStrata, admin.ModelAdmin) admin.site.register(VegetationThicknessType, admin.ModelAdmin) admin.site.register(VegetationType, admin.ModelAdmin) -admin.site.register(Work) admin.site.register(WorkBankEffect, admin.ModelAdmin) admin.site.register(WorkStreamInfluence, admin.ModelAdmin) admin.site.register(WorkFishContinuityEffect, admin.ModelAdmin) diff --git a/georiviere/knowledge/tests/test_forms.py b/georiviere/knowledge/tests/test_forms.py new file mode 100644 index 00000000..1305b770 --- /dev/null +++ b/georiviere/knowledge/tests/test_forms.py @@ -0,0 +1,31 @@ +from django.test import TestCase + +from geotrek.authent.tests.factories import StructureFactory + +from georiviere.tests.factories import UserAllPermsFactory +from georiviere.knowledge.forms import KnowledgeForm +from . import factories + + +class KnowledgeFormTest(TestCase): + """Test knowledge forms""" + + @classmethod + def setUpTestData(cls): + cls.user = UserAllPermsFactory(password='booh') + cls.knowledge = factories.KnowledgeFactory() + + def test_update_knowledge(self): + """Test create new knowledge""" + data = { + 'structure': self.knowledge.structure, + 'name': 'New name', + 'description': self.knowledge.description, + 'geom': self.knowledge.geom.ewkt, + } + knowledge_form_update = KnowledgeForm( + user=self.user, + instance=self.knowledge, + data=data + ) + self.assertTrue(knowledge_form_update.is_valid()) diff --git a/georiviere/river/fields.py b/georiviere/river/fields.py index f8014ed0..d57e98f5 100644 --- a/georiviere/river/fields.py +++ b/georiviere/river/fields.py @@ -15,12 +15,18 @@ logger = logging.getLogger(__name__) -class SnappedFieldMixin(object): +class SnappedFieldMixin: """ It's a Geometry field, with additional information about snapped vertices. """ widget = SnappedGeometryWidget + +class ForceSnapFieldMixin(SnappedFieldMixin): + """ + It's a Geometry field, with additional information about snapped vertices, and force snap on validation + """ + default_error_messages = { 'invalid_snap_line': _('Geometry invalid snapping.'), }