diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-02 13:04:40 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-02 13:04:40 +0200 |
commit | f6f20e5745a0c6eb3f07b4e0b33454c87c48f6e6 (patch) | |
tree | aae1f9f35364a05c463932dde074583b37194a2c | |
parent | 2fcd1ef9e0b6659df24d3171ca04d5bc803e9d8e (diff) | |
download | Ishtar-f6f20e5745a0c6eb3f07b4e0b33454c87c48f6e6.tar.bz2 Ishtar-f6f20e5745a0c6eb3f07b4e0b33454c87c48f6e6.zip |
Data importer: add value formaters based on Python format() string
-rw-r--r-- | Makefile.example | 3 | ||||
-rw-r--r-- | archaeological_context_records/models.py | 3 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 3 | ||||
-rw-r--r-- | archaeological_finds/models_treatments.py | 3 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 23 | ||||
-rw-r--r-- | archaeological_warehouse/models.py | 3 | ||||
-rw-r--r-- | ishtar_common/admin.py | 10 | ||||
-rw-r--r-- | ishtar_common/data_importer.py | 14 | ||||
-rw-r--r-- | ishtar_common/fixtures/initial_importtypes-fr.json | 245 | ||||
-rw-r--r-- | ishtar_common/migrations/0091_auto_20190502_1223.py | 44 | ||||
-rw-r--r-- | ishtar_common/model_managers.py | 20 | ||||
-rw-r--r-- | ishtar_common/models.py | 21 | ||||
-rw-r--r-- | ishtar_common/models_imports.py | 49 |
13 files changed, 160 insertions, 281 deletions
diff --git a/Makefile.example b/Makefile.example index 1609d1091..ffd3ea86a 100644 --- a/Makefile.example +++ b/Makefile.example @@ -103,7 +103,7 @@ migrations: generate_doc: cd $(project);\ - $(PYTHON) manage.py graph_models --pydot -g -I "ImporterModel,ImporterType,ImporterDefault,ImporterDefaultValues,ImporterColumn,Regexp,ImportTarget,FormaterType,Import" ishtar_common > /tmp/ishtar-imports.dot ;\ + $(PYTHON) manage.py graph_models --pydot -g -I "ImporterModel,ImporterType,ImporterDefault,ImporterDefaultValues,ImporterColumn,ValueFormater,Regexp,ImportTarget,FormaterType,Import" ishtar_common > /tmp/ishtar-imports.dot ;\ dot -Tpng /tmp/ishtar-imports.dot -o ../docs/source/_static/db-imports.png rm /tmp/ishtar-imports.dot cd $(project);\ @@ -139,6 +139,7 @@ fixtures_common_importers: ishtar_common.importermodel \ ishtar_common.importertype \ ishtar_common.regexp \ + ishtar_common.valueformater \ ishtar_common.importerdefault \ ishtar_common.importerdefaultvalues \ ishtar_common.importercolumn \ diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index ff5c31c64..01595feed 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -30,10 +30,11 @@ from django.utils.text import slugify from ishtar_common.utils import cached_label_changed, \ m2m_historization_changed, post_save_geo +from ishtar_common.model_managers import ExternalIdManager from ishtar_common.models import Document, GeneralType, \ BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \ GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\ - post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \ + post_save_cache, ValueGetter, BulkUpdatedItem, \ RelationItem, Town, get_current_profile, document_attached_changed, \ HistoryModel, SearchAltName, GeoItem, QRCodeItem, SearchVectorConfig from archaeological_operations.models import Operation, Period, Parcel, \ diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index c5a3aa914..3dbda8472 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -35,11 +35,12 @@ from ishtar_common.utils import cached_label_changed, post_save_geo, \ from ishtar_common.alternative_configs import ALTERNATE_CONFIGS +from ishtar_common.model_managers import ExternalIdManager from ishtar_common.models import Document, GeneralType, \ HierarchicalType, BaseHistorizedItem, LightHistorizedItem, \ HistoricalRecords, OwnPerms, Person, Basket, post_save_cache, \ ValueGetter, get_current_profile, IshtarSiteProfile, PRIVATE_FIELDS, \ - GeoItem, BulkUpdatedItem, ExternalIdManager, QuickAction, \ + GeoItem, BulkUpdatedItem, QuickAction, \ MainItem, document_attached_changed, HistoryModel, DynamicRequest, \ SearchAltName, QRCodeItem, SearchVectorConfig diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 3fc1a5afa..5a7792083 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -33,10 +33,11 @@ from archaeological_finds.models_finds import Find, FindBasket, TreatmentType from archaeological_operations.models import ClosedItem, Operation from archaeological_context_records.models import Dating from archaeological_warehouse.models import Warehouse, Container +from ishtar_common.model_managers import ExternalIdManager from ishtar_common.models import Document, GeneralType, \ ImageModel, BaseHistorizedItem, OwnPerms, HistoricalRecords, Person, \ Organization, ValueGetter, post_save_cache, ShortMenuItem, \ - DashboardFormItem, ExternalIdManager, document_attached_changed, \ + DashboardFormItem, document_attached_changed, \ HistoryModel, SearchAltName, SearchVectorConfig from ishtar_common.utils import cached_label_changed, get_current_year, \ update_data, m2m_historization_changed diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index b5680a6fd..957e5d65e 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -44,7 +44,7 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \ DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \ JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField, \ UserProfile, ProfileType, Area, CustomFormJsonField, get_current_profile, \ - Document + Document, ValueFormater from archaeological_files.models import File, FileType from archaeological_context_records.models import Unit, ContextRecord @@ -334,6 +334,27 @@ class ImportOperationTest(ImportTest, TestCase): current_ope_nb = models.Operation.objects.count() self.assertEqual(current_ope_nb, first_ope_nb + 2) + def test_import_value_format(self): + importer, form = self.init_ope_import() + column = importer.columns.get(col_number=1) + f = ValueFormater.objects.create(name="-", slug="-", + format_string="oa-{}") + column.value_format = f + column.save() + + self.assertTrue(form.is_valid()) + impt = form.save(self.ishtar_user) + impt.initialize() + self.init_ope_targetkey(imp=impt) + impt.importation() + self.assertEqual( + models.Operation.objects.filter(code_patriarche='oa-4201').count(), + 1) + self.assertEqual( + models.Operation.objects.filter(code_patriarche='oa-4200').count(), + 1) + f.delete() + def test_keys_limitation(self): # each key association associated to the import init_ope_number = models.Operation.objects.count() diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index cec8667cd..10cf89943 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -28,9 +28,10 @@ from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _, pgettext_lazy from ishtar_common.data_importer import post_importer_action +from ishtar_common.model_managers import ExternalIdManager from ishtar_common.models import Document, GeneralType, get_external_id, \ LightHistorizedItem, OwnPerms, Address, Person, post_save_cache, \ - DashboardFormItem, ExternalIdManager, ShortMenuItem, \ + DashboardFormItem, ShortMenuItem, \ document_attached_changed, SearchAltName, DynamicRequest, GeoItem, \ QRCodeItem, SearchVectorConfig from ishtar_common.utils import cached_label_changed, post_save_geo diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 2ddb43cdb..3a7ea4a12 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -947,12 +947,20 @@ admin_site.register(models.ImporterType, ImporterTypeAdmin) class RegexpAdmin(admin.ModelAdmin): - list_display = ('name', 'description', "regexp") + list_display = ('name', "regexp", 'description') admin_site.register(models.Regexp, RegexpAdmin) +class ValueFormaterAdmin(admin.ModelAdmin): + list_display = ('name', "format_string", 'description') + prepopulated_fields = {"slug": ("name",)} + + +admin_site.register(models.ValueFormater, ValueFormaterAdmin) + + def duplicate_importercolumn(modeladmin, request, queryset): res = [] for col in queryset.order_by('col_number'): diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 43c07873e..95763ae09 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -61,11 +61,11 @@ def pre_importer_action(func): class ImportFormater(object): def __init__(self, field_name, formater=None, required=True, through=None, through_key=None, through_dict=None, - through_unicity_keys=None, duplicate_fields=[], regexp=None, - regexp_formater_args=[], force_value=None, + through_unicity_keys=None, duplicate_fields=None, regexp=None, + regexp_formater_args=None, force_value=None, post_processing=False, concat=False, concat_str=False, comment="", force_new=None, export_field_name=None, - label=""): + value_format=None, label=""): self.field_name = field_name if export_field_name: self.export_field_name = export_field_name @@ -77,9 +77,10 @@ class ImportFormater(object): self.through_key = through_key self.through_dict = through_dict self.through_unicity_keys = through_unicity_keys - self.duplicate_fields = duplicate_fields + self.duplicate_fields = duplicate_fields or [] self.regexp = regexp - self.regexp_formater_args = regexp_formater_args + self.value_format = value_format + self.regexp_formater_args = regexp_formater_args or [] # write this value even if a value exists self.force_value = force_value # post process after import @@ -1312,7 +1313,6 @@ class Importer(object): self.DB_TARGETS["{}-{}".format(idx_col + 1, field_name)], idx_v) for idx, v in enumerate(values): - value = None try: if formater.regexp_formater_args: args = [] @@ -1330,6 +1330,8 @@ class Importer(object): self.errors.append((idx_line + 1, idx_col + 1, e.message)) c_values.append('') return + if formater.value_format and value is not None and value != "": + value = formater.value_format.format(value) formated_values.append(value) if hasattr(func, 'match_table'): if field_name not in self.match_table: diff --git a/ishtar_common/fixtures/initial_importtypes-fr.json b/ishtar_common/fixtures/initial_importtypes-fr.json index e5b5695b7..a2ca74b68 100644 --- a/ishtar_common/fixtures/initial_importtypes-fr.json +++ b/ishtar_common/fixtures/initial_importtypes-fr.json @@ -5527,7 +5527,6 @@ 1 ], "target": "code_patriarche", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -5547,7 +5546,6 @@ 3 ], "target": "operation_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.OperationType", @@ -5567,7 +5565,6 @@ 4 ], "target": "common_name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -5587,7 +5584,6 @@ 5 ], "target": "operator__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -5607,7 +5603,6 @@ 6 ], "target": "scientist__raw_name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "300", @@ -5627,7 +5622,6 @@ 7 ], "target": "start_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%Y/%m/%d", @@ -5647,7 +5641,6 @@ 8 ], "target": "excavation_end_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%Y/%m/%d", @@ -5667,7 +5660,6 @@ 9 ], "target": "periods", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -5687,7 +5679,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -5707,7 +5698,6 @@ 2 ], "target": "town__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -5727,7 +5717,6 @@ 9 ], "target": "address", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "500", @@ -5747,7 +5736,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -5767,7 +5755,6 @@ 2 ], "target": "external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -5787,7 +5774,6 @@ 3 ], "target": "source_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "SourceType", @@ -5807,7 +5793,6 @@ 4 ], "target": "support_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "SupportType", @@ -5827,7 +5812,6 @@ 5 ], "target": "item_number", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -5847,7 +5831,6 @@ 6 ], "target": "authors__person__raw_name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "300", @@ -5867,7 +5850,6 @@ 7 ], "target": "creation_date", - "regexp_filter": null, "formater_type": [ "YearFormater", "%Y", @@ -5887,7 +5869,6 @@ 8 ], "target": "format_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "Format", @@ -5907,7 +5888,6 @@ 9 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -5927,7 +5907,6 @@ 12 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -5947,7 +5926,6 @@ 13 ], "target": "scale", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "30", @@ -5967,7 +5945,6 @@ 16 ], "target": "additional_information", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -5987,7 +5964,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -6007,7 +5983,6 @@ 4 ], "target": "label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6027,7 +6002,6 @@ 5 ], "target": "unit", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.Unit", @@ -6047,7 +6021,6 @@ 6 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -6067,7 +6040,6 @@ 7 ], "target": "identification", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.IdentificationType", @@ -6087,7 +6059,6 @@ 8 ], "target": "opening_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%Y/%m/%d", @@ -6107,7 +6078,6 @@ 9 ], "target": "closing_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%Y/%m/%d", @@ -6127,7 +6097,6 @@ 3 ], "target": "parcel__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -6147,7 +6116,6 @@ 11 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -6167,7 +6135,6 @@ 13 ], "target": "datings__period", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -6187,7 +6154,6 @@ 1 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -6207,7 +6173,6 @@ 5 ], "target": "base_finds__label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6227,7 +6192,6 @@ 9 ], "target": "material_types", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.MaterialType", @@ -6247,7 +6211,6 @@ 13 ], "target": "find_number", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -6267,7 +6230,6 @@ 14 ], "target": "weight", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -6287,7 +6249,6 @@ 15 ], "target": "weight_unit", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "4", @@ -6307,7 +6268,6 @@ 4 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6327,7 +6287,6 @@ 16 ], "target": "base_finds__discovery_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%Y/%m/%d", @@ -6347,7 +6306,6 @@ 17 ], "target": "conservatory_state", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.ConservatoryState", @@ -6367,7 +6325,6 @@ 18 ], "target": "preservation_to_considers", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.TreatmentType", @@ -6387,7 +6344,6 @@ 19 ], "target": "base_finds__comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -6407,7 +6363,6 @@ 21 ], "target": "base_finds__topographic_localisation", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6427,7 +6382,6 @@ 22 ], "target": "base_finds__special_interest", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6447,7 +6401,6 @@ 23 ], "target": "base_finds__description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -6467,7 +6420,6 @@ 4 ], "target": "parcel_number", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "6", @@ -6487,7 +6439,6 @@ 5 ], "target": "section", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "4", @@ -6507,7 +6458,6 @@ 3 ], "target": "external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -6527,7 +6477,6 @@ 6 ], "target": "year", - "regexp_filter": null, "formater_type": [ "YearFormater", "%Y", @@ -6547,7 +6496,6 @@ 12 ], "target": "interpretation", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -6567,7 +6515,6 @@ 2 ], "target": "parcel__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -6587,7 +6534,6 @@ 3 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -6607,7 +6553,6 @@ 2 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -6627,7 +6572,6 @@ 20 ], "target": "datings__period", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -6647,7 +6591,6 @@ 12 ], "target": "label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6667,7 +6610,6 @@ 1 ], "target": "code_patriarche", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "20", @@ -6687,7 +6629,6 @@ 2 ], "target": "common_name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -6707,7 +6648,6 @@ 3 ], "target": "year", - "regexp_filter": null, "formater_type": [ "YearFormater", "%Y", @@ -6727,7 +6667,6 @@ 4 ], "target": "operation_code", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -6747,7 +6686,6 @@ 5 ], "target": "operation_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.OperationType", @@ -6767,7 +6705,6 @@ 7 ], "target": "associated_file__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -6787,7 +6724,6 @@ 10 ], "target": "periods", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -6807,7 +6743,6 @@ 8 ], "target": "archaeological_sites__reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "20", @@ -6827,7 +6762,6 @@ 11 ], "target": "scientist__title", - "regexp_filter": null, "formater_type": [ "TypeFormater", "TitleType", @@ -6847,7 +6781,6 @@ 12 ], "target": "scientist__surname", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6867,7 +6800,6 @@ 13 ], "target": "scientist__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -6887,7 +6819,6 @@ 14 ], "target": "scientist__attached_to__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -6907,7 +6838,6 @@ 15 ], "target": "operator__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "500", @@ -6927,7 +6857,6 @@ 16 ], "target": "operator_reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -6947,7 +6876,6 @@ 17 ], "target": "in_charge__title", - "regexp_filter": null, "formater_type": [ "TypeFormater", "TitleType", @@ -6967,7 +6895,6 @@ 18 ], "target": "in_charge__surname", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "50", @@ -6987,7 +6914,6 @@ 19 ], "target": "in_charge__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -7007,7 +6933,6 @@ 20 ], "target": "in_charge__attached_to__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "500", @@ -7027,7 +6952,6 @@ 21 ], "target": "surface", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -7047,7 +6971,6 @@ 22 ], "target": "start_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7067,7 +6990,6 @@ 23 ], "target": "excavation_end_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7087,7 +7009,6 @@ 24 ], "target": "end_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7107,7 +7028,6 @@ 25 ], "target": "cira_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7127,7 +7047,6 @@ 26 ], "target": "negative_result", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -7147,7 +7066,6 @@ 27 ], "target": "cira_rapporteur__surname", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "50", @@ -7167,7 +7085,6 @@ 28 ], "target": "cira_rapporteur__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -7187,7 +7104,6 @@ 29 ], "target": "cira_rapporteur__attached_to__name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "500", @@ -7207,7 +7123,6 @@ 30 ], "target": "documentation_deadline", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7227,7 +7142,6 @@ 31 ], "target": "documentation_received", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -7247,7 +7161,6 @@ 32 ], "target": "finds_deadline", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7267,7 +7180,6 @@ 33 ], "target": "finds_received", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -7287,7 +7199,6 @@ 34 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7307,7 +7218,6 @@ 35 ], "target": "report_delivery_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -7327,7 +7237,6 @@ 36 ], "target": "report_processing", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.ReportState", @@ -7347,7 +7256,6 @@ 37 ], "target": "scientific_documentation_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7367,7 +7275,6 @@ 38 ], "target": "documents__image", - "regexp_filter": null, "formater_type": [ "FileFormater", "", @@ -7387,7 +7294,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -7407,7 +7313,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "20", @@ -7427,7 +7332,6 @@ 2 ], "target": "town__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -7447,7 +7351,6 @@ 3 ], "target": "external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -7467,7 +7370,6 @@ 4 ], "target": "section", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "4", @@ -7487,7 +7389,6 @@ 5 ], "target": "parcel_number", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "6", @@ -7507,7 +7408,6 @@ 6 ], "target": "year", - "regexp_filter": null, "formater_type": [ "YearFormater", "%Y", @@ -7527,7 +7427,6 @@ 7 ], "target": "address", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "500", @@ -7547,7 +7446,6 @@ 8 ], "target": "public_domain", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -7567,7 +7465,6 @@ 2 ], "target": "parcel__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -7587,7 +7484,6 @@ 3 ], "target": "parcel__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -7607,7 +7503,6 @@ 4 ], "target": "parcel__year", - "regexp_filter": null, "formater_type": [ "YearFormater", "%Y", @@ -7627,7 +7522,6 @@ 9 ], "target": "remains", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.RemainType", @@ -7647,7 +7541,6 @@ 5 ], "target": "label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -7667,7 +7560,6 @@ 6 ], "target": "unit", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.Unit", @@ -7687,7 +7579,6 @@ 7 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7707,7 +7598,6 @@ 8 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7727,7 +7617,6 @@ 9 ], "target": "length", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -7747,7 +7636,6 @@ 10 ], "target": "width", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -7767,7 +7655,6 @@ 11 ], "target": "thickness", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -7787,7 +7674,6 @@ 12 ], "target": "depth", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -7807,7 +7693,6 @@ 13 ], "target": "location", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7827,7 +7712,6 @@ 14 ], "target": "documentations", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.DocumentationType", @@ -7847,7 +7731,6 @@ 15 ], "target": "documents__image", - "regexp_filter": null, "formater_type": [ "FileFormater", "", @@ -7867,7 +7750,6 @@ 16 ], "target": "datings__period", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -7887,7 +7769,6 @@ 17 ], "target": "datings_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "1000", @@ -7907,7 +7788,6 @@ 18 ], "target": "filling", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7927,7 +7807,6 @@ 19 ], "target": "interpretation", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -7947,7 +7826,6 @@ 20 ], "target": "activity", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.ActivityType", @@ -7967,7 +7845,6 @@ 21 ], "target": "identification", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.IdentificationType", @@ -7987,7 +7864,6 @@ 22 ], "target": "taq", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8007,7 +7883,6 @@ 23 ], "target": "tpq", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8027,7 +7902,6 @@ 24 ], "target": "taq_estimated", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8047,7 +7921,6 @@ 25 ], "target": "tpq_estimated", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8067,7 +7940,6 @@ 6 ], "target": "old_code", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -8087,7 +7959,6 @@ 1 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -8107,7 +7978,6 @@ 2 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -8127,7 +7997,6 @@ 3 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8147,7 +8016,6 @@ 4 ], "target": "base_finds__context_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -8167,7 +8035,6 @@ 5 ], "target": "base_finds__label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8187,7 +8054,6 @@ 6 ], "target": "previous_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -8207,7 +8073,6 @@ 8 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8227,7 +8092,6 @@ 9 ], "target": "base_finds__batch", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.BatchType", @@ -8247,7 +8111,6 @@ 10 ], "target": "is_complete", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -8267,7 +8130,6 @@ 11 ], "target": "material_types", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.MaterialType", @@ -8287,7 +8149,6 @@ 12 ], "target": "conservatory_state", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.ConservatoryState", @@ -8307,7 +8168,6 @@ 13 ], "target": "conservatory_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8327,7 +8187,6 @@ 14 ], "target": "object_types", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.ObjectType", @@ -8347,7 +8206,6 @@ 15 ], "target": "preservation_to_considers", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.TreatmentType", @@ -8367,7 +8225,6 @@ 16 ], "target": "integrities", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.IntegrityType", @@ -8387,7 +8244,6 @@ 17 ], "target": "remarkabilities", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.RemarkabilityType", @@ -8407,7 +8263,6 @@ 18 ], "target": "length", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8427,7 +8282,6 @@ 19 ], "target": "width", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8447,7 +8301,6 @@ 20 ], "target": "height", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8467,7 +8320,6 @@ 21 ], "target": "diameter", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8487,7 +8339,6 @@ 22 ], "target": "dimensions_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8507,7 +8358,6 @@ 24 ], "target": "find_number", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8527,7 +8377,6 @@ 26 ], "target": "mark", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8547,7 +8396,6 @@ 27 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8567,7 +8415,6 @@ 28 ], "target": "dating_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8587,7 +8434,6 @@ 29 ], "target": "estimated_value", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8607,7 +8453,6 @@ 30 ], "target": "documents__image", - "regexp_filter": null, "formater_type": [ "FileFormater", "", @@ -8627,7 +8472,6 @@ 31 ], "target": "datings__period", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -8647,7 +8491,6 @@ 7 ], "target": "base_finds__topographic_localisation", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -8667,7 +8510,6 @@ 32 ], "target": "base_finds__x", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8687,7 +8529,6 @@ 33 ], "target": "base_finds__y", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8707,7 +8548,6 @@ 34 ], "target": "base_finds__z", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8727,7 +8567,6 @@ 35 ], "target": "base_finds__spatial_reference_system", - "regexp_filter": null, "formater_type": [ "TypeFormater", "SpatialReferenceSystem", @@ -8747,7 +8586,6 @@ 1 ], "target": "left_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8767,7 +8605,6 @@ 2 ], "target": "relation_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_context_records.models.RelationType", @@ -8787,7 +8624,6 @@ 3 ], "target": "right_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8807,7 +8643,6 @@ 23 ], "target": "weight", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -8827,7 +8662,6 @@ 37 ], "target": "container__responsible__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8847,7 +8681,6 @@ 38 ], "target": "container__reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "30", @@ -8867,7 +8700,6 @@ 39 ], "target": "container__container_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_warehouse.models.ContainerType", @@ -8887,7 +8719,6 @@ 1 ], "target": "operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -8907,7 +8738,6 @@ 4 ], "target": "title", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "300", @@ -8927,7 +8757,6 @@ 3 ], "target": "source_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "SourceType", @@ -8947,7 +8776,6 @@ 2 ], "target": "index", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -8967,7 +8795,6 @@ 5 ], "target": "reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "100", @@ -8987,7 +8814,6 @@ 6 ], "target": "internal_reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "100", @@ -9007,7 +8833,6 @@ 7 ], "target": "associated_url", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "300", @@ -9027,7 +8852,6 @@ 8 ], "target": "receipt_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9047,7 +8871,6 @@ 9 ], "target": "creation_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9067,7 +8890,6 @@ 10 ], "target": "receipt_date_in_documentation", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9087,7 +8909,6 @@ 11 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9107,7 +8928,6 @@ 12 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9127,7 +8947,6 @@ 13 ], "target": "additional_information", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9147,7 +8966,6 @@ 15 ], "target": "authors__person__raw_name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "300", @@ -9167,7 +8985,6 @@ 14 ], "target": "duplicate", - "regexp_filter": null, "formater_type": [ "StrToBoolean", "", @@ -9187,7 +9004,6 @@ 1 ], "target": "base_finds__context_record__operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -9207,7 +9023,6 @@ 2 ], "target": "base_finds__context_record__parcel__town__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -9227,7 +9042,6 @@ 3 ], "target": "base_finds__context_record__parcel__section", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "4", @@ -9247,7 +9061,6 @@ 4 ], "target": "base_finds__context_record__parcel__parcel_number", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "6", @@ -9267,7 +9080,6 @@ 5 ], "target": "base_finds__context_record__label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -9287,7 +9099,6 @@ 6 ], "target": "label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -9307,7 +9118,6 @@ 2 ], "target": "base_finds__context_record__parcel__town__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "5", @@ -9327,7 +9137,6 @@ 39 ], "target": "towns__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "10", @@ -9347,7 +9156,6 @@ 26 ], "target": "opening_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9367,7 +9175,6 @@ 27 ], "target": "closing_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9387,7 +9194,6 @@ 36 ], "target": "base_finds__discovery_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -9407,7 +9213,6 @@ 40 ], "target": "set_localisation_1", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9427,7 +9232,6 @@ 41 ], "target": "set_localisation_2", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9447,7 +9251,6 @@ 42 ], "target": "set_localisation_3", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9467,7 +9270,6 @@ 43 ], "target": "set_localisation_4", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9487,7 +9289,6 @@ 44 ], "target": "set_localisation_5", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9507,7 +9308,6 @@ 45 ], "target": "set_localisation_6", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9527,7 +9327,6 @@ 25 ], "target": "min_number_of_individuals", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -9547,7 +9346,6 @@ 1 ], "target": "left_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9567,7 +9365,6 @@ 2 ], "target": "relation_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.RelationType", @@ -9587,7 +9384,6 @@ 3 ], "target": "right_record__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9607,7 +9403,6 @@ 9 ], "target": "base_finds__context_record__operation__code_patriarche", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "12", @@ -9627,7 +9422,6 @@ 11 ], "target": "base_finds__context_record__parcel__town__numero_insee", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "20", @@ -9647,7 +9441,6 @@ 12 ], "target": "base_finds__context_record__parcel__section", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "4", @@ -9667,7 +9460,6 @@ 13 ], "target": "base_finds__context_record__parcel__parcel_number", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "6", @@ -9687,7 +9479,6 @@ 10 ], "target": "base_finds__context_record__label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -9707,7 +9498,6 @@ 14 ], "target": "label", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -9727,7 +9517,6 @@ 1 ], "target": "container__reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "30", @@ -9747,7 +9536,6 @@ 2 ], "target": "container__container_type", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_warehouse.models.ContainerType", @@ -9767,7 +9555,6 @@ 3 ], "target": "set_localisation_1", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9787,7 +9574,6 @@ 4 ], "target": "set_localisation_2", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9807,7 +9593,6 @@ 5 ], "target": "set_localisation_3", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9827,7 +9612,6 @@ 6 ], "target": "set_localisation_4", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -9847,7 +9631,6 @@ 15 ], "target": "previous_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -9867,7 +9650,6 @@ 16 ], "target": "base_finds__batch", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.BatchType", @@ -9887,7 +9669,6 @@ 19 ], "target": "description", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -9907,7 +9688,6 @@ 20 ], "target": "find_number", - "regexp_filter": null, "formater_type": [ "IntegerFormater", "", @@ -9927,7 +9707,6 @@ 21 ], "target": "weight", - "regexp_filter": null, "formater_type": [ "FloatFormater", "", @@ -9947,7 +9726,6 @@ 22 ], "target": "conservatory_state", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.ConservatoryState", @@ -9967,7 +9745,6 @@ 25 ], "target": "preservation_to_considers", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.TreatmentType", @@ -9987,7 +9764,6 @@ 27 ], "target": "conservatory_comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -10007,7 +9783,6 @@ 28 ], "target": "integrities", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.IntegrityType", @@ -10027,7 +9802,6 @@ 29 ], "target": "remarkabilities", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.RemarkabilityType", @@ -10047,7 +9821,6 @@ 36 ], "target": "documents__image", - "regexp_filter": null, "formater_type": [ "FileFormater", "", @@ -10067,7 +9840,6 @@ 30 ], "target": "base_finds__discovery_date", - "regexp_filter": null, "formater_type": [ "DateFormater", "%d/%m/%Y | %Y-%m-%d", @@ -10087,7 +9859,6 @@ 31 ], "target": "mark", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -10107,7 +9878,6 @@ 32 ], "target": "base_finds__topographic_localisation", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "120", @@ -10127,7 +9897,6 @@ 33 ], "target": "comment", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -10147,7 +9916,6 @@ 35 ], "target": "container__responsible__external_id", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "", @@ -10167,7 +9935,6 @@ 17 ], "target": "material_types", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.MaterialType", @@ -10187,7 +9954,6 @@ 34 ], "target": "datings__period", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -10207,7 +9973,6 @@ 18 ], "target": "object_types", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.ObjectType", @@ -10227,7 +9992,6 @@ 7 ], "target": "set_localisation_5", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -10247,7 +10011,6 @@ 8 ], "target": "set_localisation_6", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -10267,7 +10030,6 @@ 23 ], "target": "alterations", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.AlterationType", @@ -10287,7 +10049,6 @@ 24 ], "target": "alteration_causes", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.AlterationCauseType", @@ -10307,7 +10068,6 @@ 26 ], "target": "treatment_emergency", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_finds.models.TreatmentEmergencyType", @@ -10327,7 +10087,6 @@ 1 ], "target": "reference", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -10347,7 +10106,6 @@ 2 ], "target": "name", - "regexp_filter": null, "formater_type": [ "UnicodeFormater", "200", @@ -10367,7 +10125,6 @@ 4 ], "target": "periods", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.Period", @@ -10387,7 +10144,6 @@ 5 ], "target": "remains", - "regexp_filter": null, "formater_type": [ "TypeFormater", "archaeological_operations.models.RemainType", @@ -10407,7 +10163,6 @@ 3 ], "target": "towns__numero_insee", - "regexp_filter": null, "formater_type": [ "InseeFormater", null, diff --git a/ishtar_common/migrations/0091_auto_20190502_1223.py b/ishtar_common/migrations/0091_auto_20190502_1223.py new file mode 100644 index 000000000..4b92d2dfa --- /dev/null +++ b/ishtar_common/migrations/0091_auto_20190502_1223.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-05-02 12:23 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0090_ishtarsiteprofile_locate_warehouses'), + ] + + operations = [ + migrations.CreateModel( + name='ValueFormater', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, unique=True, verbose_name='Nom')), + ('slug', models.SlugField(max_length=100, unique=True, verbose_name='Identifiant texte')), + ('description', models.TextField(blank=True, null=True, verbose_name='Description')), + ('format_string', models.CharField(help_text='A string used to format a value using the Python "format()" method. The site https://pyformat.info/ provide good examples of usage. Only one "{}" entry is managed. The input is assumed to be a string.', max_length=100, verbose_name='Format string')), + ], + options={ + 'verbose_name': 'Importer - Value format', + 'verbose_name_plural': 'Importer - Value formats', + }, + ), + migrations.RemoveField( + model_name='importtarget', + name='regexp_filter', + ), + migrations.AlterField( + model_name='regexp', + name='description', + field=models.TextField(blank=True, null=True, verbose_name='Description'), + ), + migrations.AddField( + model_name='importercolumn', + name='value_format', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='ishtar_common.ValueFormater'), + ), + ] diff --git a/ishtar_common/model_managers.py b/ishtar_common/model_managers.py new file mode 100644 index 000000000..ae0264ced --- /dev/null +++ b/ishtar_common/model_managers.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +from django.contrib.gis.db.models import Manager, GeoManager + + +class ExternalIdManager(GeoManager): + def get_by_natural_key(self, external_id): + return self.get(external_id=external_id) + + +class TypeManager(Manager): + def get_by_natural_key(self, txt_idx): + return self.get(txt_idx=txt_idx) + + +class SlugModelManager(Manager): + def get_by_natural_key(self, slug): + return self.get(slug=slug) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index a3e0302aa..4b14d852c 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -72,11 +72,13 @@ from ishtar_common.alternative_configs import ALTERNATE_CONFIGS, \ from ishtar_common.data_importer import pre_importer_action +from ishtar_common.model_managers import SlugModelManager, ExternalIdManager, \ + TypeManager from ishtar_common.model_merging import merge_model_objects from ishtar_common.models_imports import ImporterModel, ImporterType, \ ImporterDefault, ImporterDefaultValues, ImporterColumn, \ ImporterDuplicateField, Regexp, ImportTarget, TargetKey, FormaterType, \ - Import, TargetKeyGroup + Import, TargetKeyGroup, ValueFormater from ishtar_common.templatetags.link_to_window import simple_link_to_window from ishtar_common.utils import get_cache, disable_for_loaddata, create_slug, \ get_all_field_names, merge_tsvectors, cached_label_changed, \ @@ -85,7 +87,7 @@ from ishtar_common.utils import get_cache, disable_for_loaddata, create_slug, \ __all__ = [ 'ImporterModel', 'ImporterType', 'ImporterDefault', 'ImporterDefaultValues', 'ImporterColumn', 'ImporterDuplicateField', 'Regexp', 'ImportTarget', - 'TargetKey', 'FormaterType', 'Import', 'TargetKeyGroup' + 'TargetKey', 'FormaterType', 'Import', 'TargetKeyGroup', 'ValueFormater' ] logger = logging.getLogger(__name__) @@ -525,21 +527,6 @@ def post_save_cache(sender, **kwargs): sender.refresh_cache() -class ExternalIdManager(models.GeoManager): - def get_by_natural_key(self, external_id): - return self.get(external_id=external_id) - - -class SlugModelManager(models.Manager): - def get_by_natural_key(self, slug): - return self.get(slug=slug) - - -class TypeManager(models.Manager): - def get_by_natural_key(self, txt_idx): - return self.get(txt_idx=txt_idx) - - class GeneralType(Cached, models.Model): """ Abstract class for "types" diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 9c98f5ea8..5cb72bd18 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -30,7 +30,7 @@ import zipfile from django.conf import settings from django.contrib.gis.db import models -from django.core.exceptions import SuspiciousOperation +from django.core.exceptions import SuspiciousOperation, ValidationError from django.core.files.base import ContentFile from django.core.validators import validate_comma_separated_integer_list from django.db.models.base import ModelBase @@ -39,6 +39,8 @@ from django.template.defaultfilters import slugify from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _, pgettext_lazy +from ishtar_common.model_managers import SlugModelManager + from ishtar_common.utils import create_slug, \ get_all_related_m2m_objects_with_model, put_session_message, \ put_session_var, get_session_var, num2col, max_size_help @@ -193,6 +195,9 @@ class ImporterType(models.Model): if column.regexp_pre_filter: formater_kwargs['regexp'] = re.compile( column.regexp_pre_filter.regexp) + if column.value_format: + formater_kwargs['value_format'] = \ + column.value_format.format_string formater_kwargs['concat_str'] = concat_str formater_kwargs['duplicate_fields'] = [ (field.field_name, field.force_new, field.concat, @@ -379,6 +384,9 @@ class ImporterColumn(models.Model): regexp_pre_filter = models.ForeignKey( "Regexp", blank=True, null=True, on_delete=models.SET_NULL, ) + value_format = models.ForeignKey( + "ValueFormater", blank=True, null=True, on_delete=models.SET_NULL, + ) required = models.BooleanField(_(u"Required"), default=False) export_field_name = models.CharField( _(u"Export field name"), blank=True, null=True, max_length=200, @@ -451,8 +459,7 @@ class NamedManager(models.Manager): class Regexp(models.Model): name = models.CharField(_(u"Name"), max_length=100, unique=True) - description = models.CharField(_(u"Description"), blank=True, null=True, - max_length=500) + description = models.TextField(_(u"Description"), blank=True, null=True) regexp = models.CharField(_(u"Regular expression"), max_length=500) objects = NamedManager() @@ -467,6 +474,39 @@ class Regexp(models.Model): return (self.name, ) +class ValueFormater(models.Model): + name = models.CharField(_(u"Name"), max_length=100, unique=True) + slug = models.SlugField(_(u"Slug"), unique=True, max_length=100) + description = models.TextField(_(u"Description"), blank=True, null=True) + format_string = models.CharField( + _(u"Format string"), max_length=100, + help_text=_(u"A string used to format a value using the Python " + u"\"format()\" method. The site https://pyformat.info/ " + u"provide good examples of usage. Only one \"{}\" entry " + u"is managed. The input is assumed to be a string.") + ) + objects = SlugModelManager() + + class Meta: + verbose_name = _(u"Importer - Value format") + verbose_name_plural = _(u"Importer - Value formats") + + def __unicode__(self): + return self.name + + def clean(self): + try: + self.format_string.format("sample value") + except ValueError: + raise ValidationError( + {'format_string': _("The string provided generate an error. " + "Fix it.")} + ) + + def natural_key(self): + return (self.slug, ) + + class ImportTargetManager(models.Manager): def get_by_natural_key(self, importer_type, col_number, target): return self.get(column__importer_type__slug=importer_type, @@ -480,9 +520,6 @@ class ImportTarget(models.Model): """ column = models.ForeignKey(ImporterColumn, related_name='targets') target = models.CharField(u"Target", max_length=500) - regexp_filter = models.ForeignKey( - "Regexp", blank=True, null=True, on_delete=models.SET_NULL, - ) formater_type = models.ForeignKey("FormaterType") force_new = models.BooleanField(_(u"Force creation of new items"), default=False) |