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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2013 É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 django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from ishtar_common.forms import FinalForm
from ishtar_common.forms_common import SourceForm, AuthorFormset, \
SourceDeletionForm
from archaeological_context_records.forms import RecordFormSelection
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'],
reversed_bool_fields=['image__isnull'],
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',
'image': 'image__isnull'})
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',
})
show_find = show_item(models.Find, 'find')
revert_find = revert_item(models.Find)
find_creation_wizard = FindWizard.as_view([
('selecrecord-find_creation', RecordFormSelection),
('find-find_creation', FindForm),
('dating-find_creation', DateForm),
('final-find_creation', FinalForm)],
label=_(u"New find"),
url_name='find_creation',)
find_search_wizard = SearchWizard.as_view([
('general-find_search', FindFormSelection)],
label=_(u"Find search"),
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)],
label=_(u"Find modification"),
url_name='find_modification',)
def find_modify(request, pk):
# view = find_modification_wizard(request)
FindModificationWizard.session_set_value(
request, 'selec-find_modification', 'pk', pk, reset=True)
return redirect(
reverse('find_modification',
kwargs={'step': 'find-find_modification'}))
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)],
label=_(u"Find: new source"),
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)],
label=_(u"Find: source modification"),
url_name='find_source_modification',)
find_source_deletion_wizard = FindSourceDeletionWizard.as_view([
('selec-find_source_deletion', FindSourceFormSelection),
('final-find_source_deletion', SourceDeletionForm)],
label=_(u"Find: source deletion"),
url_name='find_source_deletion',)
"""
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']),
},
label=_(u"New treatment"),
url_name='treatment_creation',)
"""
"""
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',)
"""
|