summaryrefslogtreecommitdiff
path: root/archaeological_finds/views.py
blob: cde192ef3794f5de52061ca9a6b5b984a39eadfb (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012  É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.

from ishtar_common.views import get_item, show_item, revert_item
from ishtar_common.wizards import SearchWizard
from wizards import *
from forms import *
import models

get_find = get_item(models.Find,
        'get_find', 'find',
        bool_fields = ['base_finds__is_isolated'],
        base_request={'downstream_treatment__isnull':True},
      extra_request_keys={
'base_finds__context_record__parcel__town':
                'base_finds__context_record__parcel__town',
'base_finds__context_record__operation__year':
                'base_finds__context_record__operation__year__contains',
'base_finds__context_record__operation__code_patriarche':
               'base_finds__context_record__operation__code_patriarche',
'dating__period':'dating__period__pk',
'base_finds__find__description':'base_finds__find__description__icontains',
'base_finds__is_isolated':'base_finds__is_isolated'})
get_findsource = get_item(models.FindSource,
        'get_findsource', 'findsource',
      extra_request_keys={
'find__context_record__operation__year':'find__context_record__operation__year',
'find__dating__period':'find__dating__period__pk',
'find__description':'find__description__icontains',
    })

find_creation_wizard = FindWizard.as_view([
    ('selecrecord-find_creation', RecordFormSelection),
    ('find-find_creation', FindForm),
    ('dating-find_creation', DateForm),
    ('final-find_creation', FinalForm)],
     url_name='find_creation',)

find_search_wizard = SearchWizard.as_view([
                          ('general-find_search', FindFormSelection)],
                          url_name='find_search',)

find_modification_wizard = FindModificationWizard.as_view([
    ('selec-find_modification', FindFormSelection),
    ('find-find_modification', FindForm),
    ('dating-find_modification', DateForm),
    ('final-find_modification', FinalForm)],
     url_name='find_modification',)

treatment_creation_wizard = TreatmentWizard.as_view([
    ('basetreatment-treatment_creation', BaseTreatmentForm),
    ('selecfind-treatment_creation', UpstreamFindFormSelection),
    ('multiselecfinds-treatment_creation', FindMultipleFormSelection),
    ('container-treatment_creation', ContainerForm),
    ('resultfind-treatment_creation', ResultFindForm),
    ('resultfinds-treatment_creation', ResultFindFormSet),
    ('final-treatment_creation', FinalForm)],
             condition_dict={
'selecfind-treatment_creation':
    check_treatment('basetreatment-treatment_creation', 'treatment_type',
                    not_type_list=['physical_grouping', 'packaging']),
'multiselecfinds-treatment_creation':
    check_treatment('basetreatment-treatment_creation', 'treatment_type',
                    ['physical_grouping', 'packaging']),
'resultfinds-treatment_creation':
    check_treatment('basetreatment-treatment_creation', 'treatment_type',
                    ['split']),
'resultfind-treatment_creation':
    check_treatment('basetreatment-treatment_creation', 'treatment_type',
                    not_type_list=['split']),
'container-treatment_creation':
    check_treatment('basetreatment-treatment_creation', 'treatment_type',
                    ['packaging']),
                            },
     url_name='treatment_creation',)

find_source_creation_wizard = FindSourceWizard.as_view([
             ('selec-find_source_creation', SourceFindFormSelection),
             ('source-find_source_creation', SourceForm),
             ('authors-find_source_creation', AuthorFormset),
             ('final-find_source_creation', FinalForm)],
                  url_name='find_source_creation',)

find_source_modification_wizard = FindSourceWizard.as_view([
         ('selec-find_source_modification', FindSourceFormSelection),
         ('source-find_source_modification', SourceForm),
         ('authors-find_source_modification', AuthorFormset),
         ('final-find_source_modification', FinalForm)],
          url_name='find_source_modification',)

find_source_deletion_wizard = FindSourceDeletionWizard.as_view([
         ('selec-find_source_deletion', FindSourceFormSelection),
         ('final-find_source_deletion', SourceDeletionForm)],
          url_name='find_source_deletion',)

treatment_source_creation_wizard = TreatmentSourceWizard.as_view([
             ('selec-treatment_source_creation', SourceTreatmentFormSelection),
             ('source-treatment_source_creation', SourceForm),
             ('authors-treatment_source_creation', AuthorFormset),
             ('final-treatment_source_creation', FinalForm)],
                  url_name='treatment_source_creation',)