summaryrefslogtreecommitdiff
path: root/archaeological_context_records/data_importer.py
blob: bbe89a5b8ad1e2347769642f7a139f5012749188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2015  Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# See the file COPYING for details.

import re

from django.utils.translation import ugettext_lazy as _

from ishtar_common.data_importer import *

from archaeological_context_records import models

class ContextRecordsImporterBibracte(Importer):
    DESC = u"Exports Bibracte : importeur pour l'onglet UE"
    OBJECT_CLS = models.ContextRecord
    DEFAULTS = {
               }
    LINE_FORMAT = [
        # ID operation
        ImportFormater('operation__operation_code', IntegerFormater(),
                   duplicate_fields=['parcel__operation__operation_code'],),
        # ID UE
        ImportFormater('external_id', UnicodeFormater(120),),
        # Type
        ImportFormater('unit', TypeFormater(models.Unit), required=False),
        # description
        ImportFormater('description', UnicodeFormater(1000), required=False,),
        # interprétation
        ImportFormater('interpretation', UnicodeFormater(1000), required=False,),
        # date ouverture
        ImportFormater('opening_date', DateFormater('%Y/%m/%d'), required=False,),
        # date fermeture
        ImportFormater('closing_date', DateFormater('%Y/%m/%d'), required=False,),
        # lien vers parcelle
        ImportFormater('parcel__external_id', UnicodeFormater(12),
                       required=False,),
        # lien vers ID sig
        None,
        # commentaire
        ImportFormater('comment', UnicodeFormater(1000), required=False,),
        # ????
        None,
        # chrono
        ImportFormater('dating__period', TypeFormater(models.Period,
                                              many_split="&"), required=False),
    ]

class ContextRecordsRelationImporterBibracte(Importer):
    DESC = u"Exports Bibracte : importeur pour l'onglet relations entre UE"
    OBJECT_CLS = models.RecordRelations
    DEFAULTS = {}
    LINE_FORMAT = [
        # code OA
        ImportFormater('left_record__operation__operation_code',
               IntegerFormater(),
               duplicate_fields=['right_record__operation__operation_code'],),
        # identifiant UE 1
        ImportFormater('left_record__external_id', UnicodeFormater(120),),
        # type relation
        ImportFormater('relation_type', TypeFormater(models.RelationType),),
        # identifiant UE 2
        ImportFormater('right_record__external_id', UnicodeFormater(120),),
    ]