summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-26 15:05:09 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-26 15:05:09 +0200
commit8801ab7b7e655d8b831e535381eeea8adc091989 (patch)
treefd1cfe512c94affdfae65e7ec3078648eabffbd7 /ishtar_common
parentc42486f81b042d18b9cf825da9f35a83e00bc051 (diff)
parent005f3962ab8d0eef66de6dd335f619702107116a (diff)
downloadIshtar-8801ab7b7e655d8b831e535381eeea8adc091989.tar.bz2
Ishtar-8801ab7b7e655d8b831e535381eeea8adc091989.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/data_importer.py6
-rw-r--r--ishtar_common/fixtures/initial_data-fr.json46
-rw-r--r--ishtar_common/fixtures/initial_importtypes-fr.json402
-rw-r--r--ishtar_common/tests.py26
-rw-r--r--ishtar_common/wizards.py4
5 files changed, 448 insertions, 36 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index e11e72449..3bb65fc21 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -1415,8 +1415,7 @@ class Importer(object):
if attribute != '__force_new':
self.get_field(cls, attribute, data, m2ms, c_c_path,
new_created)
- except (ValueError, IntegrityError) as e:
- message = e.message
+ except (ValueError, IntegrityError, FieldDoesNotExist) as e:
try:
message = e.message.decode('utf-8')
except (UnicodeDecodeError, UnicodeDecodeError):
@@ -1538,6 +1537,9 @@ class Importer(object):
if m2ms:
# force post save script
obj.save()
+ if hasattr(obj, 'fix'):
+ # post save/m2m specific fix
+ obj.fix()
except IntegrityError as e:
message = e.message
try:
diff --git a/ishtar_common/fixtures/initial_data-fr.json b/ishtar_common/fixtures/initial_data-fr.json
index 9255c604e..b4447559e 100644
--- a/ishtar_common/fixtures/initial_data-fr.json
+++ b/ishtar_common/fixtures/initial_data-fr.json
@@ -212,6 +212,7 @@
83,
84,
78,
+ 54,
58,
59,
60,
@@ -337,26 +338,27 @@
"txt_idx": "head_scientist",
"groups": [
1,
+ 40,
+ 41,
+ 42,
+ 46,
+ 47,
+ 48,
50,
+ 54,
+ 58,
+ 59,
+ 60,
+ 63,
70,
71,
72,
- 41,
74,
77,
- 46,
- 47,
- 48,
- 40,
+ 78,
82,
83,
- 84,
- 78,
- 58,
- 59,
- 60,
- 42,
- 63
+ 84
],
"label": "Responsable scientifique"
}
@@ -1155,5 +1157,25 @@
"txt_idx": "a6",
"label": "A6"
}
+ },
+ {
+ "pk": 2,
+ "model": "ishtar_common.documenttemplate",
+ "fields": {
+ "associated_object_name": "archaeological_operations.models.AdministrativeAct",
+ "available": true,
+ "name": "Accus\u00e9 de r\u00e9ception d'un dossier",
+ "template": "upload/templates/ISHTAR_FILE_ACT_AR_Neutre_1.odt"
+ }
+ },
+ {
+ "pk": 1,
+ "model": "ishtar_common.documenttemplate",
+ "fields": {
+ "associated_object_name": "archaeological_operations.models.AdministrativeAct",
+ "available": true,
+ "name": "Document de r\u00e9f\u00e9rence",
+ "template": "upload/templates/document_reference.odt"
+ }
}
] \ No newline at end of file
diff --git a/ishtar_common/fixtures/initial_importtypes-fr.json b/ishtar_common/fixtures/initial_importtypes-fr.json
index 115f6a985..3b43f0003 100644
--- a/ishtar_common/fixtures/initial_importtypes-fr.json
+++ b/ishtar_common/fixtures/initial_importtypes-fr.json
@@ -150,6 +150,23 @@
}
},
{
+ "pk": 23,
+ "model": "ishtar_common.importertype",
+ "fields": {
+ "description": "Importeur de mobilier + parcelles et UE",
+ "created_models": [
+ 9,
+ 7
+ ],
+ "is_template": true,
+ "unicity_keys": "external_id",
+ "users": [],
+ "slug": "ishtar_finds_parcels_and_cr",
+ "associated_models": 12,
+ "name": "Ishtar - Mobilier_COMBO"
+ }
+ },
+ {
"pk": 17,
"model": "ishtar_common.importertype",
"fields": {
@@ -305,14 +322,6 @@
}
},
{
- "pk": 20,
- "model": "ishtar_common.importerdefault",
- "fields": {
- "importer_type": 3,
- "target": "authors"
- }
- },
- {
"pk": 1,
"model": "ishtar_common.importerdefault",
"fields": {
@@ -354,11 +363,10 @@
},
{
"pk": 26,
- "model": "ishtar_common.importerdefaultvalues",
+ "model": "ishtar_common.importerdefault",
"fields": {
- "default_target": 20,
- "target": "author_type",
- "value": "main_author"
+ "importer_type": 19,
+ "target": "public_domain"
}
},
{
@@ -407,6 +415,15 @@
}
},
{
+ "pk": 32,
+ "model": "ishtar_common.importerdefaultvalues",
+ "fields": {
+ "default_target": 26,
+ "target": "public_domain",
+ "value": "False"
+ }
+ },
+ {
"pk": 336,
"model": "ishtar_common.importercolumn",
"fields": {
@@ -888,6 +905,84 @@
}
},
{
+ "pk": 391,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 1,
+ "description": "Code PATRIARCHE ou code num\u00e9rique (entier) UNIQUE pour une op\u00e9ration.",
+ "regexp_pre_filter": null,
+ "required": true,
+ "label": "Code op\u00e9ration",
+ "importer_type": 23,
+ "export_field_name": "base_finds__context_record__operation__code_patriarche"
+ }
+ },
+ {
+ "pk": 392,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 2,
+ "description": "Commune (via num\u00e9ro INSEE).",
+ "regexp_pre_filter": null,
+ "required": true,
+ "label": "INSEE",
+ "importer_type": 23,
+ "export_field_name": "base_finds__context_record__parcel__town__numero_insee"
+ }
+ },
+ {
+ "pk": 393,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 3,
+ "description": "Section (identifiant externe), soit des lettres formant la section . Exemple : \"ZA\".",
+ "regexp_pre_filter": null,
+ "required": true,
+ "label": "Section de parcellaire",
+ "importer_type": 23,
+ "export_field_name": "base_finds__context_record__parcel__section"
+ }
+ },
+ {
+ "pk": 394,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 4,
+ "description": "Num\u00e9ro de la parcelle, soit des chiffres sans espaces. Exemple : \"253\".",
+ "regexp_pre_filter": null,
+ "required": true,
+ "label": "Num\u00e9ro de parcelle",
+ "importer_type": 23,
+ "export_field_name": "base_finds__context_record__parcel__parcel_number"
+ }
+ },
+ {
+ "pk": 395,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 5,
+ "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,
+ "label": "Label UE",
+ "importer_type": 23,
+ "export_field_name": "base_finds__context_record__label"
+ }
+ },
+ {
+ "pk": 396,
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "col_number": 6,
+ "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,
+ "label": "Label mobilier",
+ "importer_type": 23,
+ "export_field_name": "label"
+ }
+ },
+ {
"pk": 265,
"model": "ishtar_common.importercolumn",
"fields": {
@@ -4676,6 +4771,76 @@
}
},
{
+ "pk": 417,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__external_id",
+ "column": 392,
+ "formater_type": 28,
+ "concat_str": "-",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 421,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__label",
+ "column": 396,
+ "formater_type": 3,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 419,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__external_id",
+ "column": 394,
+ "formater_type": 35,
+ "concat_str": "-",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 423,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__parcel__section",
+ "column": 393,
+ "formater_type": 7,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 425,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__parcel__town__numero_insee",
+ "column": 337,
+ "formater_type": 28,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
"pk": 396,
"model": "ishtar_common.importtarget",
"fields": {
@@ -5082,6 +5247,20 @@
}
},
{
+ "pk": 416,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__external_id",
+ "column": 391,
+ "formater_type": 11,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
"pk": 310,
"model": "ishtar_common.importtarget",
"fields": {
@@ -5250,6 +5429,34 @@
}
},
{
+ "pk": 418,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__external_id",
+ "column": 393,
+ "formater_type": 35,
+ "concat_str": "-",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 420,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__external_id",
+ "column": 395,
+ "formater_type": 3,
+ "concat_str": "-",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
"pk": 355,
"model": "ishtar_common.importtarget",
"fields": {
@@ -5278,6 +5485,34 @@
}
},
{
+ "pk": 422,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__parcel__town__numero_insee",
+ "column": 392,
+ "formater_type": 11,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 424,
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "comment": "",
+ "target": "base_finds__context_record__parcel__parcel_number",
+ "column": 394,
+ "formater_type": 8,
+ "concat_str": "",
+ "regexp_filter": null,
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
"pk": 352,
"model": "ishtar_common.importtarget",
"fields": {
@@ -6258,5 +6493,148 @@
"concat": false,
"force_new": false
}
+ },
+ {
+ "pk": 54,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 391,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 55,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 391,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 56,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 392,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 57,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 392,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 58,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 393,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 59,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 393,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 62,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 395,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 63,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 395,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 64,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 396,
+ "concat_str": "",
+ "field_name": "label",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 65,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 396,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 66,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 396,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 60,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 394,
+ "concat_str": "-",
+ "field_name": "base_finds__external_id",
+ "concat": false,
+ "force_new": false
+ }
+ },
+ {
+ "pk": 61,
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": 394,
+ "concat_str": "-",
+ "field_name": "external_id",
+ "concat": false,
+ "force_new": false
+ }
}
] \ No newline at end of file
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 536d6d4a8..b862b4ea7 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -69,6 +69,21 @@ class OOOGenerationTest(TestCase):
"""
+COMMON_FIXTURES = [
+ settings.ROOT_PATH + '../fixtures/initial_data-auth-fr.json',
+ settings.ROOT_PATH + '../ishtar_common/fixtures/initial_data-fr.json',
+ settings.ROOT_PATH +
+ '../ishtar_common/fixtures/initial_spatialrefsystem-fr.json',
+ settings.ROOT_PATH +
+ '../ishtar_common/fixtures/initial_importtypes-fr.json',
+ ]
+
+OPERATION_FIXTURES = COMMON_FIXTURES + [
+ settings.ROOT_PATH +
+ '../archaeological_operations/fixtures/initial_data-fr.json'
+]
+
+
def create_superuser():
username = 'username4277'
password = 'dcbqj756456!@%'
@@ -337,16 +352,7 @@ class AccessControlTest(TestCase):
class AdminGenTypeTest(TestCase):
- fixtures = [settings.ROOT_PATH +
- '../fixtures/initial_data-auth-fr.json',
- settings.ROOT_PATH +
- '../ishtar_common/fixtures/initial_data-fr.json',
- settings.ROOT_PATH +
- '../ishtar_common/fixtures/initial_spatialrefsystem-fr.json',
- settings.ROOT_PATH +
- '../ishtar_common/fixtures/initial_importtypes-fr.json',
- settings.ROOT_PATH +
- '../archaeological_operations/fixtures/initial_data-fr.json']
+ fixtures = OPERATION_FIXTURES
gen_models = [
models.OrganizationType, models.PersonType, models.TitleType,
models.AuthorType, models.SourceType, models.OperationType,
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 3f90f8c48..c5158dfcd 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -757,6 +757,10 @@ class Wizard(NamedUrlWizardView):
item.skip_history_when_saving = True
item.save()
+ if hasattr(obj, 'fix'):
+ # post save/m2m specific fix
+ obj.fix()
+
# make the new object a default
if self.current_obj_slug:
self.request.session[self.current_obj_slug] = unicode(obj.pk)