From 7a787f0ef5f0cbe381e87267278ea7fd577596d3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 29 Aug 2022 15:55:25 +0200 Subject: Fix INSEE number generation on error with years --- CHANGES.md | 3 + ishtar_common/fixtures/initial_geo-fr.json | 494 +++++++++++++++++++++ .../fixtures/initial_spatialrefsystem-fr.json | 494 --------------------- ishtar_common/models_common.py | 9 +- 4 files changed, 505 insertions(+), 495 deletions(-) create mode 100644 ishtar_common/fixtures/initial_geo-fr.json delete mode 100644 ishtar_common/fixtures/initial_spatialrefsystem-fr.json diff --git a/CHANGES.md b/CHANGES.md index 810728039..47055895b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,9 @@ v4.0.15 - 2022- - "is locked" search +### Bug fix ### +- Fix INSEE number generation on error with years + v4.0.14 - 2022-08-05 -------------------- diff --git a/ishtar_common/fixtures/initial_geo-fr.json b/ishtar_common/fixtures/initial_geo-fr.json new file mode 100644 index 000000000..ea244e0d0 --- /dev/null +++ b/ishtar_common/fixtures/initial_geo-fr.json @@ -0,0 +1,494 @@ +[ +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS84 (lat-long)", + "txt_idx": "wgs84", + "comment": "", + "available": true, + "order": 2, + "auth_name": "EPSG", + "srid": 4326 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "Syst\u00e8me local (non r\u00e9f\u00e9renc\u00e9)", + "txt_idx": "local", + "comment": "", + "available": true, + "order": 1, + "auth_name": "EPSG", + "srid": 0 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / Lambert-93", + "txt_idx": "lambert93", + "comment": "", + "available": true, + "order": 10, + "auth_name": "EPSG", + "srid": 2154 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC42", + "txt_idx": "lambert-cc42", + "comment": "", + "available": true, + "order": 11, + "auth_name": "EPSG", + "srid": 3942 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC43", + "txt_idx": "lambert-cc43", + "comment": "", + "available": true, + "order": 12, + "auth_name": "EPSG", + "srid": 3943 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC44", + "txt_idx": "lambert-cc44", + "comment": "", + "available": true, + "order": 13, + "auth_name": "EPSG", + "srid": 3944 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC45", + "txt_idx": "lambert-cc45", + "comment": "", + "available": true, + "order": 14, + "auth_name": "EPSG", + "srid": 3945 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC46", + "txt_idx": "lambert-cc46", + "comment": "", + "available": true, + "order": 15, + "auth_name": "EPSG", + "srid": 3946 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC47", + "txt_idx": "lambert-cc47", + "comment": "", + "available": true, + "order": 16, + "auth_name": "EPSG", + "srid": 3947 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC48", + "txt_idx": "lambert-cc48", + "comment": "", + "available": true, + "order": 17, + "auth_name": "EPSG", + "srid": 3948 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC49", + "txt_idx": "lambert-cc49", + "comment": "", + "available": true, + "order": 18, + "auth_name": "EPSG", + "srid": 3949 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGF93 / CC50", + "txt_idx": "lambert-cc50", + "comment": "", + "available": true, + "order": 19, + "auth_name": "EPSG", + "srid": 3950 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert Nord France", + "txt_idx": "lambert-nord-france", + "comment": "", + "available": true, + "order": 30, + "auth_name": "EPSG", + "srid": 27561 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert Centre France", + "txt_idx": "lambert-centre-france", + "comment": "", + "available": true, + "order": 31, + "auth_name": "EPSG", + "srid": 27562 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert Sud France", + "txt_idx": "lambert-sud-france", + "comment": "", + "available": true, + "order": 32, + "auth_name": "EPSG", + "srid": 27563 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert Corse", + "txt_idx": "lambert-corse", + "comment": "", + "available": true, + "order": 33, + "auth_name": "EPSG", + "srid": 27564 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert zone I", + "txt_idx": "lambert-zone-i", + "comment": "", + "available": true, + "order": 34, + "auth_name": "EPSG", + "srid": 27571 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert zone II (Lambert II \u00e9tendu)", + "txt_idx": "lambert-zone-ii", + "comment": "", + "available": true, + "order": 35, + "auth_name": "EPSG", + "srid": 27572 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert zone III", + "txt_idx": "lambert-zone-iii", + "comment": "", + "available": true, + "order": 36, + "auth_name": "EPSG", + "srid": 27573 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "NTF (Paris) / Lambert zone IV", + "txt_idx": "lambert-zone-iv", + "comment": "", + "available": true, + "order": 37, + "auth_name": "EPSG", + "srid": 27574 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 28N", + "txt_idx": "utm-28n", + "comment": "", + "available": true, + "order": 128, + "auth_name": "EPSG", + "srid": 32628 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 29N", + "txt_idx": "utm-29n", + "comment": "", + "available": true, + "order": 129, + "auth_name": "EPSG", + "srid": 32629 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 30N", + "txt_idx": "utm-30n", + "comment": "", + "available": true, + "order": 130, + "auth_name": "EPSG", + "srid": 32630 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 31N", + "txt_idx": "utm-31n", + "comment": "", + "available": true, + "order": 131, + "auth_name": "EPSG", + "srid": 32631 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 32N", + "txt_idx": "utm-32n", + "comment": "", + "available": true, + "order": 132, + "auth_name": "EPSG", + "srid": 32632 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 33N", + "txt_idx": "utm-33n", + "comment": "", + "available": true, + "order": 133, + "auth_name": "EPSG", + "srid": 32633 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 34N", + "txt_idx": "utm-34n", + "comment": "", + "available": true, + "order": 134, + "auth_name": "EPSG", + "srid": 32634 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 35N", + "txt_idx": "utm-35n", + "comment": "", + "available": true, + "order": 135, + "auth_name": "EPSG", + "srid": 32635 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 36N", + "txt_idx": "utm-36n", + "comment": "", + "available": true, + "order": 136, + "auth_name": "EPSG", + "srid": 32636 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 37N", + "txt_idx": "utm-37n", + "comment": "", + "available": true, + "order": 137, + "auth_name": "EPSG", + "srid": 32637 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 38N", + "txt_idx": "utm-38n", + "comment": "", + "available": true, + "order": 138, + "auth_name": "EPSG", + "srid": 32638 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 39N", + "txt_idx": "utm-39n", + "comment": "", + "available": true, + "order": 139, + "auth_name": "EPSG", + "srid": 32639 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / UTM zone 40N", + "txt_idx": "utm-40n", + "comment": "", + "available": true, + "order": 140, + "auth_name": "EPSG", + "srid": 32640 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "ETRS89 / LCC Europe", + "txt_idx": "lcc-europe", + "comment": "", + "available": true, + "order": 200, + "auth_name": "EPSG", + "srid": 3034 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "ETRS89 / LAEA Europe", + "txt_idx": "laea-europe", + "comment": "", + "available": true, + "order": 201, + "auth_name": "EPSG", + "srid": 3035 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "WGS 84 / World Mercator", + "txt_idx": "wgs84-mercator", + "comment": "", + "available": true, + "order": 250, + "auth_name": "EPSG", + "srid": 3395 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGFG95 / UTM zone 22N (Guyane)", + "txt_idx": "utm-guyane", + "comment": "", + "available": true, + "order": 300, + "auth_name": "EPSG", + "srid": 2972 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGR92 / UTM zone 40S (La R\u00e9union)", + "txt_idx": "utm-reunion", + "comment": "", + "available": true, + "order": 310, + "auth_name": "EPSG", + "srid": 2975 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGSPM06 / UTM 21N (St-Pierre-et-Miquelon)", + "txt_idx": "utm-miquelon", + "comment": "", + "available": true, + "order": 320, + "auth_name": "EPSG", + "srid": 4467 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RGM04 / UTM zone 38S (Mayotte)", + "txt_idx": "utm-mayotte", + "comment": "", + "available": true, + "order": 330, + "auth_name": "EPSG", + "srid": 4471 + } +}, +{ + "model": "ishtar_common.spatialreferencesystem", + "fields": { + "label": "RRAF 1991 / UTM zone 20N (Guadeloupe et Martinique)", + "txt_idx": "utm-guadeloupe", + "comment": "", + "available": true, + "order": 340, + "auth_name": "EPSG", + "srid": 4559 + } +} +] diff --git a/ishtar_common/fixtures/initial_spatialrefsystem-fr.json b/ishtar_common/fixtures/initial_spatialrefsystem-fr.json deleted file mode 100644 index ea244e0d0..000000000 --- a/ishtar_common/fixtures/initial_spatialrefsystem-fr.json +++ /dev/null @@ -1,494 +0,0 @@ -[ -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS84 (lat-long)", - "txt_idx": "wgs84", - "comment": "", - "available": true, - "order": 2, - "auth_name": "EPSG", - "srid": 4326 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "Syst\u00e8me local (non r\u00e9f\u00e9renc\u00e9)", - "txt_idx": "local", - "comment": "", - "available": true, - "order": 1, - "auth_name": "EPSG", - "srid": 0 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / Lambert-93", - "txt_idx": "lambert93", - "comment": "", - "available": true, - "order": 10, - "auth_name": "EPSG", - "srid": 2154 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC42", - "txt_idx": "lambert-cc42", - "comment": "", - "available": true, - "order": 11, - "auth_name": "EPSG", - "srid": 3942 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC43", - "txt_idx": "lambert-cc43", - "comment": "", - "available": true, - "order": 12, - "auth_name": "EPSG", - "srid": 3943 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC44", - "txt_idx": "lambert-cc44", - "comment": "", - "available": true, - "order": 13, - "auth_name": "EPSG", - "srid": 3944 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC45", - "txt_idx": "lambert-cc45", - "comment": "", - "available": true, - "order": 14, - "auth_name": "EPSG", - "srid": 3945 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC46", - "txt_idx": "lambert-cc46", - "comment": "", - "available": true, - "order": 15, - "auth_name": "EPSG", - "srid": 3946 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC47", - "txt_idx": "lambert-cc47", - "comment": "", - "available": true, - "order": 16, - "auth_name": "EPSG", - "srid": 3947 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC48", - "txt_idx": "lambert-cc48", - "comment": "", - "available": true, - "order": 17, - "auth_name": "EPSG", - "srid": 3948 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC49", - "txt_idx": "lambert-cc49", - "comment": "", - "available": true, - "order": 18, - "auth_name": "EPSG", - "srid": 3949 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGF93 / CC50", - "txt_idx": "lambert-cc50", - "comment": "", - "available": true, - "order": 19, - "auth_name": "EPSG", - "srid": 3950 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert Nord France", - "txt_idx": "lambert-nord-france", - "comment": "", - "available": true, - "order": 30, - "auth_name": "EPSG", - "srid": 27561 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert Centre France", - "txt_idx": "lambert-centre-france", - "comment": "", - "available": true, - "order": 31, - "auth_name": "EPSG", - "srid": 27562 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert Sud France", - "txt_idx": "lambert-sud-france", - "comment": "", - "available": true, - "order": 32, - "auth_name": "EPSG", - "srid": 27563 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert Corse", - "txt_idx": "lambert-corse", - "comment": "", - "available": true, - "order": 33, - "auth_name": "EPSG", - "srid": 27564 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert zone I", - "txt_idx": "lambert-zone-i", - "comment": "", - "available": true, - "order": 34, - "auth_name": "EPSG", - "srid": 27571 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert zone II (Lambert II \u00e9tendu)", - "txt_idx": "lambert-zone-ii", - "comment": "", - "available": true, - "order": 35, - "auth_name": "EPSG", - "srid": 27572 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert zone III", - "txt_idx": "lambert-zone-iii", - "comment": "", - "available": true, - "order": 36, - "auth_name": "EPSG", - "srid": 27573 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "NTF (Paris) / Lambert zone IV", - "txt_idx": "lambert-zone-iv", - "comment": "", - "available": true, - "order": 37, - "auth_name": "EPSG", - "srid": 27574 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 28N", - "txt_idx": "utm-28n", - "comment": "", - "available": true, - "order": 128, - "auth_name": "EPSG", - "srid": 32628 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 29N", - "txt_idx": "utm-29n", - "comment": "", - "available": true, - "order": 129, - "auth_name": "EPSG", - "srid": 32629 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 30N", - "txt_idx": "utm-30n", - "comment": "", - "available": true, - "order": 130, - "auth_name": "EPSG", - "srid": 32630 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 31N", - "txt_idx": "utm-31n", - "comment": "", - "available": true, - "order": 131, - "auth_name": "EPSG", - "srid": 32631 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 32N", - "txt_idx": "utm-32n", - "comment": "", - "available": true, - "order": 132, - "auth_name": "EPSG", - "srid": 32632 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 33N", - "txt_idx": "utm-33n", - "comment": "", - "available": true, - "order": 133, - "auth_name": "EPSG", - "srid": 32633 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 34N", - "txt_idx": "utm-34n", - "comment": "", - "available": true, - "order": 134, - "auth_name": "EPSG", - "srid": 32634 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 35N", - "txt_idx": "utm-35n", - "comment": "", - "available": true, - "order": 135, - "auth_name": "EPSG", - "srid": 32635 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 36N", - "txt_idx": "utm-36n", - "comment": "", - "available": true, - "order": 136, - "auth_name": "EPSG", - "srid": 32636 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 37N", - "txt_idx": "utm-37n", - "comment": "", - "available": true, - "order": 137, - "auth_name": "EPSG", - "srid": 32637 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 38N", - "txt_idx": "utm-38n", - "comment": "", - "available": true, - "order": 138, - "auth_name": "EPSG", - "srid": 32638 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 39N", - "txt_idx": "utm-39n", - "comment": "", - "available": true, - "order": 139, - "auth_name": "EPSG", - "srid": 32639 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / UTM zone 40N", - "txt_idx": "utm-40n", - "comment": "", - "available": true, - "order": 140, - "auth_name": "EPSG", - "srid": 32640 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "ETRS89 / LCC Europe", - "txt_idx": "lcc-europe", - "comment": "", - "available": true, - "order": 200, - "auth_name": "EPSG", - "srid": 3034 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "ETRS89 / LAEA Europe", - "txt_idx": "laea-europe", - "comment": "", - "available": true, - "order": 201, - "auth_name": "EPSG", - "srid": 3035 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "WGS 84 / World Mercator", - "txt_idx": "wgs84-mercator", - "comment": "", - "available": true, - "order": 250, - "auth_name": "EPSG", - "srid": 3395 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGFG95 / UTM zone 22N (Guyane)", - "txt_idx": "utm-guyane", - "comment": "", - "available": true, - "order": 300, - "auth_name": "EPSG", - "srid": 2972 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGR92 / UTM zone 40S (La R\u00e9union)", - "txt_idx": "utm-reunion", - "comment": "", - "available": true, - "order": 310, - "auth_name": "EPSG", - "srid": 2975 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGSPM06 / UTM 21N (St-Pierre-et-Miquelon)", - "txt_idx": "utm-miquelon", - "comment": "", - "available": true, - "order": 320, - "auth_name": "EPSG", - "srid": 4467 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RGM04 / UTM zone 38S (Mayotte)", - "txt_idx": "utm-mayotte", - "comment": "", - "available": true, - "order": 330, - "auth_name": "EPSG", - "srid": 4471 - } -}, -{ - "model": "ishtar_common.spatialreferencesystem", - "fields": { - "label": "RRAF 1991 / UTM zone 20N (Guadeloupe et Martinique)", - "txt_idx": "utm-guadeloupe", - "comment": "", - "available": true, - "order": 340, - "auth_name": "EPSG", - "srid": 4559 - } -} -] diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 238bbeeac..aa644f35a 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2694,7 +2694,14 @@ class Town(GeographicItem, Imported, models.Model): return old_num = self.numero_insee[:] numero = old_num.split("-")[0] - self.numero_insee = "{}-{}".format(numero, self.year) + base_insee = "{}-{}".format(numero, self.year) + self.numero_insee = base_insee + idx = 0 + while Town.objects.filter( + year=self.year, numero_insee=self.numero_insee).exclude( + pk=self.pk).count(): + idx += 1 + self.numero_insee = base_insee + "-" + str(idx) if self.numero_insee != old_num: return True -- cgit v1.2.3