diff options
| -rw-r--r-- | archaeological_finds/models.py | 2 | ||||
| -rw-r--r-- | ishtar_common/fixtures/initial_importtypes-fr.json | 633 | ||||
| -rw-r--r-- | ishtar_common/models.py | 10 | 
3 files changed, 512 insertions, 133 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 1fb92f9d8..8aae745e6 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -195,7 +195,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):                null=True)      volume = models.FloatField(_(u"Volume (l)"), blank=True, null=True)      weight = models.FloatField(_(u"Weight (g)"), blank=True, null=True) -    weight_unit = models.CharField(_(u"Weight unit"), max_length=1, +    weight_unit = models.CharField(_(u"Weight unit"), max_length=4,                                     blank=True, null=True, choices=WEIGHT_UNIT)      find_number = models.IntegerField(_("Find number"), blank=True, null=True)      upstream_treatment = models.ForeignKey("Treatment", blank=True, null=True, diff --git a/ishtar_common/fixtures/initial_importtypes-fr.json b/ishtar_common/fixtures/initial_importtypes-fr.json index cd8e2e611..2b37ecaf9 100644 --- a/ishtar_common/fixtures/initial_importtypes-fr.json +++ b/ishtar_common/fixtures/initial_importtypes-fr.json @@ -44,6 +44,17 @@          }      },       { +        "pk": 5,  +        "model": "ishtar_common.importertype",  +        "fields": { +            "users": [],  +            "is_template": true,  +            "name": "MCC - Mobilier",  +            "associated_models": "archaeological_finds.models.BaseFind",  +            "description": "" +        } +    },  +    {          "pk": 1,           "model": "ishtar_common.regexp",           "fields": { @@ -162,87 +173,87 @@          }      },       { -        "pk": 9,  +        "pk": 15,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 1,  +            "col_number": 2,               "required": true,  -            "importer_type": 2,  +            "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 10,  +        "pk": 17,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 2,  -            "required": true,  -            "importer_type": 2,  +            "col_number": 4,  +            "required": false,  +            "importer_type": 3,               "description": null,  -            "regexp_pre_filter": 1 +            "regexp_pre_filter": null          }      },       { -        "pk": 11,  +        "pk": 18,           "model": "ishtar_common.importercolumn",           "fields": {              "col_number": 5,               "required": false,  -            "importer_type": 2,  +            "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 12,  +        "pk": 19,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 7,  +            "col_number": 6,               "required": false,  -            "importer_type": 2,  +            "importer_type": 3,               "description": null,  -            "regexp_pre_filter": 2 +            "regexp_pre_filter": null          }      },       { -        "pk": 13,  +        "pk": 20,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 9,  +            "col_number": 7,               "required": false,  -            "importer_type": 2,  +            "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 14,  +        "pk": 21,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 1,  -            "required": true,  +            "col_number": 8,  +            "required": false,               "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 15,  +        "pk": 22,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 2,  -            "required": true,  +            "col_number": 9,  +            "required": false,               "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 17,  +        "pk": 23,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 4,  +            "col_number": 12,               "required": false,               "importer_type": 3,               "description": null,  @@ -250,10 +261,10 @@          }      },       { -        "pk": 18,  +        "pk": 24,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 5,  +            "col_number": 13,               "required": false,               "importer_type": 3,               "description": null,  @@ -261,10 +272,10 @@          }      },       { -        "pk": 19,  +        "pk": 25,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 6,  +            "col_number": 16,               "required": false,               "importer_type": 3,               "description": null,  @@ -272,68 +283,222 @@          }      },       { -        "pk": 20,  +        "pk": 16,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 7,  -            "required": false,  +            "col_number": 3,  +            "required": true,               "importer_type": 3,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 21,  +        "pk": 5,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 8,  -            "required": false,  -            "importer_type": 3,  +            "col_number": 6,  +            "required": true,  +            "importer_type": 1,               "description": null,               "regexp_pre_filter": null          }      },       { -        "pk": 22,  +        "pk": 37,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 9,  +            "col_number": 2,  +            "required": true,  +            "importer_type": 5,  +            "description": "identifiant externe",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 38,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 3,               "required": false,  -            "importer_type": 3,  -            "description": null,  +            "importer_type": 5,  +            "description": "Isol\u00e9 ou non",               "regexp_pre_filter": null          }      },       { -        "pk": 23,  +        "pk": 39,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 7,  +            "required": false,  +            "importer_type": 5,  +            "description": "Sous classe de mat\u00e9riaux",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 40,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 10,  +            "required": false,  +            "importer_type": 5,  +            "description": "Nombre d'\u00e9l\u00e9ments",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 41,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 11,  +            "required": false,  +            "importer_type": 5,  +            "description": "Poids",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 42,           "model": "ishtar_common.importercolumn",           "fields": {              "col_number": 12,               "required": false,  -            "importer_type": 3,  -            "description": null,  +            "importer_type": 5,  +            "description": "Unit\u00e9 de poids",               "regexp_pre_filter": null          }      },       { -        "pk": 24,  +        "pk": 43,           "model": "ishtar_common.importercolumn",           "fields": {              "col_number": 13,  +            "required": true,  +            "importer_type": 5,  +            "description": "Lien avec l'UE",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 44,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 14,               "required": false,  -            "importer_type": 3,  -            "description": null,  +            "importer_type": 5,  +            "description": "Date de d\u00e9couverte",               "regexp_pre_filter": null          }      },       { -        "pk": 25,  +        "pk": 45,           "model": "ishtar_common.importercolumn",           "fields": {              "col_number": 16,               "required": false,  +            "importer_type": 5,  +            "description": "\u00c9tat de conservation",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 46,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 17,  +            "required": false,  +            "importer_type": 5,  +            "description": "Mesure de conservation",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 47,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 18,  +            "required": false,  +            "importer_type": 5,  +            "description": "Commentaire",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 48,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 20,  +            "required": false,  +            "importer_type": 5,  +            "description": "Localisation topogaphique",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 49,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 21,  +            "required": false,  +            "importer_type": 5,  +            "description": "Int\u00e9r\u00eat sp\u00e9cifique",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 50,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 22,  +            "required": false,  +            "importer_type": 5,  +            "description": "Description",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 9,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 1,  +            "required": true,  +            "importer_type": 2,  +            "description": "Code patriarche de l'op\u00e9ration associ\u00e9e",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 36,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 1,  +            "required": true,  +            "importer_type": 5,  +            "description": "Code patriarche de l'op\u00e9ration associ\u00e9e",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 14,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 1,  +            "required": true,               "importer_type": 3,  -            "description": null,  +            "description": "Code patriarche de l'op\u00e9ration associ\u00e9e",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 1,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 1,  +            "required": true,  +            "importer_type": 1,  +            "description": "Code patriarche",               "regexp_pre_filter": null          }      },  @@ -344,7 +509,40 @@              "col_number": 1,               "required": true,               "importer_type": 4,  -            "description": null,  +            "description": "Code patriarche de l'op\u00e9ration associ\u00e9e",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 10,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 2,  +            "required": true,  +            "importer_type": 2,  +            "description": "Section et num\u00e9ro de parcelle",  +            "regexp_pre_filter": 1 +        } +    },  +    { +        "pk": 11,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 5,  +            "required": false,  +            "importer_type": 2,  +            "description": "Ann\u00e9e",  +            "regexp_pre_filter": null +        } +    },  +    { +        "pk": 13,  +        "model": "ishtar_common.importercolumn",  +        "fields": { +            "col_number": 9,  +            "required": false,  +            "importer_type": 2,  +            "description": "Lieu dit / adresse",               "regexp_pre_filter": null          }      },  @@ -355,7 +553,7 @@              "col_number": 2,               "required": true,               "importer_type": 4,  -            "description": null,  +            "description": "Identifiant externe",               "regexp_pre_filter": null          }      },  @@ -366,7 +564,7 @@              "col_number": 3,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Type",               "regexp_pre_filter": null          }      },  @@ -377,7 +575,7 @@              "col_number": 4,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Description",               "regexp_pre_filter": null          }      },  @@ -388,7 +586,7 @@              "col_number": 5,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Interpr\u00e9tation",               "regexp_pre_filter": null          }      },  @@ -399,7 +597,7 @@              "col_number": 6,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Date d'ouverture",               "regexp_pre_filter": null          }      },  @@ -410,29 +608,29 @@              "col_number": 7,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Date de fermeture",               "regexp_pre_filter": null          }      },       { -        "pk": 33,  +        "pk": 12,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 9,  +            "col_number": 7,               "required": false,  -            "importer_type": 4,  -            "description": null,  -            "regexp_pre_filter": null +            "importer_type": 2,  +            "description": "Commune (via num\u00e9ro INSEE)",  +            "regexp_pre_filter": 2          }      },       { -        "pk": 34,  +        "pk": 33,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 10,  +            "col_number": 8,               "required": false,               "importer_type": 4,  -            "description": null,  +            "description": "Parcelle (identifiant externe)",               "regexp_pre_filter": null          }      },  @@ -443,40 +641,18 @@              "col_number": 11,               "required": false,               "importer_type": 4,  -            "description": null,  -            "regexp_pre_filter": null -        } -    },  -    { -        "pk": 16,  -        "model": "ishtar_common.importercolumn",  -        "fields": { -            "col_number": 3,  -            "required": true,  -            "importer_type": 3,  -            "description": null,  +            "description": "Chronologie (plusieurs possibles s\u00e9par\u00e9es par &)",               "regexp_pre_filter": null          }      },       { -        "pk": 1,  -        "model": "ishtar_common.importercolumn",  -        "fields": { -            "col_number": 1,  -            "required": true,  -            "importer_type": 1,  -            "description": null,  -            "regexp_pre_filter": null -        } -    },  -    { -        "pk": 5,  +        "pk": 34,           "model": "ishtar_common.importercolumn",           "fields": { -            "col_number": 6,  -            "required": true,  -            "importer_type": 1,  -            "description": null,  +            "col_number": 10,  +            "required": false,  +            "importer_type": 4,  +            "description": "Commentaire",               "regexp_pre_filter": null          }      },  @@ -551,16 +727,6 @@          }      },       { -        "pk": 9,  -        "model": "ishtar_common.importtarget",  -        "fields": { -            "column": 9,  -            "formater_type": 1,  -            "target": "operation__operation_code",  -            "regexp_filter": null -        } -    },  -    {          "pk": 10,           "model": "ishtar_common.importtarget",           "fields": { @@ -591,16 +757,6 @@          }      },       { -        "pk": 13,  -        "model": "ishtar_common.importtarget",  -        "fields": { -            "column": 12,  -            "formater_type": 8,  -            "target": "town__numero_insee",  -            "regexp_filter": null -        } -    },  -    {          "pk": 14,           "model": "ishtar_common.importtarget",           "fields": { @@ -611,16 +767,6 @@          }      },       { -        "pk": 15,  -        "model": "ishtar_common.importtarget",  -        "fields": { -            "column": 14,  -            "formater_type": 1,  -            "target": "operation__operation_code",  -            "regexp_filter": null -        } -    },  -    {          "pk": 16,           "model": "ishtar_common.importtarget",           "fields": { @@ -731,16 +877,6 @@          }      },       { -        "pk": 27,  -        "model": "ishtar_common.importtarget",  -        "fields": { -            "column": 26,  -            "formater_type": 1,  -            "target": "operation__operation_code",  -            "regexp_filter": null -        } -    },  -    {          "pk": 28,           "model": "ishtar_common.importtarget",           "fields": { @@ -841,6 +977,196 @@          }      },       { +        "pk": 37,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 36,  +            "formater_type": 1,  +            "target": "context_record__operation__code_patriarche",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 38,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 37,  +            "formater_type": 3,  +            "target": "external_id",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 39,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 38,  +            "formater_type": 19,  +            "target": "is_isolated",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 40,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 39,  +            "formater_type": 20,  +            "target": "find__material_type",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 41,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 40,  +            "formater_type": 1,  +            "target": "find__find_number",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 42,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 41,  +            "formater_type": 21,  +            "target": "find__weight",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 43,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 42,  +            "formater_type": 7,  +            "target": "find__weight_unit",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 44,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 43,  +            "formater_type": 3,  +            "target": "context_record__external_id",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 45,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 44,  +            "formater_type": 5,  +            "target": "discovery_date",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 46,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 45,  +            "formater_type": 22,  +            "target": "find__conservatory_state",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 47,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 46,  +            "formater_type": 23,  +            "target": "find__preservation_to_consider",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 48,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 47,  +            "formater_type": 16,  +            "target": "comment",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 49,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 48,  +            "formater_type": 3,  +            "target": "topographic_localisation",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 50,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 49,  +            "formater_type": 3,  +            "target": "special_interest",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 51,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 50,  +            "formater_type": 16,  +            "target": "description",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 9,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 9,  +            "formater_type": 1,  +            "target": "operation__code_patriarche",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 15,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 14,  +            "formater_type": 1,  +            "target": "operation__code_patriarche",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 27,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 26,  +            "formater_type": 1,  +            "target": "operation__code_patriarche",  +            "regexp_filter": null +        } +    },  +    { +        "pk": 13,  +        "model": "ishtar_common.importtarget",  +        "fields": { +            "column": 12,  +            "formater_type": 11,  +            "target": "town__numero_insee",  +            "regexp_filter": null +        } +    },  +    {          "pk": 5,           "model": "ishtar_common.formatertype",           "fields": { @@ -850,6 +1176,15 @@          }      },       { +        "pk": 21,  +        "model": "ishtar_common.formatertype",  +        "fields": { +            "formater_type": "FloatFormater",  +            "many_split": "",  +            "options": "" +        } +    },  +    {          "pk": 1,           "model": "ishtar_common.formatertype",           "fields": { @@ -859,6 +1194,15 @@          }      },       { +        "pk": 19,  +        "model": "ishtar_common.formatertype",  +        "fields": { +            "formater_type": "StrToBoolean",  +            "many_split": "",  +            "options": "" +        } +    },  +    {          "pk": 18,           "model": "ishtar_common.formatertype",           "fields": { @@ -868,6 +1212,33 @@          }      },       { +        "pk": 22,  +        "model": "ishtar_common.formatertype",  +        "fields": { +            "formater_type": "TypeFormater",  +            "many_split": "",  +            "options": "archaeological_finds.models.ConservatoryState" +        } +    },  +    { +        "pk": 20,  +        "model": "ishtar_common.formatertype",  +        "fields": { +            "formater_type": "TypeFormater",  +            "many_split": "",  +            "options": "archaeological_finds.models.MaterialType" +        } +    },  +    { +        "pk": 23,  +        "model": "ishtar_common.formatertype",  +        "fields": { +            "formater_type": "TypeFormater",  +            "many_split": "",  +            "options": "archaeological_finds.models.PreservationType" +        } +    },  +    {          "pk": 2,           "model": "ishtar_common.formatertype",           "fields": { diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b3bead9ab..2729aeeef 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -59,7 +59,7 @@ from ishtar_common.model_merging import merge_model_objects  from ishtar_common.utils import get_cache  from ishtar_common.data_importer import Importer, ImportFormater, \      IntegerFormater, FloatFormater, UnicodeFormater, DateFormater, \ -    TypeFormater, YearFormater +    TypeFormater, YearFormater, StrToBoolean  def post_save_user(sender, **kwargs):      user = kwargs['instance'] @@ -979,6 +979,10 @@ if 'archaeological_context_records' in settings.INSTALLED_APPS:      MODELS = [('archaeological_context_records.models.ContextRecord',                _(u"Context records")),               ] + MODELS +if 'archaeological_finds' in settings.INSTALLED_APPS: +    MODELS = [('archaeological_finds.models.BaseFind', +              _(u"Finds")), +             ] + MODELS  def get_model_fields(model):      """ @@ -1259,6 +1263,7 @@ IMPORTER_TYPES = (      ('DateFormater', _(u"Date")),      ('TypeFormater', _(u"Type")),      ('YearFormater', _(u"Year")), +    ('StrToBoolean', _(u"String to boolean")),  )  IMPORTER_TYPES_DCT = { @@ -1268,6 +1273,7 @@ IMPORTER_TYPES_DCT = {      'DateFormater':DateFormater,      'TypeFormater':TypeFormater,      'YearFormater':YearFormater, +    'StrToBoolean':StrToBoolean,  }  DATE_FORMATS = ( @@ -1324,6 +1330,8 @@ class FormaterType(models.Model):                  return          elif self.formater_type == 'DateFormater':              return DateFormater(self.options, **kwargs) +        elif self.formater_type == 'StrToBoolean': +            return StrToBoolean(**kwargs)          else:              return IMPORTER_TYPES_DCT[self.formater_type](**kwargs) | 
