summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-10-30 10:23:12 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-10-30 10:23:12 +0100
commit11c428fdd9b68c8255f1aeb6890628425a5d8898 (patch)
treed81c85d1b433ed3c0a658f95b1841784789e7c8a
parentd71ab9b6f0efc1ec27cc4dcafdad1f3119a2566a (diff)
parent47743d97e01345b7e39a18541100a020f6cfd94d (diff)
downloadIshtar-11c428fdd9b68c8255f1aeb6890628425a5d8898.tar.bz2
Ishtar-11c428fdd9b68c8255f1aeb6890628425a5d8898.zip
Merge branch 'develop' into develop-bootstrap
-rw-r--r--.gitignore2
-rw-r--r--Makefile.example8
-rw-r--r--archaeological_context_records/migrations/0013_auto_20171026_1827.py34
-rw-r--r--archaeological_files/migrations/0011_auto_20171026_1827.py26
-rw-r--r--archaeological_finds/migrations/0013_auto_20171026_1828.py61
-rw-r--r--archaeological_operations/migrations/0012_auto_20171026_1827.py55
-rw-r--r--archaeological_warehouse/migrations/0011_auto_20171026_1828.py31
-rw-r--r--example_project/settings.py1
-rwxr-xr-xinstall/ishtar-install45
-rw-r--r--ishtar_common/admin.py10
-rw-r--r--ishtar_common/fixtures/initial_importtypes-fr.json1534
-rw-r--r--ishtar_common/fixtures/test_towns.json2
-rw-r--r--ishtar_common/management/commands/import_geofla_csv.py87
-rw-r--r--ishtar_common/management/commands/import_insee_comm_csv.py106
-rw-r--r--ishtar_common/migrations/0019_auto_20171026_1827.py54
-rw-r--r--ishtar_common/models.py70
-rw-r--r--ishtar_common/tests.py50
-rw-r--r--ishtar_common/tests/geofla-test.csv10
-rw-r--r--ishtar_common/tests/insee-test.csv3
19 files changed, 2141 insertions, 48 deletions
diff --git a/.gitignore b/.gitignore
index 74e5871fa..4c38aae39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,5 @@ example_project/.coverage
bootstrap-src
node_modules/
package-lock.json
+ishtar_common/fixtures/towns_norel-fr.json
+ishtar_common/fixtures/towns-fr.json
diff --git a/Makefile.example b/Makefile.example
index c3b40b6df..95e7121a2 100644
--- a/Makefile.example
+++ b/Makefile.example
@@ -143,11 +143,13 @@ fixtures_common_importers:
> '../ishtar_common/fixtures/initial_importtypes-'$(default_data)'.json'
fixtures_common_towns:
- cd $(project); $(PYTHON) ./manage.py dumpdata --indent 4 \
- ishtar_common.state \
+ cd $(project); $(PYTHON) ./manage.py dumpdata --indent 4 --natural-primary --natural-foreign \
ishtar_common.department \
ishtar_common.town \
- > '../ishtar_common/fixtures/initial_towns-'$(default_data)'.json'
+ > '../ishtar_common/fixtures/towns-'$(default_data)'.json'
+ cat 'ishtar_common/fixtures/towns-'$(default_data)'.json' | tr '\n' '\r' | \
+ sed -e 's/"children": *\[\r *\[\r *"[0-9]*", *\r *[0-9]*\ *\r *\]\r *\]/"children": []/g' | \
+ tr '\r' '\n' > 'ishtar_common/fixtures/towns_norel-'$(default_data)'.json'
fixtures_spatialrefsystem:
cd $(project); $(PYTHON) ./manage.py dumpdata --indent 4 --natural-primary --natural-foreign \
diff --git a/archaeological_context_records/migrations/0013_auto_20171026_1827.py b/archaeological_context_records/migrations/0013_auto_20171026_1827.py
new file mode 100644
index 000000000..7f7c0062e
--- /dev/null
+++ b/archaeological_context_records/migrations/0013_auto_20171026_1827.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:27
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0012_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='recordrelations',
+ options={'permissions': [('view_recordrelation', 'Can view all Context record relations')], 'verbose_name': 'Record relation', 'verbose_name_plural': 'Record relations'},
+ ),
+ migrations.AlterModelOptions(
+ name='recordrelationview',
+ options={'managed': False, 'permissions': [('view_recordrelation', 'Can view all record relations - view')]},
+ ),
+ migrations.AlterField(
+ model_name='contextrecord',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicalcontextrecord',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/archaeological_files/migrations/0011_auto_20171026_1827.py b/archaeological_files/migrations/0011_auto_20171026_1827.py
new file mode 100644
index 000000000..93cbaf62c
--- /dev/null
+++ b/archaeological_files/migrations/0011_auto_20171026_1827.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:27
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_files', '0010_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='file',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicalfile',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/archaeological_finds/migrations/0013_auto_20171026_1828.py b/archaeological_finds/migrations/0013_auto_20171026_1828.py
new file mode 100644
index 000000000..e11bdc60b
--- /dev/null
+++ b/archaeological_finds/migrations/0013_auto_20171026_1828.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:28
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0012_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='basefind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='find',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicalbasefind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicalfind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicaltreatment',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicaltreatmentfile',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='property',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='treatment',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='treatmentfile',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/archaeological_operations/migrations/0012_auto_20171026_1827.py b/archaeological_operations/migrations/0012_auto_20171026_1827.py
new file mode 100644
index 000000000..3b34f8c4f
--- /dev/null
+++ b/archaeological_operations/migrations/0012_auto_20171026_1827.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:27
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_operations', '0011_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='recordrelations',
+ options={'ordering': ('left_record', 'relation_type'), 'permissions': [('view_operationrelation', 'Can view all Operation relations')], 'verbose_name': 'Operation record relation', 'verbose_name_plural': 'Operation record relations'},
+ ),
+ migrations.AlterField(
+ model_name='administrativeact',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='archaeologicalsite',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicaladministrativeact',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicaloperation',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='operation',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='parcel',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='parcelowner',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/archaeological_warehouse/migrations/0011_auto_20171026_1828.py b/archaeological_warehouse/migrations/0011_auto_20171026_1828.py
new file mode 100644
index 000000000..0f1363816
--- /dev/null
+++ b/archaeological_warehouse/migrations/0011_auto_20171026_1828.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:28
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_warehouse', '0010_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='collection',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='container',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='warehouse',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/example_project/settings.py b/example_project/settings.py
index 0c6be079e..1b0f6baea 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -220,6 +220,7 @@ LOGGING = {
# Ishtar custom
SRID = 27572
+SURFACE_SRID = 2154
ENCODING = 'windows-1252'
ALT_ENCODING = 'ISO-8859-15'
APP_NAME = "SRA - Pays de la Loire"
diff --git a/install/ishtar-install b/install/ishtar-install
index a34b1984c..8a51044ea 100755
--- a/install/ishtar-install
+++ b/install/ishtar-install
@@ -255,7 +255,7 @@ EOF
-------------------------------------------------------------------------------
By default Ishtar base path is '/srv/'. With this base path Ishtar is
- installed in '/srv/ishtar/choosen_version/'.
+ installed in '/srv/ishtar/'.
EOF
while [ "$install_path" == '' ]
@@ -287,7 +287,7 @@ EOF
# Run setup for each distro accordingly
case "$lsb_dist" in
ubuntu|debian)
- if [ "$dist_version" != "stretch" ] && [ "$dist_version" != "jessie" ] && [ "$dist_version" != "wheezy" ]; then
+ if [ "$dist_version" != "stretch" ] && [ "$dist_version" != "jessie" ]; then
echo ""
cecho r " Sorry this script cannot manage your version of Debian/Ubuntu."
echo ""
@@ -324,36 +324,6 @@ EOF
( set -x; $sh_c 'sleep 3; apt-get install -y -q uwsgi uwsgi-plugin-python nginx' )
fi
- if [ "$dist_version" == "wheezy" ]; then
- if [ "$default_db" == '127.0.0.1' ]; then
- echo "-------------------------------------------------------------------------------";
- cecho y "Installing postgresql"
- echo ""
- POSTGIS=postgresql-9.1-postgis
- ( set -x; $sh_c 'sleep 3; apt-get install -y -q postgresql '$POSTGIS )
- fi
-
- echo "-------------------------------------------------------------------------------";
- cecho y "Installing Ishtar dependencies"
- echo "";
- ( set -x; $sh_c 'sleep 3; apt-get install -y -q python python-django \
- libjs-jquery libjs-jquery-ui python-pisa python-django-registration \
- python-utidylib python-lxml python-imaging python-django-south \
- python-psycopg2 python-gdal gettext python-unicodecsv memcached \
- python-tidylib python-django-extra-views python-memcache python-dbf' )
-
- echo "-------------------------------------------------------------------------------";
- cecho y "Installing BeautifulSoup4"
- echo "";
-
- ( set -x; $sh_c 'pip install BeautifulSoup4==4.3.2' )
- echo "-------------------------------------------------------------------------------";
- cecho y "Installing django-simple-history"
- echo "";
- ( set -x; $sh_c 'pip install git+https://github.com/treyhunner/django-simple-history.git@0fd9b8e9c6f36b0141367b502420efe92d4e21ce' )
-
- fi
-
if [ "$dist_version" == "jessie" ]; then
if [ "$backports_activated" != 'true' ]; then
echo ""
@@ -379,7 +349,7 @@ EOF
( set -x; $sh_c 'sleep 3; apt-get install -t jessie-backports -y -q python python-django\
python-django-registration python-cffi' )
( set -x; $sh_c 'sleep 3; apt-get install -y -q \
- python-bs4 python-django-formtools libpangocairo-1.0-0 \
+ python-bs4 libpangocairo-1.0-0 \
python-tidylib python-lxml python-imaging python-html5lib \
python-psycopg2 python-gdal gettext python-unicodecsv memcached \
python-django-extra-views python-memcache python-dbf python-markdown' )
@@ -397,6 +367,9 @@ EOF
cecho y "Installing weasyprint"
echo "";
( set -x; $sh_c 'pip install WeasyPrint==0.41' )
+ cecho y "Installing django-formtools"
+ echo "";
+ ( set -x; $sh_c 'pip install django-formtools==2.1' )
fi
@@ -425,7 +398,7 @@ EOF
( set -x; $sh_c 'sleep 3; apt-get install -t stretch-backports -y -q python-django' )
( set -x; $sh_c 'sleep 3; apt-get install -y -q \
python-django-registration libpangocairo-1.0-0 \
- python-bs4 python-django-formtools python-cffi \
+ python-bs4 python-cffi \
python-tidylib python-lxml python-imaging python-html5lib \
python-psycopg2 python-gdal gettext python-unicodecsv memcached \
python-django-extra-views python-memcache python-dbf python-markdown \
@@ -441,7 +414,9 @@ EOF
cecho y "Installing weasyprint"
echo "";
( set -x; $sh_c 'pip install WeasyPrint==0.41' )
-
+ cecho y "Installing django-formtools - Debian version is too old..."
+ echo "";
+ ( set -x; $sh_c 'pip install django-formtools==2.1' )
fi
;;
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py
index 2df910ffd..45e4f7038 100644
--- a/ishtar_common/admin.py
+++ b/ishtar_common/admin.py
@@ -30,7 +30,7 @@ from django.contrib.auth.models import Group, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.admin import SiteAdmin
from django.contrib.sites.models import Site
-from django.contrib.gis.forms import PointField, OSMWidget
+from django.contrib.gis.forms import PointField, OSMWidget, MultiPolygonField
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render
from django.template.defaultfilters import slugify
@@ -194,8 +194,10 @@ class AdminTownForm(forms.ModelForm):
class Meta:
model = models.Town
exclude = ['imports']
- center = PointField(label=_(u"center"), required=False,
+ center = PointField(label=_(u"Center"), required=False,
widget=OSMWidget)
+ limit = MultiPolygonField(label=_(u"Limit"), required=False,
+ widget=OSMWidget)
children = AutoCompleteSelectMultipleField('town', required=False,
label=_(u"Town children"))
@@ -211,11 +213,11 @@ class TownParentInline(admin.TabularInline):
class TownAdmin(admin.ModelAdmin):
model = models.Town
- list_display = ['name', ]
+ list_display = ['name', 'year']
search_fields = ['name']
readonly_fields = ['cached_label']
if settings.COUNTRY == 'fr':
- list_display += ['numero_insee', 'departement', ]
+ list_display += ['numero_insee']
search_fields += ['numero_insee', 'departement__label', ]
list_filter = ("departement",)
form = AdminTownForm
diff --git a/ishtar_common/fixtures/initial_importtypes-fr.json b/ishtar_common/fixtures/initial_importtypes-fr.json
index 438a023e0..97c0856a2 100644
--- a/ishtar_common/fixtures/initial_importtypes-fr.json
+++ b/ishtar_common/fixtures/initial_importtypes-fr.json
@@ -382,6 +382,22 @@
}
},
{
+ "model": "ishtar_common.importertype",
+ "fields": {
+ "name": "Chantier des d\u00e9p\u00f4ts",
+ "slug": "inventory_combo",
+ "description": "Importer format\u00e9 selon l'ordre pr\u00e9vu pour un chantier des collections. Importe \u00e9galement les UE et les parcelles. NE CR\u00c9E PAS LES OP\u00c9RATIONS.",
+ "associated_models": [
+ "archaeological_finds.models_finds.Find"
+ ],
+ "is_template": true,
+ "unicity_keys": "external_id",
+ "available": true,
+ "users": [],
+ "created_models": []
+ }
+},
+{
"model": "ishtar_common.regexp",
"fields": {
"name": "Num\u00e9ro INSEE",
@@ -3356,6 +3372,510 @@
}
},
{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Code op\u00e9ration",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 9,
+ "description": "Code PATRIARCHE ou code num\u00e9rique (entier) UNIQUE pour une op\u00e9ration.",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "base_finds__context_record__operation__code_patriarche"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "INSEE",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 11,
+ "description": "Commune (via num\u00e9ro INSEE).",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "base_finds__context_record__parcel__town__numero_insee"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Section de parcellaire",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 12,
+ "description": "Section (identifiant externe), soit des lettres formant la section . Exemple : \"ZA\".",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "base_finds__context_record__parcel__section"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Num\u00e9ro de parcelle",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 13,
+ "description": "Num\u00e9ro de la parcelle, soit des chiffres sans espaces. Exemple : \"253\".",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "base_finds__context_record__parcel__parcel_number"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Identifiant UE",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 10,
+ "description": "Label / Identifiant (externe) de l'UE. Exemple : \"US 145\", \"Tranch\u00e9e 145\", \"145\", \"St 17\", etc. Doit \u00eatre unique pour une parcelle donn\u00e9e.",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "base_finds__context_record__label"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Identifiant objet ou lot",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 14,
+ "description": "Identifiant libre pour le mobilier. Exemple : \"12\", \"Lot 24\", \"Sac vert\", etc.\r\nDoit \u00eatre unique \u00e0 l'\u00e9chelle de l'UE associ\u00e9e.",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "label"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "R\u00e9f\u00e9rence contenant",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 1,
+ "description": "Label du contenant, si possible visible et identifiable facilement sur celui-ci.",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Type de contenant",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 2,
+ "description": "Type de contenant, fait r\u00e9f\u00e9rence \u00e0 une typologie de contenant",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": ""
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 1",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 3,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la premi\u00e8re localisation. Par exemple si la premi\u00e8re localisation du d\u00e9p\u00f4t concern\u00e9 est \u00ab b\u00e2timent \u00bb mettre : \u00ab A \u00bb pour b\u00e2timent A.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_1"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 2",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 4,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la seconde localisation.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_2"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 3",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 5,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la troisi\u00e8me localisation.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_3"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 4",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 6,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la quatri\u00e8me localisation.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_4"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Identifiant pr\u00e9c\u00e9dent",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 15,
+ "description": "Identifiant pr\u00e9c\u00e9dent, li\u00e9 \u00e0 une base de donn\u00e9e ou un autre mode d'enregistrement. Exemple : \"400.01.05\", \"Beau biface\", \"inv. 4523\", \"Iso.4220\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Lot ou objet",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 16,
+ "description": "D\u00e9finit si on enregistre ici un objet seul (parfois appel\u00e9 Isolation) ou un lot d'objets. Exemple : \"lot\", \"objet\", \"Iso\", \"vrac\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Type(s) d'objet(s)",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 18,
+ "description": "Type(s) d'objet(s), s\u00e9par\u00e9s par des \"&\". Exemple : \"tesson & charbon\", \"os & m\u00e9tal\", \"faune\", \"fibule & bague\", \"lame & lamelle\", \"\u00e9clat & nucl\u00e9us\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Description",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 19,
+ "description": "Description du mobilier, objet ou lot. Exemple : \"Fibule aviforme\". Texte libre.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Nombre",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 20,
+ "description": "Nombre d'objet(s) li\u00e9(s) \u00e0 cet enregistrement (entier). Exemple : \"12\".\r\nAttention, ce champ n'est pas contraint par l'information de type OBJET/LOT.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Poids (g)",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 21,
+ "description": "Poids en grammes. Nombre \u00e0 virgule, exemple : 12.6, 50, 15200",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "\u00c9tat sanitaire",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 22,
+ "description": "\u00c9tat de conservation. Exemple : \"Instable\", \"Stable\", \"Inconnu\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Types d'alt\u00e9ration",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 23,
+ "description": "Type d'alt\u00e9ration observ\u00e9e, choix multiples possibles s\u00e9par\u00e9s par des \"&\", exemple : \"corrosion active&fissuration\", etc. Fait r\u00e9f\u00e9rence \u00e0 une typologie, pr\u00e9sent au sein du MODULE CONSERVATION",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Causes d'alt\u00e9ration",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 24,
+ "description": "Causes d'alt\u00e9ration estim\u00e9e(s), choix multiples possibles s\u00e9par\u00e9s par des \"&\". Fait r\u00e9f\u00e9rence \u00e0 une typologie, pr\u00e9sent au sein du MODULE CONSERVATION",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Type de traitement recommand\u00e9",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 25,
+ "description": "Actions de conservation-restauration \u00e0 mener. Il est possible de proposer plusieurs choix s\u00e9par\u00e9s d'un \"&\", exemple : \"remonter&reconditionner\"",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Urgence du traitement",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 26,
+ "description": "Niveau d'urgence des actions de conservation \u00e0 mener (Type), pr\u00e9sent au sein du MODULE CONSERVATION",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Commentaire sur la conservation",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 27,
+ "description": "Commentaire relatif \u00e0 la conservation. Exemple : \"Devrait \u00eatre conserv\u00e9 dans une chambre climatis\u00e9e\", \"Ne sera plus qu'une poudre, si on ne s'en occupe pas sous peu\", \" \u00e0 jeter\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Int\u00e9grit\u00e9 / int\u00e9r\u00eat",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 28,
+ "description": "Type(s) d'int\u00e9r\u00eat scientifique ou d'int\u00e9grit\u00e9, s\u00e9par\u00e9s par des \"&\". Exemple : \"Arch\u00e9ologiquement complet\", \"absent\", \"perdu\", etc.\r\nPeut \u00e9galement qualifier (selon votre usage) des qualit\u00e9s de fragmentation : \"proximal\", \"distal\", \"fragmentaire\", \"complet&fragmentaire\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Remarquabilit\u00e9",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 29,
+ "description": "Type(s) de remarquabilit\u00e9(s), s\u00e9par\u00e9s par des \"&\". Exemple : \"Mus\u00e9able\", \"Publication\", \"Tessonier & Publication\", etc.\r\nA pr\u00e9ciser dans la typologie ad\u00e9quate pour l'adapter \u00e0 votre usage.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Image",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 36,
+ "description": "Nom exact du fichier image, sous la forme XXXXX.jpg.\r\nAttention au respect strict des caract\u00e8res et majuscules lors d'un import de ce type, \".JPG\" ou \"*.jpg\", etc.\r\nExemple : \"P1030831.JPG\", \"IMG_6485.JPG\", \"fibule.jpg\", etc.\r\nLors de l'import il faut ajouter ces images sous la forme d'un fichier zip (joint au csv import\u00e9) pour que les images soient automatiquement int\u00e9gr\u00e9es.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Date de d\u00e9couverte",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 30,
+ "description": "Date au format JJ/MM/AAAA ou AAAA-MM-JJ. Par exemple : 2017-07-31 ou 31/07/2017.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Marquage",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 31,
+ "description": "Marquage visible sur le mobilier. Exemple : \"id1234 la Roche aux F\u00e9es\", \"MTX-45\", etc.\r\nCeci reproduit d'ordinaire un marquage r\u00e9alis\u00e9 par un arch\u00e9ologue. Il ne s'agit pas ici de reproduire une \u00e9pigraphie ou tout autre inscription arch\u00e9ologique (graffito, d\u00e9dicaces, defixio, etc.) , mais vous pouvez l'utiliser pour cela si vous n'avez pas \u00e0 utiliser de marquage arch\u00e9ologique.\r\nPeut aussi indiquer si un marquage est pr\u00e9sent ou non (oui/non).",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation topographique",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 32,
+ "description": "R\u00e9f\u00e9rence du point topo, d'ordinaire un entier mais peut \u00eatre autre chose, un lieu dit ou autre. Champ texte, max. 120 caract\u00e8res. Exemple : \"7220\", \"pt. 72\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Commentaire g\u00e9n\u00e9ral",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 33,
+ "description": "Commentaire g\u00e9n\u00e9ral en texte libre. Exemple : \"habillage en nid d'abeille, poli g\u00e9n\u00e9ralis\u00e9, encoche emmanchement lat\u00e9ral ouvert sur la face sup\u00e9rieure\", \"1 bord + bec tubulaire\", \"fibule de Langton Down\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Chronologie",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 34,
+ "description": "Chronologies associ\u00e9es (plusieurs possibles s\u00e9par\u00e9es par &). Exemple : \"Gallo-romain & M\u00e9di\u00e9val\", \"GR&MED\", \"M\u00e9solithique final & M\u00e9so moyen & Epipal\", etc.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "datings__period__label"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "CCE / d\u00e9p\u00f4t concern\u00e9",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 35,
+ "description": "Identifiant textuel du d\u00e9p\u00f4t. Cet identifiant doit correspondre \u00e0 un d\u00e9p\u00f4t existant en base de donn\u00e9es, plus pr\u00e9cis\u00e9ment \u00e0 sa clef, exemple : \"cce-49\"",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Mat\u00e9riau(x)",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 17,
+ "description": "Type(s) de mat\u00e9riau(x) s\u00e9par\u00e9s par des \"&\". Exemple : \"m\u00e9tal & os\", \"LT\", \"Min\u00e9ral\", \"Granito\u00efde & Basalte & Ardoise\".",
+ "regexp_pre_filter": null,
+ "required": true,
+ "export_field_name": "material_types__label"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 5",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 7,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la cinqui\u00e8me localisation.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_5"
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 6",
+ "importer_type": [
+ "inventory_combo"
+ ],
+ "col_number": 8,
+ "description": "Localisation dans le d\u00e9p\u00f4t : r\u00e9f\u00e9rence de la sixi\u00e8me localisation.",
+ "regexp_pre_filter": null,
+ "required": false,
+ "export_field_name": "localisation_6"
+ }
+},
+{
"model": "ishtar_common.formatertype",
"fields": {
"formater_type": "IntegerFormater",
@@ -3796,6 +4316,14 @@
}
},
{
+ "model": "ishtar_common.formatertype",
+ "fields": {
+ "formater_type": "TypeFormater",
+ "options": "archaeological_finds.models.ObjectType",
+ "many_split": "&"
+ }
+},
+{
"model": "ishtar_common.importerduplicatefield",
"fields": {
"column": [
@@ -4589,6 +5117,292 @@
}
},
{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 9
+ ],
+ "field_name": "base_finds__context_record__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 9
+ ],
+ "field_name": "base_finds__context_record__parcel__operation__code_patriarche",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 9
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 9
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 11
+ ],
+ "field_name": "base_finds__context_record__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 11
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 11
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 12
+ ],
+ "field_name": "base_finds__context_record__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 12
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 12
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 13
+ ],
+ "field_name": "base_finds__context_record__external_id",
+ "force_new": false,
+ "concat": true,
+ "concat_str": null
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 13
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": true,
+ "concat_str": null
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 13
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": true,
+ "concat_str": null
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 10
+ ],
+ "field_name": "base_finds__context_record__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 10
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 10
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 14
+ ],
+ "field_name": "base_finds__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 14
+ ],
+ "field_name": "base_finds__label",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 14
+ ],
+ "field_name": "external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 1
+ ],
+ "field_name": "container__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 35
+ ],
+ "field_name": "container__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 35
+ ],
+ "field_name": "container__location__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": ""
+ }
+},
+{
"model": "ishtar_common.importtarget",
"fields": {
"column": [
@@ -8667,5 +9481,725 @@
"concat_str": null,
"comment": ""
}
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 9
+ ],
+ "target": "base_finds__context_record__operation__code_patriarche",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "12",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 11
+ ],
+ "target": "base_finds__context_record__parcel__town__numero_insee",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "5",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 12
+ ],
+ "target": "base_finds__context_record__parcel__section",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "4",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 13
+ ],
+ "target": "base_finds__context_record__parcel__parcel_number",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "6",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 10
+ ],
+ "target": "base_finds__context_record__label",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "120",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 14
+ ],
+ "target": "label",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "120",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 1
+ ],
+ "target": "container__reference",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "30",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 2
+ ],
+ "target": "container__container_type",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_warehouse.models.ContainerType",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 3
+ ],
+ "target": "set_localisation_1",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 4
+ ],
+ "target": "set_localisation_2",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 5
+ ],
+ "target": "set_localisation_3",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 6
+ ],
+ "target": "set_localisation_4",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 15
+ ],
+ "target": "previous_id",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "120",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 16
+ ],
+ "target": "base_finds__batch",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.BatchType",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 19
+ ],
+ "target": "description",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 20
+ ],
+ "target": "find_number",
+ "regexp_filter": null,
+ "formater_type": [
+ "IntegerFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 21
+ ],
+ "target": "weight",
+ "regexp_filter": null,
+ "formater_type": [
+ "FloatFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 22
+ ],
+ "target": "conservatory_state",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.ConservatoryState",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 25
+ ],
+ "target": "preservation_to_considers",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.TreatmentType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 27
+ ],
+ "target": "conservatory_comment",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 28
+ ],
+ "target": "integrities",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.IntegrityType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 29
+ ],
+ "target": "remarkabilities",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.RemarkabilityType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 36
+ ],
+ "target": "image",
+ "regexp_filter": null,
+ "formater_type": [
+ "FileFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 30
+ ],
+ "target": "base_finds__discovery_date",
+ "regexp_filter": null,
+ "formater_type": [
+ "DateFormater",
+ "%d/%m/%Y | %Y-%m-%d",
+ " | "
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 31
+ ],
+ "target": "mark",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 32
+ ],
+ "target": "base_finds__topographic_localisation",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "120",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 33
+ ],
+ "target": "comment",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 35
+ ],
+ "target": "container__responsible__external_id",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 17
+ ],
+ "target": "material_types",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.MaterialType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 34
+ ],
+ "target": "datings__period",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_operations.models.Period",
+ "&"
+ ],
+ "force_new": true,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 18
+ ],
+ "target": "object_types",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.ObjectType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": "",
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 7
+ ],
+ "target": "set_localisation_5",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 8
+ ],
+ "target": "set_localisation_6",
+ "regexp_filter": null,
+ "formater_type": [
+ "UnicodeFormater",
+ "200",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 23
+ ],
+ "target": "alterations",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.AlterationType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 24
+ ],
+ "target": "alteration_causes",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.AlterationCauseType",
+ "&"
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "inventory_combo",
+ 26
+ ],
+ "target": "treatment_emergency",
+ "regexp_filter": null,
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_finds.models.TreatmentEmergencyType",
+ null
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
}
]
diff --git a/ishtar_common/fixtures/test_towns.json b/ishtar_common/fixtures/test_towns.json
index a88ca6476..d34c10411 100644
--- a/ishtar_common/fixtures/test_towns.json
+++ b/ishtar_common/fixtures/test_towns.json
@@ -7,7 +7,6 @@
"name": "PARIS-1ER-ARRONDISSEMENT",
"center": "POINT (599976.9837326267734170 2429351.2226647692732513)",
"surface": 1810000,
- "canton": null,
"numero_insee": "75101"
}
},
@@ -19,7 +18,6 @@
"name": "LILLE",
"center": "POINT (650348.5204579939600080 2626592.6267738011665642)",
"surface": 34990000,
- "canton": null,
"numero_insee": "59350"
}
}
diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py
new file mode 100644
index 000000000..7ef0e0a38
--- /dev/null
+++ b/ishtar_common/management/commands/import_geofla_csv.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+import csv
+import sys
+
+from django.core.management.base import BaseCommand
+from django.contrib.gis.geos import GEOSGeometry, Point
+
+from ishtar_common.models import Town
+
+
+class Command(BaseCommand):
+ help = 'Import GEOFLA csv'
+
+ def add_arguments(self, parser):
+ parser.add_argument('csv_file')
+ parser.add_argument(
+ '--year', type=int, default=2014, dest='year',
+ help='Default year to affect to the town')
+
+ def handle(self, *args, **options):
+ csv_file = options['csv_file']
+ default_year = options['year']
+ sys.stdout.write('* using year {} as a default\n'.format(default_year))
+ sys.stdout.write('* Opening file {}\n'.format(csv_file))
+ nb_created, nb_changed = 0, 0
+ with open(csv_file, 'rb') as csvfile:
+ reader = csv.DictReader(csvfile)
+ for idx, row in enumerate(reader):
+ sys.stdout.write('Processing town %d.\r' % (idx + 1))
+ sys.stdout.flush()
+ num_insee = row['INSEE_COM']
+ if len(num_insee) < 5:
+ num_insee = '0' + num_insee
+ q = Town.objects.filter(numero_insee=num_insee)
+ created = False
+ if q.count():
+ if q.filter(year=default_year).count():
+ town = q.filter(year=default_year).all()[0]
+ else:
+ town = q.order_by('-year').all()[0]
+ else:
+ created = True
+ nb_created += 1
+ town = Town(name=row['NOM_COM'],
+ numero_insee=num_insee)
+ geom = row['wkt_geom'].upper()
+ if 'MULTI' not in geom:
+ geom = geom.replace('POLYGON', 'MULTIPOLYGON(') + ')'
+ town.limit = GEOSGeometry(geom, srid=2154)
+ if 'X_CENTROID' in row:
+ town.center = Point(float(row['X_CENTROID']),
+ float(row['Y_CENTROID']), srid=2154)
+ else:
+ town.center = None
+ if not town.year and default_year:
+ town.year = default_year
+ if 'SUPERFICIE' in row:
+ town.surface = row['SUPERFICIE']
+ else:
+ town.surface = None
+ if not created:
+ nb_changed += 1
+ town.save()
+ sys.stdout.write('\n* {} town created'.format(nb_created))
+ sys.stdout.write('\n* {} town changed\n'.format(nb_changed))
+ sys.stdout.flush()
+
+
+
diff --git a/ishtar_common/management/commands/import_insee_comm_csv.py b/ishtar_common/management/commands/import_insee_comm_csv.py
new file mode 100644
index 000000000..24eb2013e
--- /dev/null
+++ b/ishtar_common/management/commands/import_insee_comm_csv.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See the file COPYING for details.
+
+import csv
+import re
+import sys
+
+from django.core.management.base import BaseCommand
+
+from ishtar_common.models import Town
+
+
+class Command(BaseCommand):
+ help = 'Import INSEE csv'
+
+ def add_arguments(self, parser):
+ parser.add_argument('csv_file')
+ parser.add_argument(
+ '--year', type=int, default=2015, dest='year',
+ help='Year to affect to new towns')
+
+ def handle(self, *args, **options):
+ csv_file = options['csv_file']
+ default_year = options['year']
+ sys.stdout.write('* using year {} for new towns\n'.format(default_year))
+ sys.stdout.write('* opening file {}\n'.format(csv_file))
+ r = re.compile(r"(.*)\((.*)\)")
+ nb_created = 0
+ nb_link = 0
+ missing = []
+ strange = []
+ linked = set()
+ with open(csv_file, 'rb') as csvfile:
+ reader = csv.DictReader(csvfile)
+ for idx, row in enumerate(reader):
+ sys.stdout.write('Processing town %d.\r' % (idx + 1))
+ sys.stdout.flush()
+
+ old_insee = row['DepComA']
+ if len(old_insee) < 5:
+ old_insee = '0' + old_insee
+ q = Town.objects.filter(numero_insee=old_insee)
+
+ if not q.count():
+ missing.append((old_insee, row['NomCA']))
+ continue
+ if q.count() > 1:
+ q = q.filter(year__lt=default_year).order_by('-year')
+ if not q.count():
+ strange.append((old_insee, row['NomCA']))
+ continue
+ old_town = q.all()[0]
+
+ new_insee = row['DepComN']
+ if len(new_insee) < 5:
+ new_insee = '0' + new_insee
+ q = Town.objects.filter(numero_insee=new_insee,
+ year=default_year)
+ if not q.count():
+ nb_created += 1
+ name = row['NomCN'].decode('utf-8').strip()
+ name = r.sub(r"\2 \1", name).strip()
+ new_town = Town.objects.create(name=name, year=default_year,
+ numero_insee=new_insee)
+ else:
+ new_town = q.all()[0]
+ if new_town in old_town.children.all():
+ continue # link already created
+ nb_link += 1
+ old_town.children.add(new_town)
+ linked.add(new_town)
+ nb_limit = 0
+ sys.stdout.write('\nGenerate limits...'.format(nb_created))
+ for town in linked:
+ if town.generate_geo():
+ nb_limit += 1
+ sys.stdout.write('\n* {} town created\n'.format(nb_created))
+ sys.stdout.write('* {} link created\n'.format(nb_link))
+ sys.stdout.write('* {} limit generated\n'.format(nb_limit))
+ if missing:
+ sys.stdout.write('* theses towns are missing:\n')
+ for insee, name in missing:
+ sys.stdout.write('* {} ({})\n'.format(name, insee))
+ if strange:
+ sys.stdout.write('* theses towns have newer version:\n')
+ for insee, name in strange:
+ sys.stdout.write('* {} ({})\n'.format(name, insee))
+ sys.stdout.flush()
+
+
diff --git a/ishtar_common/migrations/0019_auto_20171026_1827.py b/ishtar_common/migrations/0019_auto_20171026_1827.py
new file mode 100644
index 000000000..854304837
--- /dev/null
+++ b/ishtar_common/migrations/0019_auto_20171026_1827.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-26 18:27
+from __future__ import unicode_literals
+
+import django.contrib.gis.db.models.fields
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0018_auto_20171017_1840'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='jsondatafield',
+ options={'ordering': ['order', 'name'], 'verbose_name': 'Json data - Field', 'verbose_name_plural': 'Json data - Fields'},
+ ),
+ migrations.AlterModelOptions(
+ name='jsondatasection',
+ options={'ordering': ['order', 'name'], 'verbose_name': 'Json data - Menu', 'verbose_name_plural': 'Json data - Menus'},
+ ),
+ migrations.RemoveField(
+ model_name='town',
+ name='canton',
+ ),
+ migrations.AddField(
+ model_name='town',
+ name='limit',
+ field=django.contrib.gis.db.models.fields.MultiPolygonField(blank=True, null=True, srid=4326, verbose_name='Limit'),
+ ),
+ migrations.AlterField(
+ model_name='historicalorganization',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='historicalperson',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='organization',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ migrations.AlterField(
+ model_name='person',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, db_index=True, default={}),
+ ),
+ ]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index c3ba4fdd0..14869e2a5 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -85,6 +85,8 @@ def post_save_user(sender, **kwargs):
except DatabaseError: # manage when db is not synced
pass
IshtarUser.set_superuser(user)
+
+
post_save.connect(post_save_user, sender=User)
@@ -2636,6 +2638,7 @@ class Source(OwnPerms, ImageModel, models.Model):
if getattr(self, attr)]
return slugify(u"-".join(values))
+
if settings.COUNTRY == 'fr':
class Arrondissement(models.Model):
name = models.CharField(u"Nom", max_length=30)
@@ -2654,17 +2657,21 @@ if settings.COUNTRY == 'fr':
(self.name, unicode(self.arrondissement)))
+class TownManager(models.GeoManager):
+ def get_by_natural_key(self, numero_insee, year):
+ return self.get(numero_insee=numero_insee, year=year)
+
+
class Town(Imported, models.Model):
name = models.CharField(_(u"Name"), max_length=100)
surface = models.IntegerField(_(u"Surface (m2)"), blank=True, null=True)
center = models.PointField(_(u"Localisation"), srid=settings.SRID,
blank=True, null=True)
+ limit = models.MultiPolygonField(_(u"Limit"), blank=True, null=True)
if settings.COUNTRY == 'fr':
numero_insee = models.CharField(u"Numéro INSEE", max_length=6)
departement = models.ForeignKey(
Department, verbose_name=u"Département", null=True, blank=True)
- canton = models.ForeignKey(Canton, verbose_name=u"Canton", null=True,
- blank=True)
year = models.IntegerField(
_("Year of creation"), null=True, blank=True,
help_text=_(u"Filling this field is relevant to distinguish old towns "
@@ -2674,7 +2681,7 @@ class Town(Imported, models.Model):
related_name='parents')
cached_label = models.CharField(_(u"Cached name"), max_length=500,
null=True, blank=True, db_index=True)
- objects = models.GeoManager()
+ objects = TownManager()
class Meta:
verbose_name = _(u"Town")
@@ -2683,12 +2690,61 @@ class Town(Imported, models.Model):
ordering = ['numero_insee']
unique_together = (('numero_insee', 'year'),)
+ def natural_key(self):
+ return (self.numero_insee, self.year)
+
def __unicode__(self):
if self.cached_label:
return self.cached_label
self.save()
return self.cached_label
+ def generate_geo(self, force=False):
+ force = self.generate_limit(force=force)
+ self.generate_center(force=force)
+ self.generate_area(force=force)
+
+ def generate_limit(self, force=False):
+ if not force and self.limit:
+ return
+ parents = None
+ if not self.parents.count():
+ return
+ for parent in self.parents.all():
+ if not parent.limit:
+ return
+ if not parents:
+ parents = parent.limit
+ else:
+ parents = parents.union(parent.limit)
+ # if union is a simple polygon make it a multi
+ if 'MULTI' not in parents.wkt:
+ parents = parents.wkt.replace('POLYGON', 'MULTIPOLYGON(') + ")"
+ if not parents:
+ return
+ self.limit = parents
+ self.save()
+ return True
+
+ def generate_center(self, force=False):
+ if not force and (self.center or not self.limit):
+ return
+ self.center = self.limit.centroid
+ if not self.center:
+ return False
+ self.save()
+ return True
+
+ def generate_area(self, force=False):
+ if not force and (self.surface or not self.limit):
+ return
+ self.surface = self.limit.transform(settings.SURFACE_SRID,
+ clone=True).area
+ if not self.surface:
+ return False
+ self.save()
+ return True
+
def _generate_cached_label(self):
cached_label = self.name
if settings.COUNTRY == "fr":
@@ -2698,7 +2754,13 @@ class Town(Imported, models.Model):
return cached_label
-post_save.connect(cached_label_changed, sender=Town)
+def post_save_town(sender, **kwargs):
+ cached_label_changed(sender, **kwargs)
+ town = kwargs['instance']
+ town.generate_geo()
+
+
+post_save.connect(post_save_town, sender=Town)
class OperationType(GeneralType):
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index bbb449fe3..e107bd6fb 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -92,6 +92,9 @@ class TestCase(BaseTestCase):
class CommandsTestCase(TestCase):
+ fixtures = [settings.ROOT_PATH +
+ '../ishtar_common/fixtures/test_towns.json']
+
def test_clean_ishtar(self):
"""
Clean ishtar db
@@ -107,6 +110,53 @@ class CommandsTestCase(TestCase):
self.assertEqual(parcel_nb - 1, Parcel.objects.count())
self.assertEqual(Parcel.objects.filter(pk=p.pk).count(), 0)
+ def test_import_geofla(self):
+ q = models.Town.objects
+ town_nb = q.count()
+ out = StringIO()
+ call_command('import_geofla_csv',
+ '../ishtar_common/tests/geofla-test.csv', stdout=out)
+ self.assertEqual(town_nb + 9, models.Town.objects.count())
+ call_command('import_geofla_csv',
+ '../ishtar_common/tests/geofla-test.csv', stdout=out)
+ # no new town
+ self.assertEqual(town_nb + 9, models.Town.objects.count())
+
+ def test_import_insee(self):
+ q = models.Town.objects
+ town_nb = q.count()
+ first, union_start, union_end = '', '', []
+ for idx, town in enumerate(q.all()):
+ x1 = float(idx) / 10
+ if not x1:
+ x1 = 0
+ x2 = float(idx) / 10 + 0.1
+ l = 'MULTIPOLYGON((({x1} 0.1,{x2} 0.1,{x2} 0,{x1} 0,' \
+ '{x1} 0.1)))'.format(x1=x1, x2=x2)
+ if union_start:
+ union_start += ", "
+ else:
+ first = '{x1} 0.1'.format(x1=x1)
+ union_start += '{x2} 0.1'.format(x1=x1, x2=x2)
+ union_end.append('{x2} 0'.format(x1=x1, x2=x2))
+ town.limit = l
+ town.save()
+ union = 'MULTIPOLYGON (((' + first + ", " + union_start + \
+ ", " + ", ".join(reversed(union_end)) + ", 0 0, " + first + ")))"
+ out = StringIO()
+ call_command('import_insee_comm_csv',
+ '../ishtar_common/tests/insee-test.csv', stdout=out)
+ self.assertEqual(town_nb + 1, models.Town.objects.count())
+ new = models.Town.objects.order_by('-pk').all()[0]
+ self.assertEqual(new.parents.count(), 2)
+
+ self.assertEqual(new.limit.wkt, union)
+
+ call_command('import_insee_comm_csv',
+ '../ishtar_common/tests/insee-test.csv', stdout=out)
+ # no new town
+ self.assertEqual(town_nb + 1, models.Town.objects.count())
+
class WizardTestFormData(object):
"""
diff --git a/ishtar_common/tests/geofla-test.csv b/ishtar_common/tests/geofla-test.csv
new file mode 100644
index 000000000..749901a0c
--- /dev/null
+++ b/ishtar_common/tests/geofla-test.csv
@@ -0,0 +1,10 @@
+wkt_geom,ID_GEOFLA,CODE_COM,INSEE_COM,NOM_COM,STATUT,X_CHF_LIEU,Y_CHF_LIEU,X_CENTROID,Y_CENTROID,Z_MOYEN,SUPERFICIE,POPULATION,CODE_CANT,CODE_ARR,CODE_DEPT,NOM_DEPT,CODE_REG,NOM_REG
+"Polygon ((499484.59999999997671694 6265244.29999999981373549, 499474.79999999998835847 6265269.40000000037252903, 499460.09999999997671694 6265309.5, 499505.90000000002328306 6265894.5, 499739.29999999998835847 6266207.20000000018626451, 500441.5 6265965.59999999962747097, 501199.70000000001164153 6266501.29999999981373549, 501566.90000000002328306 6266822.5, 501750.40000000002328306 6267319.40000000037252903, 501846.09999999997671694 6267413.5, 501891.29999999998835847 6267443.09999999962747097, 501926 6267417.79999999981373549, 502127.29999999998835847 6266995.59999999962747097, 502181.40000000002328306 6266895.20000000018626451, 502435 6266757.29999999981373549, 502585.59999999997671694 6266726.09999999962747097, 502909.70000000001164153 6266663.40000000037252903, 503049.40000000002328306 6266637.29999999981373549, 503114.20000000001164153 6266626.79999999981373549, 503196 6266274.29999999981373549, 503247.70000000001164153 6265864.5, 503107.79999999998835847 6265366.20000000018626451, 503076.29999999998835847 6265180.59999999962747097, 503041.5 6265200.90000000037252903, 502981.5 6265201.40000000037252903, 502680.59999999997671694 6265174.90000000037252903, 502500.5 6265141.40000000037252903, 502450.40000000002328306 6265121.90000000037252903, 502001.40000000002328306 6265306.40000000037252903, 501812.40000000002328306 6265402.90000000037252903, 501653 6265449.09999999962747097, 501568.09999999997671694 6265454.79999999981373549, 501537.20000000001164153 6265340.20000000018626451, 501515.40000000002328306 6265245.5, 501653.59999999997671694 6265043.59999999962747097, 501708.29999999998835847 6265013.09999999962747097, 501963.5 6264951.09999999962747097, 502133.90000000002328306 6265019.59999999962747097, 502148.90000000002328306 6265024.5, 502173.70000000001164153 6264999.29999999981373549, 502173.5 6264979.29999999981373549, 502123 6264904.79999999981373549, 501875.40000000002328306 6264687.09999999962747097, 501724.70000000001164153 6264583.5, 501699.59999999997671694 6264558.70000000018626451, 501693.20000000001164153 6264397.90000000037252903, 501701.59999999997671694 6264198.09999999962747097, 501885.20000000001164153 6264051.70000000018626451, 501927.40000000002328306 6264018.40000000037252903, 502004.40000000002328306 6263974.79999999981373549, 502436.29999999998835847 6263655.5, 502656.40000000002328306 6263573.79999999981373549, 502836.09999999997671694 6263557.29999999981373549, 502985.59999999997671694 6263516.09999999962747097, 502969.59999999997671694 6263395.40000000037252903, 502933.5 6263265.79999999981373549, 502897.79999999998835847 6263176.20000000018626451, 502806.20000000001164153 6263087.09999999962747097, 502771.09999999997671694 6263067.40000000037252903, 502591.29999999998835847 6263066.40000000037252903, 502386.09999999997671694 6263025.59999999962747097, 502234.90000000002328306 6262977.90000000037252903, 502224.59999999997671694 6262947, 502183.29999999998835847 6262782.59999999962747097, 502118.59999999997671694 6262803.09999999962747097, 501643.09999999997671694 6263042.79999999981373549, 501336.59999999997671694 6263186.20000000018626451, 501082.59999999997671694 6263278.20000000018626451, 501057.59999999997671694 6263278.40000000037252903, 501002.29999999998835847 6263238.90000000037252903, 501002.29999999998835847 6263228.90000000037252903, 500851.70000000001164153 6263265.09999999962747097, 500747.29999999998835847 6263316.90000000037252903, 500627.90000000002328306 6263382.79999999981373549, 500598.29999999998835847 6263418, 499637.09999999997671694 6264177.20000000018626451, 499469.59999999997671694 6264649.09999999962747097, 499452.09999999997671694 6264942, 499494.09999999997671694 6265189.29999999981373549, 499489.5 6265239.29999999981373549, 499484.59999999997671694 6265244.29999999981373549))",COMMUNE00000000000000001,216,A32216,LOURTIES-MONBRUN,Commune simple,500820,6264958,500515,6265413,251,966,140,3,3,32,GERS,73,MIDI-PYRENEES
+"Polygon ((514320.79999999998835847 6384320.20000000018626451, 514310.29999999998835847 6384372.20000000018626451, 514432.20000000001164153 6384437.20000000018626451, 514470.70000000001164153 6384485, 514591.90000000002328306 6384643.79999999981373549, 514784.29999999998835847 6384956.90000000037252903, 514820.20000000001164153 6385071.5, 514817.29999999998835847 6385206.40000000037252903, 514782.90000000002328306 6385271.59999999962747097, 514231.59999999997671694 6385801.70000000018626451, 513828 6386380.40000000037252903, 513650.59999999997671694 6386669.09999999962747097, 513626 6386714.29999999981373549, 513576.90000000002328306 6386812.09999999962747097, 513566.79999999998835847 6387282.70000000018626451, 513564 6387545, 513622.5 6387981.59999999962747097, 513652.90000000002328306 6388036.29999999981373549, 513668 6388041.20000000018626451, 513867.29999999998835847 6387984.59999999962747097, 513913.29999999998835847 6387989.20000000018626451, 514656.5 6387382.59999999962747097, 515152.70000000001164153 6386972.90000000037252903, 515599.59999999997671694 6386658.5, 515868.90000000002328306 6386486.40000000037252903, 515934.40000000002328306 6386550.79999999981373549, 516216.09999999997671694 6386783.20000000018626451, 516600.20000000001164153 6386719.09999999962747097, 516654.90000000002328306 6386698.59999999962747097, 516898.5 6386556.79999999981373549, 516992.90000000002328306 6386496, 516981 6386266.40000000037252903, 516939.20000000001164153 6386036.90000000037252903, 516922.70000000001164153 6385857.20000000018626451, 516951.90000000002328306 6385766.09999999962747097, 517158.29999999998835847 6385412.20000000018626451, 517340.20000000001164153 6385118.5, 517389.59999999997671694 6385053.09999999962747097, 517448.70000000001164153 6384951.70000000018626451, 517448.59999999997671694 6384941.79999999981373549, 517423.5 6384932, 517363 6384862.5, 517246.90000000002328306 6384718.59999999962747097, 516952.40000000002328306 6384261.5, 516906.70000000001164153 6384172, 516875.29999999998835847 6384002.40000000037252903, 516943.5 6383904.59999999962747097, 517033.70000000001164153 6383800.59999999962747097, 517137.5 6383695.59999999962747097, 517152.40000000002328306 6383675.40000000037252903, 517152.70000000001164153 6383590.79999999981373549, 516792.20000000001164153 6383498.5, 515450.09999999997671694 6383450.79999999981373549, 515334.59999999997671694 6383382.70000000018626451, 515304.09999999997671694 6383361.40000000037252903, 515249.90000000002328306 6383397.5, 514340 6384271.29999999981373549, 514320.79999999998835847 6384320.20000000018626451))",COMMUNE00000000000000002,33,A47033,BOUDY-DE-BEAUREGARD,Commune simple,516424,6384852,515575,6385938,112,1019,414,10,3,47,LOT-ET-GARONNE,72,AQUITAINE
+"Polygon ((473151.90000000002328306 6280675.40000000037252903, 473183 6280709.29999999981373549, 473236.5 6280726, 473730.70000000001164153 6280604.70000000018626451, 474721.20000000001164153 6280442.20000000018626451, 474752.29999999998835847 6280446.59999999962747097, 474783.5 6280395.40000000037252903, 474744.59999999997671694 6279870, 474491.90000000002328306 6279632.40000000037252903, 474451.40000000002328306 6279567.79999999981373549, 474436 6279517, 474458 6279152.20000000018626451, 474558.29999999998835847 6278958.59999999962747097, 474714.79999999998835847 6278804.40000000037252903, 474764.09999999997671694 6278729.09999999962747097, 474768.90000000002328306 6278704.09999999962747097, 474853 6278603.5, 474872.5 6278542.40000000037252903, 474850.79999999998835847 6278452.59999999962747097, 474780.79999999998835847 6278453.20000000018626451, 474124.20000000001164153 6278395.29999999981373549, 473404.40000000002328306 6278341.70000000018626451, 473344.20000000001164153 6278317.29999999981373549, 472941.90000000002328306 6278110.79999999981373549, 472906.70000000001164153 6278081.09999999962747097, 472830.90000000002328306 6277976.90000000037252903, 472805.70000000001164153 6277942.09999999962747097, 472607.59999999997671694 6277500.20000000018626451, 472070.20000000001164153 6276868, 472283 6276706, 472330.90000000002328306 6276681.29999999981373549, 472287.40000000002328306 6276631.79999999981373549, 472277.40000000002328306 6276631.90000000037252903, 471168.40000000002328306 6276890.90000000037252903, 471055.40000000002328306 6276907.09999999962747097, 471066 6277038.5, 471171.79999999998835847 6278227.29999999981373549, 471324.29999999998835847 6278436.90000000037252903, 471400.20000000001164153 6278551.09999999962747097, 471405.59999999997671694 6278596, 471401.70000000001164153 6278730.90000000037252903, 471398 6278775.90000000037252903, 471374.5 6278945.90000000037252903, 471335.70000000001164153 6279087.09999999962747097, 471286.40000000002328306 6279162.40000000037252903, 470741.59999999997671694 6279722.29999999981373549, 470691.79999999998835847 6279747.70000000018626451, 470722.40000000002328306 6279817.40000000037252903, 471042.29999999998835847 6279849.70000000018626451, 471200.90000000002328306 6279703.59999999962747097, 471625.20000000001164153 6279686.59999999962747097, 472102.79999999998835847 6279800, 472474.90000000002328306 6280584.09999999962747097, 473085.70000000001164153 6280646, 473151.90000000002328306 6280675.40000000037252903))",COMMUNE00000000000000003,9,A32009,ARMOUS-ET-CAU,Commune simple,472979,6278963,473004,6278937,220,932,99,16,3,32,GERS,73,MIDI-PYRENEES
+"Polygon ((902581.5 6453999, 902580.5 6453884.09999999962747097, 902549 6453699.59999999962747097, 902450 6453106, 902361.5 6452523.79999999981373549, 902293.40000000002328306 6452092.29999999981373549, 901973.5 6451954.20000000018626451, 901783 6451875.90000000037252903, 901177.69999999995343387 6451336.59999999962747097, 900649.90000000002328306 6450571.79999999981373549, 900470.19999999995343387 6449893.40000000037252903, 900403.40000000002328306 6449566.90000000037252903, 900346 6449272.59999999962747097, 899983.90000000002328306 6448180.79999999981373549, 899846.69999999995343387 6447906.20000000018626451, 899730.59999999997671694 6447652.40000000037252903, 899705 6447582.70000000018626451, 899605.19999999995343387 6447588.59999999962747097, 898604.40000000002328306 6447733.79999999981373549, 897908.5 6447909.90000000037252903, 897838.59999999997671694 6447915.5, 897470.59999999997671694 6447824.79999999981373549, 896902 6447626.79999999981373549, 896811.90000000002328306 6447597.59999999962747097, 896671.90000000002328306 6447582.79999999981373549, 896297.09999999997671694 6447571, 896082.30000000004656613 6447566.90000000037252903, 896012.40000000002328306 6447572.5, 895982.69999999995343387 6447602.70000000018626451, 895888.80000000004656613 6447718.40000000037252903, 895883.90000000002328306 6447738.40000000037252903, 895867.5 6448273.09999999962747097, 895868.59999999997671694 6448397.90000000037252903, 895937.40000000002328306 6448996.90000000037252903, 895928.59999999997671694 6449917, 895890.40000000002328306 6450242, 895893.59999999997671694 6450731.5, 895965.90000000002328306 6451814.90000000037252903, 895976.5 6451889.79999999981373549, 896013.5 6452129.20000000018626451, 896131.09999999997671694 6452558.79999999981373549, 896182.69999999995343387 6452743.20000000018626451, 896339.69999999995343387 6453111.5, 896607.80000000004656613 6453619.79999999981373549, 896709.5 6453828.70000000018626451, 896755.30000000004656613 6453933.20000000018626451, 896974.30000000004656613 6454536.70000000018626451, 897019.5 6454681.20000000018626451, 897554.69999999995343387 6454757.5, 897674.69999999995343387 6454766.5, 897739.59999999997671694 6454765.90000000037252903, 898148.80000000004656613 6454598.59999999962747097, 898397.69999999995343387 6454496.5, 898536 6454200.59999999962747097, 898869.80000000004656613 6454023.79999999981373549, 899078.09999999997671694 6453927.20000000018626451, 899467.59999999997671694 6453904.90000000037252903, 899684 6454093.90000000037252903, 900312.30000000004656613 6454327.09999999962747097, 900739.59999999997671694 6454281.59999999962747097, 901024.09999999997671694 6454249.20000000018626451, 901492.80000000004656613 6454151.20000000018626451, 902037.30000000004656613 6454032.70000000018626451, 902486.59999999997671694 6453999.79999999981373549, 902581.5 6453999))",COMMUNE00000000000000004,225,A38225,MEAUDRE,Commune simple,898640,6450689,898625,6451597,1150,3371,1368,7,1,38,ISERE,82,RHONE-ALPES
+"Polygon ((639510.5 7027545, 639456.59999999997671694 7027671.40000000037252903, 639447 7027726.40000000037252903, 639262.5 7028183.29999999981373549, 639044.19999999995343387 7028677.90000000037252903, 638869.69999999995343387 7028842.79999999981373549, 638699.90000000002328306 7028859.20000000018626451, 638656.40000000002328306 7029039.5, 638472 7029691.70000000018626451, 638461.09999999997671694 7029711.79999999981373549, 638472.19999999995343387 7029721.70000000018626451, 638967.40000000002328306 7030363.70000000018626451, 639422.59999999997671694 7031183.59999999962747097, 639552.09999999997671694 7031440.79999999981373549, 639620.80000000004656613 7031509.20000000018626451, 639868.30000000004656613 7031683.79999999981373549, 639805.69999999995343387 7031770.5, 639885.40000000002328306 7031833.59999999962747097, 639915.69999999995343387 7031767.59999999962747097, 639970 7031692.20000000018626451, 640049.30000000004656613 7031611.59999999962747097, 640143.69999999995343387 7031535.79999999981373549, 640626.59999999997671694 7031200.90000000037252903, 640671.40000000002328306 7031175.5, 640727.09999999997671694 7031140.09999999962747097, 640738.40000000002328306 7031115.79999999981373549, 640771.19999999995343387 7031044.79999999981373549, 640810.09999999997671694 7030909.5, 640867.69999999995343387 7030628.20000000018626451, 640921.19999999995343387 7030452.79999999981373549, 641232.40000000002328306 7030495.20000000018626451, 641859.40000000002328306 7030644.79999999981373549, 641944.5 7030669.09999999962747097, 641954.5 7030664, 641985.80000000004656613 7030578.5, 641924.59999999997671694 7030558.20000000018626451, 641847.30000000004656613 7030516.09999999962747097, 641757.09999999997671694 7030370.79999999981373549, 641679.5 7030175.59999999962747097, 641753.19999999995343387 7029905.09999999962747097, 641976 7029056.59999999962747097, 642026.09999999997671694 7029071.20000000018626451, 642040.90000000002328306 7029046.09999999962747097, 642080 7028940.79999999981373549, 642162.69999999995343387 7028670.20000000018626451, 642008.59999999997671694 7028120.29999999981373549, 641894 7027616, 641888.69999999995343387 7027591, 641779 7027611.90000000037252903, 640623.90000000002328306 7027781.5, 639565.59999999997671694 7027559.5, 639510.5 7027545))",COMMUNE00000000000000005,890,A62890,WILLEMAN,Commune simple,640049,7028672,640115,7029900,79,1023,179,6,4,62,PAS-DE-CALAIS,31,NORD-PAS-DE-CALAIS
+"Polygon ((825043.59999999997671694 6910068.79999999981373549, 825073.40000000002328306 6910053.59999999962747097, 825232.19999999995343387 6909926.29999999981373549, 825484.90000000002328306 6908926.20000000018626451, 825302.80000000004656613 6908645.20000000018626451, 824991.19999999995343387 6908263.29999999981373549, 824578 6907962.59999999962747097, 824246 6907678, 824180.40000000002328306 6907610.59999999962747097, 824089.80000000004656613 6907495.79999999981373549, 824074.90000000002328306 6907471.29999999981373549, 824071.80000000004656613 6907487, 824048.40000000002328306 6907531.79999999981373549, 823749.19999999995343387 6907605.29999999981373549, 823444.90000000002328306 6907657.90000000037252903, 823049.30000000004656613 6907677.20000000018626451, 823044.80000000004656613 6907742.20000000018626451, 823056.40000000002328306 6907817.09999999962747097, 823149.40000000002328306 6908166.09999999962747097, 823387.09999999997671694 6908379, 823469.09999999997671694 6908628.09999999962747097, 823366.5 6908894.79999999981373549, 823225.59999999997671694 6909245.79999999981373549, 823109.59999999997671694 6909411.79999999981373549, 822997.80000000004656613 6909488.70000000018626451, 822823.59999999997671694 6909575.09999999962747097, 822704.5 6909666.09999999962747097, 822630.09999999997671694 6909741.70000000018626451, 822590.80000000004656613 6909818, 822566.40000000002328306 6909883.09999999962747097, 822620.69999999995343387 6910101.40000000037252903, 822625.09999999997671694 6910161.29999999981373549, 822973 6910103.5, 823568.30000000004656613 6910004.40000000037252903, 823855.19999999995343387 6909901.40000000037252903, 824062.69999999995343387 6909771.70000000018626451, 824604.80000000004656613 6909712.79999999981373549, 825038.30000000004656613 6909969.20000000018626451, 825047.80000000004656613 6910023.59999999962747097, 825043.59999999997671694 6910068.79999999981373549))",COMMUNE00000000000000006,18,A8018,ARDEUIL-ET-MONTFAUXELLES,Commune simple,824246,6908952,824391,6908954,125,438,83,1,4,8,ARDENNES,21,CHAMPAGNE-ARDENNE
+"Polygon ((459389.29999999998835847 6300394.70000000018626451, 459349.70000000001164153 6300440, 459102.5 6300742.70000000018626451, 459092.59999999997671694 6300762.79999999981373549, 459078.20000000001164153 6300827.90000000037252903, 459073.79999999998835847 6300902.79999999981373549, 459125 6301057.20000000018626451, 459077.20000000001164153 6302020, 459323.09999999997671694 6302713.5, 459367.70000000001164153 6302768.70000000018626451, 459576.5 6302950.70000000018626451, 460000.5 6303159.79999999981373549, 460457.29999999998835847 6303307.40000000037252903, 461029.40000000002328306 6303519.90000000037252903, 461030 6303589.90000000037252903, 461040.40000000002328306 6303644.70000000018626451, 461092.40000000002328306 6303774.20000000018626451, 461117.79999999998835847 6303823.90000000037252903, 461173.59999999997671694 6303918.29999999981373549, 461356.5 6304171.59999999962747097, 461427 6304211, 461446.40000000002328306 6304170.79999999981373549, 461393.79999999998835847 6303976.5, 461826.09999999997671694 6303096.79999999981373549, 461987.59999999997671694 6302985.59999999962747097, 462193.09999999997671694 6302778.09999999962747097, 462193 6302773.09999999962747097, 462167.5 6302708.40000000037252903, 462166.59999999997671694 6302416.20000000018626451, 462255.20000000001164153 6301471.90000000037252903, 462322.59999999997671694 6301013, 462441.79999999998835847 6300600.29999999981373549, 462590.20000000001164153 6300424.20000000018626451, 462408.20000000001164153 6300160, 461573.90000000002328306 6299778.29999999981373549, 461533.90000000002328306 6299768.59999999962747097, 461493.90000000002328306 6299764, 461324.40000000002328306 6299805.29999999981373549, 461239.79999999998835847 6299842, 461195.09999999997671694 6299877.29999999981373549, 460279.40000000002328306 6300401.40000000037252903, 459888.29999999998835847 6300359.09999999962747097, 459543.29999999998835847 6300292.59999999962747097, 459424 6300364.5, 459389.29999999998835847 6300394.70000000018626451))",COMMUNE00000000000000007,113,A32113,CRAVENCERES,Commune simple,461332,6300782,460721,6302268,133,919,99,12,2,32,GERS,73,MIDI-PYRENEES
+"Polygon ((746161.40000000002328306 6791877.40000000037252903, 746181.30000000004656613 6791872.20000000018626451, 747049.09999999997671694 6791670.09999999962747097, 747813.69999999995343387 6791693.5, 747823.69999999995343387 6791693.40000000037252903, 747818.30000000004656613 6791638.5, 747793 6791608.70000000018626451, 747872.40000000002328306 6791410.79999999981373549, 748249.80000000004656613 6791079.70000000018626451, 748594.69999999995343387 6791031.70000000018626451, 748912.19999999995343387 6791004.70000000018626451, 748947.19999999995343387 6791014.29999999981373549, 749067 6791003.29999999981373549, 749316.59999999997671694 6790976.20000000018626451, 749371.5 6790965.79999999981373549, 749416.19999999995343387 6790930.40000000037252903, 749623.69999999995343387 6790653.79999999981373549, 749752.09999999997671694 6790477.90000000037252903, 749859.5 6790182.20000000018626451, 749948.69999999995343387 6790091.5, 749847 6789882.5, 749734.69999999995343387 6789009, 749742.09999999997671694 6788709.09999999962747097, 749462.19999999995343387 6788701.5, 748716.5 6788552.90000000037252903, 748626.30000000004656613 6788523.70000000018626451, 748540.80000000004656613 6788464.5, 748294 6788226.70000000018626451, 747673 6787477.5, 747607.09999999997671694 6787363.09999999962747097, 747601.90000000002328306 6787333.20000000018626451, 747571.90000000002328306 6787338.5, 747442.69999999995343387 6787424.5, 747363.40000000002328306 6787490.09999999962747097, 747328.80000000004656613 6787535.40000000037252903, 747185.19999999995343387 6787696.5, 747056.19999999995343387 6787802.5, 746956.80000000004656613 6787858.29999999981373549, 746578.5 6788031.40000000037252903, 746038.59999999997671694 6788006, 745500.69999999995343387 6787620.79999999981373549, 744540.59999999997671694 6786944.40000000037252903, 744359.69999999995343387 6786821, 744163.5 6786667.79999999981373549, 744148.40000000002328306 6786647.90000000037252903, 744088.59999999997671694 6786668.40000000037252903, 743447.40000000002328306 6787068.59999999962747097, 742926.69999999995343387 6787532.70000000018626451, 742743.69999999995343387 6787754.09999999962747097, 742773.80000000004656613 6787773.90000000037252903, 743070.40000000002328306 6787981.20000000018626451, 743669.5 6788510.79999999981373549, 744331.80000000004656613 6789134.70000000018626451, 744649.30000000004656613 6789441.90000000037252903, 745196.80000000004656613 6790086.79999999981373549, 745316.30000000004656613 6790230.09999999962747097, 745396.69999999995343387 6790351.09999999962747097, 745553.30000000004656613 6790873.29999999981373549, 745606.5 6791262.5, 745621.80000000004656613 6791297.40000000037252903, 745687.69999999995343387 6791401.70000000018626451, 745713 6791441.5, 745808.90000000002328306 6791555.59999999962747097, 745854.30000000004656613 6791605.20000000018626451, 746025.5 6791763.59999999962747097, 746151.40000000002328306 6791877.5, 746161.40000000002328306 6791877.40000000037252903))",COMMUNE00000000000000008,319,A10319,RIGNY-LE-FERRON,Commune simple,746925,6790005,747181,6789569,167,1904,366,1,3,10,AUBE,21,CHAMPAGNE-ARDENNE
+"Polygon ((1025470.19999999995343387 6314583.90000000037252903, 1025439.69999999995343387 6314639.09999999962747097, 1025445.5 6314740, 1025460.69999999995343387 6314764.79999999981373549, 1025628.59999999997671694 6315035.40000000037252903, 1025728.69999999995343387 6315248, 1025790.80000000004656613 6315497.20000000018626451, 1025790.40000000002328306 6315568.09999999962747097, 1025727.40000000002328306 6315798.40000000037252903, 1025597.40000000002328306 6315898.40000000037252903, 1025432.80000000004656613 6315924.79999999981373549, 1025428.19999999995343387 6315969.79999999981373549, 1025320.59999999997671694 6317270.40000000037252903, 1025427.59999999997671694 6318435.29999999981373549, 1025209.80000000004656613 6318776.79999999981373549, 1025086 6319012.59999999962747097, 1025196.30000000004656613 6319864.40000000037252903, 1025185.40000000002328306 6320572.20000000018626451, 1025191.30000000004656613 6320672, 1025201.69999999995343387 6320726.90000000037252903, 1025257 6320882.20000000018626451, 1025388.69999999995343387 6321205.79999999981373549, 1025506 6321485.40000000037252903, 1025853.5 6321934, 1025869.59999999997671694 6322058.70000000018626451, 1025934.40000000002328306 6322048.20000000018626451, 1026438.40000000002328306 6321875, 1027598.59999999997671694 6321922.79999999981373549, 1027698.59999999997671694 6321933, 1027773.5 6321932.29999999981373549, 1027798.5 6321927.09999999962747097, 1027808.69999999995343387 6321897, 1027772.40000000002328306 6321687.59999999962747097, 1027766.90000000002328306 6321631.70000000018626451, 1027726.5 6321577.09999999962747097, 1027701.09999999997671694 6321532.40000000037252903, 1027696.59999999997671694 6321472.5, 1027725.5 6321342.29999999981373549, 1027739.90000000002328306 6321282.29999999981373549, 1027813.30000000004656613 6320986.90000000037252903, 1027922.19999999995343387 6320871.09999999962747097, 1027997.5 6320805.5, 1028003.90000000002328306 6320160.09999999962747097, 1027701.90000000002328306 6319486.20000000018626451, 1027552.30000000004656613 6319118.09999999962747097, 1027525.59999999997671694 6319004.59999999962747097, 1027510.5 6318897.70000000018626451, 1027520.80000000004656613 6318822.70000000018626451, 1027568.59999999997671694 6318716.20000000018626451, 1027624 6318622, 1027960.5 6318451.59999999962747097, 1028233.69999999995343387 6318428.90000000037252903, 1028569.19999999995343387 6318229.70000000018626451, 1028886.19999999995343387 6317989.70000000018626451, 1029346.09999999997671694 6317226.5, 1029402.09999999997671694 6316951.29999999981373549, 1029435.40000000002328306 6316488.40000000037252903, 1029585.40000000002328306 6315445.29999999981373549, 1029591.09999999997671694 6315420.29999999981373549, 1029545.19999999995343387 6315415.70000000018626451, 1028943.40000000002328306 6315144.20000000018626451, 1027771.30000000004656613 6314755.79999999981373549, 1027671.59999999997671694 6314781.59999999962747097, 1027561.59999999997671694 6314766.59999999962747097, 1027346.40000000002328306 6314723.5, 1027291.09999999997671694 6314684, 1027035.69999999995343387 6314600.29999999981373549, 1026916.30000000004656613 6314576.90000000037252903, 1026751 6314573.40000000037252903, 1026205.59999999997671694 6314627.90000000037252903, 1025561.19999999995343387 6314668.29999999981373549, 1025514.30000000004656613 6314629.59999999962747097, 1025470.19999999995343387 6314583.90000000037252903))",COMMUNE00000000000000009,97,A6097,PIERREFEU,Commune simple,1028827,6315717,1027327,6316879,752,2217,282,26,2,6,ALPES-MARITIMES,93,PROVENCE-ALPES-COTE D'AZUR
diff --git a/ishtar_common/tests/insee-test.csv b/ishtar_common/tests/insee-test.csv
new file mode 100644
index 000000000..8845908ba
--- /dev/null
+++ b/ishtar_common/tests/insee-test.csv
@@ -0,0 +1,3 @@
+DepComN,NomCN,DepComA,NomCA,ChefLieu,ComDLG,Date1,Date2,Date3
+01015,Arboys en Bugey,75101,Arbignieu,O,O,29/09/2015,,24/12/2015
+01015,Arboys en Bugey,59350,Saint-Bois,N,O,,,