From c2403220e382b271e99764b285229041af3b3615 Mon Sep 17 00:00:00 2001 From: Bruno Besson Date: Tue, 6 Jul 2021 22:16:43 +0200 Subject: [PATCH 1/2] Ensure to clear associations first? --- c2corg_api/views/document_delete.py | 1 + 1 file changed, 1 insertion(+) diff --git a/c2corg_api/views/document_delete.py b/c2corg_api/views/document_delete.py index f5fed2cc5..d061fdb88 100644 --- a/c2corg_api/views/document_delete.py +++ b/c2corg_api/views/document_delete.py @@ -335,6 +335,7 @@ def remove_whole_document(document_id, clazz, clazz_locale, _remove_locale(clazz_locale, document_id) _remove_geometry(document_id) _remove_figures(clazz, document_id) + _remove_associations(document_id) # When all references have been deleted, finally remove the main # document entry: _remove_document(document_id) From 7cc19e76e9c5c692e20240e38b564715da71aa2c Mon Sep 17 00:00:00 2001 From: Bruno Besson Date: Mon, 12 Jul 2021 12:51:54 +0200 Subject: [PATCH 2/2] Add UT --- c2corg_api/tests/scripts/users/test_merge.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/c2corg_api/tests/scripts/users/test_merge.py b/c2corg_api/tests/scripts/users/test_merge.py index bb8a70332..b721d0b6d 100644 --- a/c2corg_api/tests/scripts/users/test_merge.py +++ b/c2corg_api/tests/scripts/users/test_merge.py @@ -14,6 +14,8 @@ from c2corg_api.models.route import Route, RouteLocale, ROUTE_TYPE from c2corg_api.models.sso import SsoExternalId from c2corg_api.models.token import Token +from c2corg_api.models.topo_map import TopoMap +from c2corg_api.models.topo_map_association import TopoMapAssociation from c2corg_api.models.user import User from c2corg_api.models.user_profile import UserProfile, ArchiveUserProfile, \ USERPROFILE_TYPE @@ -194,6 +196,20 @@ def _add_test_data(self): document=self.contributor.profile, area=area)) self.session.flush() + self.map1 = TopoMap( + code='3232ET', editor='IGN', scale='25000', + locales=[ + DocumentLocale(lang='fr', title='Belley') + ], + geometry=DocumentGeometry(geom_detail='SRID=3857;POLYGON((611774.917032556 5706934.10657514,611774.917032556 5744215.5846397,642834.402570357 5744215.5846397,642834.402570357 5706934.10657514,611774.917032556 5706934.10657514))') # noqa + ) + self.session.add(self.map1) + self.session.flush() + self.session.add(TopoMapAssociation( + document=self.contributor.profile, + topo_map=self.map1)) + self.session.flush() + self.waypoint1 = Waypoint( waypoint_type='summit', elevation=2203, locales=[WaypointLocale(lang='en', title='Mont Granier')],