summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorValérie-Emma Leroux <valerie-emma.leroux@iggdrasil.net>2017-04-07 11:40:31 +0200
committerValérie-Emma Leroux <valerie-emma.leroux@iggdrasil.net>2017-04-07 11:40:31 +0200
commit655236dd5d04d6527184a58ef8622e75c73f8a65 (patch)
treef773b80964981c231c892ee5255b94285bc5620a /archaeological_finds
parentdc08e5f643562a6ecf3b208c1e2cd44e5350af3c (diff)
parenta4f1766d2217b1a3bc4d1d17625d9d808eed7416 (diff)
downloadIshtar-655236dd5d04d6527184a58ef8622e75c73f8a65.tar.bz2
Ishtar-655236dd5d04d6527184a58ef8622e75c73f8a65.zip
Merge branch 'master' of git.iggdrasil.net:/srv/git/ishtar
Conflicts: archaeological_operations/templates/ishtar/sheet_operation.html
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/forms.py64
-rw-r--r--archaeological_finds/forms_treatments.py4
-rw-r--r--archaeological_finds/ishtar_menu.py32
-rw-r--r--archaeological_finds/locale/django.pot496
-rw-r--r--archaeological_finds/models_finds.py105
-rw-r--r--archaeological_finds/models_treatments.py67
-rw-r--r--archaeological_finds/templates/ishtar/sheet_findbasket.html2
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html13
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatmentfile.html16
-rw-r--r--archaeological_finds/tests.py22
-rw-r--r--archaeological_finds/urls.py12
-rw-r--r--archaeological_finds/views.py46
-rw-r--r--archaeological_finds/wizards.py6
13 files changed, 625 insertions, 260 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 2c367043c..8fe945e88 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -48,6 +48,8 @@ from ishtar_common.utils import convert_coordinates_to_point
from ishtar_common import widgets
from archaeological_operations.widgets import OAWidget
+from archaeological_warehouse.models import Warehouse
+
from archaeological_finds.forms_treatments import TreatmentSelect, \
TreatmentFormSelection, BaseTreatmentForm, TreatmentModifyForm, \
AdministrativeActTreatmentForm, TreatmentFormFileChoice, \
@@ -75,7 +77,8 @@ __all__ = [
'SourceTreatmentFileFormSelection', 'TreatmentSourceFormSelection',
'TreatmentFileSourceFormSelection',
'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet',
- 'FindSelect', 'FindFormSelection', 'MultipleFindFormSelection',
+ 'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule',
+ 'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule',
'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist',
'check_value', 'check_type_field', 'check_type_not_field',
'check_treatment', 'ResultFindForm', 'ResultFindFormSet',
@@ -144,18 +147,22 @@ class FindForm(ManageOldType, forms.Form):
required=False)
is_complete = forms.NullBooleanField(label=_(u"Is complete?"),
required=False)
- material_type = widgets.MultipleAutocompleteField(
- model=models.MaterialType, label=_(u"Material type"), required=False)
+ material_type = widgets.Select2MultipleField(
+ model=models.MaterialType, label=_(u"Material type"), required=False,
+ available=True
+ )
conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"),
choices=[], required=False)
conservatory_comment = forms.CharField(
label=_(u"Conservatory comment"), required=False,
widget=forms.Textarea)
- object_type = widgets.MultipleAutocompleteField(
- model=models.ObjectType, label=_(u"Object types"), required=False)
+ object_type = widgets.Select2MultipleField(
+ model=models.ObjectType, label=_(u"Object types"), required=False,
+ available=True
+ )
preservation_to_consider = forms.MultipleChoiceField(
label=_(u"Preservation type"), choices=[],
- widget=widgets.CheckboxSelectMultiple, required=False)
+ widget=widgets.Select2Multiple, required=False)
integritie = forms.MultipleChoiceField(
label=_(u"Integrity / interest"), choices=[],
widget=widgets.CheckboxSelectMultiple, required=False)
@@ -348,7 +355,6 @@ class FindSelect(TableSelect):
label=_(u"Search within related operations"), choices=[],
widget=widgets.CheckboxSelectMultiple)
datings__period = forms.ChoiceField(label=_(u"Period"), choices=[])
- # TODO search by warehouse
material_types = forms.ChoiceField(label=_(u"Material type"), choices=[])
object_types = forms.ChoiceField(label=_(u"Object type"), choices=[])
preservation_to_considers = forms.ChoiceField(
@@ -410,6 +416,23 @@ class FindSelect(TableSelect):
return ids
+class FindSelectWarehouseModule(FindSelect):
+ container__location = forms.IntegerField(
+ label=_(u"Warehouse (location)"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-warehouse'),
+ associated_model=Warehouse),
+ validators=[valid_id(Warehouse)])
+ container__responsible = forms.IntegerField(
+ label=_(u"Warehouse (responsible)"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-warehouse'),
+ associated_model=Warehouse),
+ validators=[valid_id(Warehouse)])
+ container__index = forms.IntegerField(label=_(u"Container ID"))
+ container__reference = forms.IntegerField(label=_(u"Container ref."))
+
+
class FindFormSelection(forms.Form):
form_label = _("Find search")
associated_models = {'pk': models.Find}
@@ -423,6 +446,16 @@ class FindFormSelection(forms.Form):
validators=[valid_id(models.Find)])
+class FindFormSelectionWarehouseModule(FindFormSelection):
+ pk = forms.IntegerField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-find'),
+ FindSelectWarehouseModule, models.Find,
+ source_full=reverse_lazy('get-find-full')),
+ validators=[valid_id(models.Find)])
+
+
class MultipleFindFormSelection(forms.Form):
form_label = _("Find search")
associated_models = {'pk': models.Find}
@@ -437,15 +470,28 @@ class MultipleFindFormSelection(forms.Form):
validators=[valid_id(models.Find)])
+class MultipleFindFormSelectionWarehouseModule(MultipleFindFormSelection):
+ pk = forms.IntegerField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-find'),
+ FindSelectWarehouseModule, models.Find,
+ multiple_select=True,
+ source_full=reverse_lazy('get-find-full')),
+ validators=[valid_id(models.Find)])
+
+
class FindMultipleFormSelection(forms.Form):
form_label = _(u"Upstream finds")
associated_models = {'finds': models.Find}
associated_labels = {'finds': _(u"Finds")}
+ # using FindSelectWarehouseModule because this form is only used with
+ # the warehouse module activated
finds = forms.CharField(
label="", required=False,
widget=widgets.JQueryJqGrid(
- reverse_lazy('get-find'), FindSelect, models.Find, multiple=True,
- multiple_cols=[2, 3, 4]),
+ reverse_lazy('get-find'), FindSelectWarehouseModule, models.Find,
+ multiple=True, multiple_cols=[2, 3, 4]),
validators=[valid_ids(models.Find)])
def clean(self):
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index 3c6668c9d..b3ad8b115 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -95,7 +95,7 @@ class BaseTreatmentForm(ManageOldType, forms.Form):
label=_(u"Other ref."), max_length=200, required=False)
year = forms.IntegerField(label=_("Year"),
initial=lambda: datetime.datetime.now().year,
- validators=[validators.MinValueValidator(1900),
+ validators=[validators.MinValueValidator(1600),
validators.MaxValueValidator(2100)])
treatment_type = forms.MultipleChoiceField(
label=_(u"Treatment type"), choices=[],
@@ -405,7 +405,7 @@ class TreatmentFileForm(ManageOldType, forms.Form):
max_length=1000, required=False)
year = forms.IntegerField(label=_("Year"),
initial=lambda: datetime.datetime.now().year,
- validators=[validators.MinValueValidator(1900),
+ validators=[validators.MinValueValidator(1600),
validators.MaxValueValidator(2100)])
internal_reference = forms.CharField(
label=_(u"Internal ref."), max_length=60, required=False)
diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py
index 44a19dc02..4877e442c 100644
--- a/archaeological_finds/ishtar_menu.py
+++ b/archaeological_finds/ishtar_menu.py
@@ -112,23 +112,23 @@ MENU_SECTIONS = [
MenuItem('treatmentfle_search',
_(u"Search"),
model=models.TreatmentFile,
- access_controls=['view_find',
- 'view_own_find']),
+ access_controls=['view_treatmentfile',
+ 'view_own_treatmentfile']),
MenuItem('treatmentfle_creation',
_(u"Creation"),
model=models.TreatmentFile,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
MenuItem('treatmentfle_modification',
_(u"Modification"),
model=models.TreatmentFile,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
MenuItem('treatmentfle_deletion',
_(u"Deletion"),
model=models.TreatmentFile,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
SectionItem(
'admin_act_fletreatments', _(u"Administrative act"),
childs=[
@@ -192,23 +192,23 @@ MENU_SECTIONS = [
MenuItem('treatment_search',
_(u"Search"),
model=models.Treatment,
- access_controls=['view_find',
- 'view_own_find']),
+ access_controls=['view_treatment',
+ 'view_own_treatment']),
MenuItem('treatment_creation',
_(u"Creation"),
model=models.Treatment,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatment',
+ 'change_own_treatment']),
MenuItem('treatment_modification',
_(u"Modification"),
model=models.Treatment,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatment',
+ 'change_own_treatment']),
MenuItem('treatment_deletion',
_(u"Deletion"),
model=models.Treatment,
- access_controls=['change_find',
- 'change_own_find']),
+ access_controls=['change_treatment',
+ 'change_own_treatment']),
]),
SectionItem(
'admin_act_treatments', _(u"Administrative act"),
diff --git a/archaeological_finds/locale/django.pot b/archaeological_finds/locale/django.pot
index 21cfba64a..dcbf94fca 100644
--- a/archaeological_finds/locale/django.pot
+++ b/archaeological_finds/locale/django.pot
@@ -5,332 +5,349 @@
# Valérie-Emma Leroux <emma@iggdrasil.net>, 2016. #zanata
# Étienne Loks <etienne.loks@iggdrasil.net>, 2016. #zanata
# Valérie-Emma Leroux <emma@iggdrasil.net>, 2017. #zanata
+# Étienne Loks <etienne.loks@iggdrasil.net>, 2017. #zanata
msgid ""
msgstr ""
-#: forms.py:90 forms.py:94 models_finds.py:505 wizards.py:64
+#: forms.py:93 forms.py:97 models_finds.py:518 wizards.py:64
msgid "Context record"
msgstr ""
-#: forms.py:123 ishtar_menu.py:32 models_finds.py:664 models_finds.py:1067
-#: models_finds.py:1076 models_treatments.py:281
+#: forms.py:126 ishtar_menu.py:32 models_finds.py:682 models_finds.py:1113
+#: models_finds.py:1134 models_treatments.py:281
#: templates/ishtar/sheet_find.html:5
msgid "Find"
msgstr ""
-#: forms.py:137 forms.py:330 forms.py:559 models_finds.py:151
-#: models_finds.py:595
+#: forms.py:140 forms.py:337 forms.py:605 models_finds.py:150
+#: models_finds.py:612
msgid "Free ID"
msgstr ""
-#: forms.py:139 models_finds.py:647
+#: forms.py:142 models_finds.py:665
msgid "Previous ID"
msgstr ""
-#: forms.py:140 forms.py:362 forms_treatments.py:134 models_finds.py:155
-#: models_finds.py:596 models_treatments.py:127
+#: forms.py:143 forms.py:368 forms_treatments.py:134 models_finds.py:154
+#: models_finds.py:613 models_treatments.py:127
msgid "Description"
msgstr ""
-#: forms.py:143 forms.py:364 models_finds.py:164
+#: forms.py:146 forms.py:370 models_finds.py:163
msgid "Batch/object"
msgstr ""
-#: forms.py:145 models_finds.py:624
+#: forms.py:148 models_finds.py:642
msgid "Is complete?"
msgstr ""
-#: forms.py:148 forms.py:352 forms.py:563 models_finds.py:51
+#: forms.py:151 forms.py:358 forms.py:609 models_finds.py:50
msgid "Material type"
msgstr ""
-#: forms.py:149 forms.py:356 models_finds.py:63 models_finds.py:600
+#: forms.py:154 forms.py:362 models_finds.py:62 models_finds.py:617
msgid "Conservatory state"
msgstr ""
-#: forms.py:152 models_finds.py:602
+#: forms.py:157 models_finds.py:619
msgid "Conservatory comment"
msgstr ""
-#: forms.py:155 models_finds.py:113 models_finds.py:627
+#: forms.py:160 models_finds.py:112 models_finds.py:645
msgid "Object types"
msgstr ""
-#: forms.py:157 forms.py:355 models_finds.py:72
+#: forms.py:164 forms.py:361 models_finds.py:71
msgid "Preservation type"
msgstr ""
-#: forms.py:160 forms.py:358 models_finds.py:629
+#: forms.py:167 forms.py:364 models_finds.py:647
msgid "Integrity / interest"
msgstr ""
-#: forms.py:163 forms.py:360 models_finds.py:632
+#: forms.py:170 forms.py:366 models_finds.py:650
msgid "Remarkability"
msgstr ""
-#: forms.py:166 models_finds.py:169
+#: forms.py:173 models_finds.py:168
msgid "Point of topographic reference"
msgstr ""
-#: forms.py:169 models_finds.py:171
+#: forms.py:176 models_finds.py:170
msgid "X"
msgstr ""
-#: forms.py:170 models_finds.py:172
+#: forms.py:177 models_finds.py:171
msgid "Y"
msgstr ""
-#: forms.py:171 models_finds.py:173
+#: forms.py:178 models_finds.py:172
msgid "Z"
msgstr ""
-#: forms.py:173 models_finds.py:181
+#: forms.py:180 models_finds.py:180
msgid "Spatial Reference System"
msgstr ""
-#: forms.py:176 models_finds.py:174
+#: forms.py:183 models_finds.py:173
msgid "Estimated error for X"
msgstr ""
-#: forms.py:178 models_finds.py:176
+#: forms.py:185 models_finds.py:175
msgid "Estimated error for Y"
msgstr ""
-#: forms.py:180 models_finds.py:178
+#: forms.py:187 models_finds.py:177
msgid "Estimated error for Z"
msgstr ""
-#: forms.py:181 models_finds.py:636
+#: forms.py:188 models_finds.py:654
msgid "Length (cm)"
msgstr ""
-#: forms.py:182 models_finds.py:637
+#: forms.py:189 models_finds.py:655
msgid "Width (cm)"
msgstr ""
-#: forms.py:183 models_finds.py:638
+#: forms.py:190 models_finds.py:656
msgid "Height (cm)"
msgstr ""
-#: forms.py:184 models_finds.py:639
+#: forms.py:191 models_finds.py:657
msgid "Diameter (cm)"
msgstr ""
-#: forms.py:185 models_finds.py:640
+#: forms.py:192 models_finds.py:658
msgid "Thickness (cm)"
msgstr ""
-#: forms.py:186 forms.py:564 models_finds.py:607
+#: forms.py:193 forms.py:610 models_finds.py:624
msgid "Volume (l)"
msgstr ""
-#: forms.py:187 forms.py:565 models_finds.py:608
+#: forms.py:194 forms.py:611 models_finds.py:625
msgid "Weight (g)"
msgstr ""
-#: forms.py:189 models_finds.py:641
+#: forms.py:196 models_finds.py:659
msgid "Dimensions comment"
msgstr ""
-#: forms.py:190 forms.py:566 models_finds.py:611
+#: forms.py:197 forms.py:612 models_finds.py:628
msgid "Find number"
msgstr ""
-#: forms.py:192 models_finds.py:635
+#: forms.py:199 models_finds.py:653
msgid "Minimum number of individuals (MNI)"
msgstr ""
-#: forms.py:193 models_finds.py:643
+#: forms.py:200 models_finds.py:661
msgid "Mark"
msgstr ""
-#: forms.py:194 forms.py:365 models_finds.py:649
+#: forms.py:201 forms.py:371 models_finds.py:667
msgid "Check"
msgstr ""
-#: forms.py:196 models_finds.py:651
+#: forms.py:203 models_finds.py:669
msgid "Check date"
msgstr ""
-#: forms.py:197 forms_treatments.py:132 forms_treatments.py:434
-#: models_finds.py:156 models_finds.py:644 models_treatments.py:126
+#: forms.py:204 forms_treatments.py:132 forms_treatments.py:434
+#: models_finds.py:155 models_finds.py:662 models_treatments.py:126
#: models_treatments.py:494
msgid "Comment"
msgstr ""
-#: forms.py:200 models_finds.py:645
+#: forms.py:207 models_finds.py:663
msgid "Comment on dating"
msgstr ""
-#: forms.py:201 models_finds.py:653
+#: forms.py:208 models_finds.py:671
msgid "Estimated value"
msgstr ""
-#: forms.py:203 forms_treatments.py:151
+#: forms.py:210 forms_treatments.py:151
msgid "Image"
msgstr ""
-#: forms.py:204 forms_treatments.py:152
+#: forms.py:211 forms_treatments.py:152
#, python-format
msgid ""
"<p>Heavy images are resized to: %(width)dx%(height)d (ratio is preserved).</"
"p>"
msgstr ""
-#: forms.py:278
+#: forms.py:285
msgid "You should at least provide X, Y and the spatial reference system used."
msgstr ""
-#: forms.py:287
+#: forms.py:294
msgid "Coordinates are not relevant for the spatial reference system used: {}."
msgstr ""
-#: forms.py:293 forms.py:324 models_finds.py:619
+#: forms.py:300 forms.py:331 models_finds.py:636
msgid "Dating"
msgstr ""
-#: forms.py:298 forms.py:350
+#: forms.py:305 forms.py:357
msgid "Period"
msgstr ""
-#: forms.py:299 forms_treatments.py:138 forms_treatments.py:436
-#: models_finds.py:1081 models_treatments.py:129 models_treatments.py:292
+#: forms.py:306 forms_treatments.py:138 forms_treatments.py:436
+#: models_finds.py:1139 models_treatments.py:129 models_treatments.py:292
#: templates/ishtar/sheet_find.html:91 templates/ishtar/sheet_find.html:133
msgid "Start date"
msgstr ""
-#: forms.py:301 models_finds.py:1082 models_treatments.py:293
+#: forms.py:308 models_finds.py:1140 models_treatments.py:293
#: templates/ishtar/sheet_find.html:92 templates/ishtar/sheet_find.html:134
msgid "End date"
msgstr ""
-#: forms.py:302
+#: forms.py:309
msgid "Quality"
msgstr ""
-#: forms.py:304
+#: forms.py:311
msgid "Dating type"
msgstr ""
-#: forms.py:306
+#: forms.py:313
msgid "Precise dating"
msgstr ""
-#: forms.py:328 models_finds.py:188
+#: forms.py:335 models_finds.py:187
msgid "Short ID"
msgstr ""
-#: forms.py:329 models_finds.py:191
+#: forms.py:336 models_finds.py:190
msgid "Complete ID"
msgstr ""
-#: forms.py:333 forms_treatments.py:54 forms_treatments.py:96
+#: forms.py:340 forms_treatments.py:54 forms_treatments.py:96
#: forms_treatments.py:284 forms_treatments.py:356 forms_treatments.py:406
#: forms_treatments.py:489 models_treatments.py:102 models_treatments.py:466
msgid "Year"
msgstr ""
-#: forms.py:335
+#: forms.py:342
msgid "Operation's number (index by year)"
msgstr ""
-#: forms.py:338
+#: forms.py:345
msgid "Code PATRIARCHE"
msgstr ""
-#: forms.py:342
+#: forms.py:349
msgid "Archaeological site"
msgstr ""
-#: forms.py:348
+#: forms.py:355
msgid "Search within related operations"
msgstr ""
-#: forms.py:353 models_finds.py:112
+#: forms.py:359 models_finds.py:111
msgid "Object type"
msgstr ""
-#: forms.py:366 forms_treatments.py:57
+#: forms.py:372 forms_treatments.py:57
msgid "Has an image?"
msgstr ""
-#: forms.py:414 forms.py:427 views.py:130
+#: forms.py:421
+msgid "Warehouse (location)"
+msgstr ""
+
+#: forms.py:427
+msgid "Warehouse (responsible)"
+msgstr ""
+
+#: forms.py:432
+msgid "Container ID"
+msgstr ""
+
+#: forms.py:433
+msgid "Container ref."
+msgstr ""
+
+#: forms.py:437 forms.py:460 views.py:149
msgid "Find search"
msgstr ""
-#: forms.py:441 templates/ishtar/sheet_treatment.html:46
+#: forms.py:485 templates/ishtar/sheet_treatment.html:46
msgid "Upstream finds"
msgstr ""
-#: forms.py:443 models_finds.py:665
+#: forms.py:487 models_finds.py:683
msgid "Finds"
msgstr ""
-#: forms.py:453
+#: forms.py:499
msgid "You should at least select one archaeological find."
msgstr ""
-#: forms.py:556
+#: forms.py:602
msgid "Resulting find"
msgstr ""
-#: forms.py:561
+#: forms.py:607
msgid "Precise description"
msgstr ""
-#: forms.py:576
+#: forms.py:622
msgid "Resulting finds"
msgstr ""
-#: forms.py:581
+#: forms.py:627
msgid "Would you like to delete this find?"
msgstr ""
-#: forms.py:585 models_treatments.py:90
+#: forms.py:631 models_treatments.py:90
msgid "Upstream find"
msgstr ""
-#: forms.py:598
+#: forms.py:644
msgid "Archaeological find search"
msgstr ""
-#: forms.py:600
+#: forms.py:646
msgid "You should select an archaeological find."
msgstr ""
-#: forms.py:605
+#: forms.py:651
msgid "Year of the operation"
msgstr ""
-#: forms.py:607
+#: forms.py:653
msgid "Numeric reference"
msgstr ""
-#: forms.py:614
+#: forms.py:660
msgid "Period of the archaeological find"
msgstr ""
-#: forms.py:616
+#: forms.py:662
msgid "Material type of the archaeological find"
msgstr ""
-#: forms.py:618
+#: forms.py:664
msgid "Description of the archaeological find"
msgstr ""
-#: forms.py:630 forms_treatments.py:590 forms_treatments.py:616
+#: forms.py:676 forms_treatments.py:590 forms_treatments.py:616
msgid "Documentation search"
msgstr ""
-#: forms.py:632 forms_treatments.py:592 forms_treatments.py:618
+#: forms.py:678 forms_treatments.py:592 forms_treatments.py:618
msgid "You should select a document."
msgstr ""
-#: forms.py:649
+#: forms.py:695
msgid "Another basket already exists with this name."
msgstr ""
-#: forms.py:659 forms.py:663 forms_treatments.py:175 ishtar_menu.py:57
+#: forms.py:705 forms.py:709 forms_treatments.py:175 ishtar_menu.py:57
msgid "Basket"
msgstr ""
@@ -356,7 +373,7 @@ msgstr ""
msgid "Treatment type"
msgstr ""
-#: forms_treatments.py:68 forms_treatments.py:560 views.py:360
+#: forms_treatments.py:68 forms_treatments.py:560 views.py:398
msgid "Treatment search"
msgstr ""
@@ -449,8 +466,8 @@ msgid "Associated request"
msgstr ""
#: forms_treatments.py:266 forms_treatments.py:397 ishtar_menu.py:108
-#: models_treatments.py:499 models_treatments.py:521 models_treatments.py:583
-#: wizards.py:183 templates/ishtar/sheet_treatmentfile.html:5
+#: models_treatments.py:499 models_treatments.py:527 models_treatments.py:602
+#: wizards.py:187 templates/ishtar/sheet_treatmentfile.html:5
msgid "Treatment request"
msgstr ""
@@ -533,7 +550,7 @@ msgstr ""
msgid "Applicant organisation"
msgstr ""
-#: forms_treatments.py:385 forms_treatments.py:565 views.py:464
+#: forms_treatments.py:385 forms_treatments.py:565 views.py:502
msgid "Treatment request search"
msgstr ""
@@ -612,7 +629,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
-#: ishtar_menu.py:133 ishtar_menu.py:214 models_finds.py:1078
+#: ishtar_menu.py:133 ishtar_menu.py:214 models_finds.py:1136
msgid "Administrative act"
msgstr ""
@@ -626,7 +643,8 @@ msgid "Source"
msgstr ""
#: ishtar_menu.py:185 models_treatments.py:147 models_treatments.py:283
-#: models_treatments.py:567 templates/ishtar/sheet_treatment.html:5
+#: models_treatments.py:573 models_treatments.py:576
+#: templates/ishtar/sheet_treatment.html:5
msgid "Treatment"
msgstr ""
@@ -634,113 +652,113 @@ msgstr ""
msgid "Simple treatments"
msgstr ""
-#: models_finds.py:44
+#: models_finds.py:43
msgid "Code"
msgstr ""
-#: models_finds.py:45
+#: models_finds.py:44
msgid "Recommendation"
msgstr ""
-#: models_finds.py:48
+#: models_finds.py:47
msgid "Parent material"
msgstr ""
-#: models_finds.py:52 models_finds.py:525 models_finds.py:598
+#: models_finds.py:51 models_finds.py:538 models_finds.py:615
msgid "Material types"
msgstr ""
-#: models_finds.py:60
+#: models_finds.py:59
msgid "Parent conservatory state"
msgstr ""
-#: models_finds.py:64
+#: models_finds.py:63
msgid "Conservatory states"
msgstr ""
-#: models_finds.py:73
+#: models_finds.py:72
msgid "Preservation types"
msgstr ""
-#: models_finds.py:81
+#: models_finds.py:80
msgid "Integrity / interest type"
msgstr ""
-#: models_finds.py:82
+#: models_finds.py:81
msgid "Integrity / interest types"
msgstr ""
-#: models_finds.py:90
+#: models_finds.py:89
msgid "Remarkability type"
msgstr ""
-#: models_finds.py:91
+#: models_finds.py:90
msgid "Remarkability types"
msgstr ""
-#: models_finds.py:98 models_finds.py:594 models_treatments.py:40
+#: models_finds.py:97 models_finds.py:611 models_treatments.py:40
#: models_treatments.py:287
msgid "Order"
msgstr ""
-#: models_finds.py:100
+#: models_finds.py:99
msgid "Batch type"
msgstr ""
-#: models_finds.py:101
+#: models_finds.py:100
msgid "Batch types"
msgstr ""
-#: models_finds.py:109
+#: models_finds.py:108
msgid "Parent"
msgstr ""
-#: models_finds.py:152 models_finds.py:591 models_treatments.py:124
+#: models_finds.py:151 models_finds.py:608 models_treatments.py:124
#: models_treatments.py:471
msgid "External ID"
msgstr ""
-#: models_finds.py:154 models_finds.py:593
+#: models_finds.py:153 models_finds.py:610
msgid "External ID is set automatically"
msgstr ""
-#: models_finds.py:157
+#: models_finds.py:156
msgid "Special interest"
msgstr ""
-#: models_finds.py:161
+#: models_finds.py:160
msgid "Context Record"
msgstr ""
-#: models_finds.py:162
+#: models_finds.py:161
msgid "Discovery date"
msgstr ""
-#: models_finds.py:167
+#: models_finds.py:166
msgid "Material index"
msgstr ""
-#: models_finds.py:183
+#: models_finds.py:182
msgid "Point (2D)"
msgstr ""
-#: models_finds.py:184
+#: models_finds.py:183
msgid "Point"
msgstr ""
-#: models_finds.py:185
+#: models_finds.py:184
msgid "Line"
msgstr ""
-#: models_finds.py:186
+#: models_finds.py:185
msgid "Polygon"
msgstr ""
-#: models_finds.py:189 models_finds.py:192
+#: models_finds.py:188 models_finds.py:191
msgid "Cached value - do not edit"
msgstr ""
-#: models_finds.py:197 models_finds.py:589
+#: models_finds.py:197 models_finds.py:606
msgid "Base find"
msgstr ""
@@ -768,149 +786,169 @@ msgstr ""
msgid "Can delete own Base find"
msgstr ""
-#: models_finds.py:430
+#: models_finds.py:443
msgid "g"
msgstr ""
-#: models_finds.py:431
+#: models_finds.py:444
msgid "kg"
msgstr ""
-#: models_finds.py:433
+#: models_finds.py:446
msgid "Not checked"
msgstr ""
-#: models_finds.py:434
+#: models_finds.py:447
msgid "Checked but incorrect"
msgstr ""
-#: models_finds.py:435
+#: models_finds.py:448
msgid "Checked and correct"
msgstr ""
-#: models_finds.py:506
+#: models_finds.py:519
msgid "Base find - Short ID"
msgstr ""
-#: models_finds.py:507
+#: models_finds.py:520
msgid "Base find - Complete ID"
msgstr ""
-#: models_finds.py:509
+#: models_finds.py:522
msgid "Operation (code)"
msgstr ""
-#: models_finds.py:511
+#: models_finds.py:524
msgid "Town"
msgstr ""
-#: models_finds.py:513
+#: models_finds.py:526
msgid "Operation (name)"
msgstr ""
-#: models_finds.py:515
+#: models_finds.py:528
msgid "Parcel"
msgstr ""
-#: models_finds.py:516
+#: models_finds.py:529
msgid "Batch"
msgstr ""
-#: models_finds.py:517
+#: models_finds.py:530
msgid "Base find - Comment"
msgstr ""
-#: models_finds.py:518
+#: models_finds.py:531
msgid "Base find - Description"
msgstr ""
-#: models_finds.py:519
+#: models_finds.py:532
msgid "Base find - Topographic localisation"
msgstr ""
-#: models_finds.py:521
+#: models_finds.py:534
msgid "Base find - Special interest"
msgstr ""
-#: models_finds.py:522
+#: models_finds.py:535
msgid "Base find - Discovery date"
msgstr ""
-#: models_finds.py:523 models_finds.py:622 models_treatments.py:131
+#: models_finds.py:536 models_finds.py:639 models_treatments.py:131
#: models_treatments.py:295 templates/ishtar/sheet_find.html:90
#: templates/ishtar/sheet_find.html:132
msgid "Container"
msgstr ""
-#: models_finds.py:524
+#: models_finds.py:537
msgid "Periods"
msgstr ""
-#: models_finds.py:605
+#: models_finds.py:622
msgid "Type of preservation to consider"
msgstr ""
-#: models_finds.py:609
+#: models_finds.py:626
msgid "Weight unit"
msgstr ""
-#: models_finds.py:615 templates/ishtar/sheet_find.html:78
+#: models_finds.py:632 templates/ishtar/sheet_find.html:78
msgid "Upstream treatment"
msgstr ""
-#: models_finds.py:618 templates/ishtar/sheet_find.html:120
+#: models_finds.py:635 templates/ishtar/sheet_find.html:120
msgid "Downstream treatment"
msgstr ""
-#: models_finds.py:656
+#: models_finds.py:674
msgid "Collection"
msgstr ""
-#: models_finds.py:658 models_treatments.py:143 models_treatments.py:495
+#: models_finds.py:676 models_treatments.py:143 models_treatments.py:495
msgid "Cached name"
msgstr ""
-#: models_finds.py:667
+#: models_finds.py:685
msgid "Can view all Finds"
msgstr ""
-#: models_finds.py:668
+#: models_finds.py:686
msgid "Can view own Find"
msgstr ""
-#: models_finds.py:669
+#: models_finds.py:687
msgid "Can add own Find"
msgstr ""
-#: models_finds.py:670
+#: models_finds.py:688
msgid "Can change own Find"
msgstr ""
-#: models_finds.py:671
+#: models_finds.py:689
msgid "Can delete own Find"
msgstr ""
-#: models_finds.py:677
+#: models_finds.py:695
msgid "FIND"
msgstr ""
-#: models_finds.py:1065
+#: models_finds.py:1099
msgid "Find documentation"
msgstr ""
-#: models_finds.py:1066
+#: models_finds.py:1100
msgid "Find documentations"
msgstr ""
-#: models_finds.py:1079
+#: models_finds.py:1103
+msgid "Can view all Find sources"
+msgstr ""
+
+#: models_finds.py:1105
+msgid "Can view own Find source"
+msgstr ""
+
+#: models_finds.py:1107
+msgid "Can add own Find source"
+msgstr ""
+
+#: models_finds.py:1109
+msgid "Can change own Find source"
+msgstr ""
+
+#: models_finds.py:1111
+msgid "Can delete own Find source"
+msgstr ""
+
+#: models_finds.py:1137
msgid "Person"
msgstr ""
-#: models_finds.py:1085
+#: models_finds.py:1143
msgid "Property"
msgstr ""
-#: models_finds.py:1086
+#: models_finds.py:1144
msgid "Properties"
msgstr ""
@@ -979,7 +1017,7 @@ msgid "Target a basket"
msgstr ""
#: models_treatments.py:148 templates/ishtar/sheet_find.html:75
-#: templates/ishtar/sheet_treatmentfile.html:45
+#: templates/ishtar/sheet_treatmentfile.html:46
msgid "Treatments"
msgstr ""
@@ -1045,158 +1083,226 @@ msgid "Can view all Treatment requests"
msgstr ""
#: models_treatments.py:506
-msgid "Can view own Treatment request"
+msgid "Can add Treatment request"
msgstr ""
#: models_treatments.py:508
-msgid "Can add own Treatment request"
+msgid "Can change Treatment request"
msgstr ""
#: models_treatments.py:510
-msgid "Can change own Treatment request"
+msgid "Can delete Treatment request"
msgstr ""
#: models_treatments.py:512
+msgid "Can view own Treatment request"
+msgstr ""
+
+#: models_treatments.py:514
+msgid "Can add own Treatment request"
+msgstr ""
+
+#: models_treatments.py:516
+msgid "Can change own Treatment request"
+msgstr ""
+
+#: models_treatments.py:518
msgid "Can delete own Treatment request"
msgstr ""
-#: models_treatments.py:573
+#: models_treatments.py:580
msgid "Treatment documentation"
msgstr ""
-#: models_treatments.py:574
+#: models_treatments.py:581
msgid "Treament documentations"
msgstr ""
+#: models_treatments.py:584
+msgid "Can view all Treatment source"
+msgstr ""
+
+#: models_treatments.py:586
+msgid "Can view own Treatment source"
+msgstr ""
+
+#: models_treatments.py:588
+msgid "Can add own Treatment source"
+msgstr ""
+
#: models_treatments.py:590
+msgid "Can change own Treatment source"
+msgstr ""
+
+#: models_treatments.py:592
+msgid "Can delete own Treatment source"
+msgstr ""
+
+#: models_treatments.py:606
+msgid "Treatment file"
+msgstr ""
+
+#: models_treatments.py:610
msgid "Treatment request documentation"
msgstr ""
-#: models_treatments.py:591
+#: models_treatments.py:611
msgid "Treatment request documentations"
msgstr ""
-#: views.py:125
+#: models_treatments.py:614
+msgid "Can view all Treatment request source"
+msgstr ""
+
+#: models_treatments.py:616
+msgid "Can add Treatment request source"
+msgstr ""
+
+#: models_treatments.py:618
+msgid "Can change Treatment request source"
+msgstr ""
+
+#: models_treatments.py:620
+msgid "Can delete Treatment request source"
+msgstr ""
+
+#: models_treatments.py:622
+msgid "Can view own Treatment request source"
+msgstr ""
+
+#: models_treatments.py:624
+msgid "Can add own Treatment request source"
+msgstr ""
+
+#: models_treatments.py:626
+msgid "Can change own Treatment request source"
+msgstr ""
+
+#: models_treatments.py:628
+msgid "Can delete own Treatment request source"
+msgstr ""
+
+#: views.py:138
msgid "New find"
msgstr ""
-#: views.py:139
+#: views.py:167
msgid "Find modification"
msgstr ""
-#: views.py:154
+#: views.py:189
msgid "Find deletion"
msgstr ""
-#: views.py:159
+#: views.py:194
msgid "Find: source search"
msgstr ""
-#: views.py:167
+#: views.py:202
msgid "Find: new source"
msgstr ""
-#: views.py:175
+#: views.py:210
msgid "Find: source modification"
msgstr ""
-#: views.py:190
+#: views.py:225
msgid "Find: source deletion"
msgstr ""
-#: views.py:204
+#: views.py:239
msgid "New basket"
msgstr ""
-#: views.py:223
+#: views.py:258
msgid "Manage items in basket"
msgstr ""
-#: views.py:243
+#: views.py:278
msgid "Manage basket"
msgstr ""
-#: views.py:331
+#: views.py:369
msgid "Delete basket"
msgstr ""
-#: views.py:381
+#: views.py:419
msgid "New treatment"
msgstr ""
-#: views.py:389 views.py:481
+#: views.py:427 views.py:519
msgid "Modify"
msgstr ""
-#: views.py:406
+#: views.py:444
msgid "Treatment deletion"
msgstr ""
-#: views.py:413
+#: views.py:451
msgid "Treatment: search administrative act"
msgstr ""
-#: views.py:422
+#: views.py:460
msgid "Treatment: new administrative act"
msgstr ""
-#: views.py:432
+#: views.py:470
msgid "Treatment: administrative act modification"
msgstr ""
-#: views.py:441
+#: views.py:479
msgid "Treatment: administrative act deletion"
msgstr ""
-#: views.py:474
+#: views.py:512
msgid "New treatment request"
msgstr ""
-#: views.py:497
+#: views.py:535
msgid "Treatment request deletion"
msgstr ""
-#: views.py:504
+#: views.py:542
msgid "Treatment request: search administrative act"
msgstr ""
-#: views.py:514
+#: views.py:552
msgid "Treatment request: new administrative act"
msgstr ""
-#: views.py:524
+#: views.py:562
msgid "Treatment request: administrative act modification"
msgstr ""
-#: views.py:533
+#: views.py:571
msgid "Treatment request: administrative act deletion"
msgstr ""
-#: views.py:559
+#: views.py:597
msgid "Treatment: source search"
msgstr ""
-#: views.py:574
+#: views.py:612
msgid "Treatment: source modification"
msgstr ""
-#: views.py:589
+#: views.py:627
msgid "Treatment: source deletion"
msgstr ""
-#: views.py:602
+#: views.py:640
msgid "Treatment request: source search"
msgstr ""
-#: views.py:618
+#: views.py:656
msgid "Treatment request: source modification"
msgstr ""
-#: views.py:636
+#: views.py:674
msgid "Treatment request: source deletion"
msgstr ""
-#: wizards.py:63 wizards.py:195
+#: wizards.py:63 wizards.py:199
msgid "Operation"
msgstr ""
@@ -1294,6 +1400,16 @@ msgstr ""
msgid "Related operations"
msgstr ""
+#: templates/ishtar/sheet_treatment.html:60
+#: templates/ishtar/sheet_treatmentfile.html:51
+msgid "Associated documents"
+msgstr ""
+
+#: templates/ishtar/sheet_treatment.html:65
+#: templates/ishtar/sheet_treatmentfile.html:56
+msgid "Administrative acts"
+msgstr ""
+
#: templates/ishtar/sheet_treatmentfile.html:16
msgctxt "Treatment request"
msgid "Closed"
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 4ece0b286..d33933264 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -31,13 +31,12 @@ from ishtar_common.utils import cached_label_changed, post_save_point
from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \
ShortMenuItem, LightHistorizedItem, HistoricalRecords, OwnPerms, Source, \
- Person, Basket, get_external_id, post_save_cache
+ Person, Basket, get_external_id, post_save_cache, ValueGetter
from archaeological_operations.models import AdministrativeAct
from archaeological_context_records.models import ContextRecord, Dating
from ishtar_common.models import PRIVATE_FIELDS, SpatialReferenceSystem
-from archaeological_warehouse.models import Container, Collection
class MaterialType(GeneralType):
@@ -192,6 +191,7 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
help_text=_(u"Cached value - do not edit"))
history = HistoricalRecords()
RELATED_POST_PROCESS = ['find']
+ CACHED_LABELS = ['cache_short_id', 'cache_complete_id']
class Meta:
verbose_name = _(u"Base find")
@@ -254,6 +254,9 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
).format(self.index))
return settings.JOINT.join(c_id)
+ def _generate_cache_complete_id(self):
+ return self.complete_id()
+
def short_id(self):
# OPE|FIND_index
c_id = [self._ope_code()]
@@ -261,6 +264,9 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
).format(self.index))
return settings.JOINT.join(c_id)
+ def _generate_cache_short_id(self):
+ return self.short_id()
+
def full_label(self):
return self._real_label() or self._temp_label() or u""
@@ -323,7 +329,8 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
return returned
@classmethod
- def cached_label_bulk_update(cls, operation_id=None, parcel_id=None):
+ def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
+ context_record_id=None):
if operation_id:
filters = """
INNER JOIN archaeological_context_records_contextrecord acr
@@ -338,6 +345,12 @@ class BaseFind(BaseHistorizedItem, OwnPerms):
"""
args = [int(parcel_id)]
kwargs = {'parcel_id': parcel_id}
+ elif context_record_id:
+ filters = """
+ WHERE mybf.context_record_id = %s
+ """
+ args = [int(context_record_id)]
+ kwargs = {'context_record_id': context_record_id}
else:
return
@@ -477,7 +490,8 @@ class FBulkView(object):
"""
-class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
+class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms,
+ ShortMenuItem):
CHECK_DICT = dict(CHECK_CHOICES)
SHOW_URL = 'show-find'
SLUG = 'find'
@@ -571,6 +585,10 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
'basket': 'basket',
'cached_label': 'cached_label__icontains',
'image__isnull': 'image__isnull',
+ 'container__location': 'container__location__pk',
+ 'container__responsible': 'container__responsible__pk',
+ 'container__index': 'container__index',
+ 'container__reference': 'container__reference',
}
EXTRA_REQUEST_KEYS.update(
dict(
@@ -619,7 +637,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
datings = models.ManyToManyField(Dating, verbose_name=_(u"Dating"),
related_name='find')
container = models.ForeignKey(
- Container, verbose_name=_(u"Container"), blank=True, null=True,
+ "archaeological_warehouse.Container", verbose_name=_(u"Container"),
+ blank=True, null=True,
related_name='finds', on_delete=models.SET_NULL)
is_complete = models.NullBooleanField(_(u"Is complete?"), blank=True,
null=True)
@@ -653,8 +672,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
estimated_value = models.FloatField(_(u"Estimated value"), blank=True,
null=True)
collection = models.ForeignKey(
- Collection, verbose_name=_(u"Collection"), blank=True, null=True,
- related_name='finds', on_delete=models.SET_NULL)
+ "archaeological_warehouse.Collection", verbose_name=_(u"Collection"),
+ blank=True, null=True, related_name='finds', on_delete=models.SET_NULL)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True)
history = HistoricalRecords()
BASKET_MODEL = FindBasket
@@ -843,16 +862,20 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
def duplicate(self, user):
model = self.__class__
- # base fields
- table_cols = [field.name for field in model._meta.fields
- if field.name not in PRIVATE_FIELDS or
- field.name == 'order']
- dct = dict([(attr, getattr(self, attr)) for attr in
- table_cols])
- dct['order'] += 1
- dct['history_modifier'] = user
- new = self.__class__(**dct)
- new.save()
+
+ new = model.objects.get(pk=self.pk)
+
+ for field in model._meta.fields:
+ # pk is in PRIVATE_FIELDS so: new.pk = None and a new
+ # item will be created on save
+ if field.name in PRIVATE_FIELDS:
+ setattr(new, field.name, None)
+ new.order = self.order + 1
+ new.history_order = user
+ new.image.name = self.image.name
+ # force_copy is necessary to not regenerate a thumb and resize
+ # again the image
+ new.save(force_copy=True)
# m2m fields
m2m = [field.name for field in model._meta.many_to_many
@@ -864,11 +887,14 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
@classmethod
def get_query_owns(cls, user):
- return Q(base_finds__context_record__operation__scientist=user.
- ishtaruser.person) | \
- Q(base_finds__context_record__operation__in_charge=user.
- ishtaruser.person) | \
- Q(history_creator=user)
+ return (Q(base_finds__context_record__operation__scientist=user.
+ ishtaruser.person) |
+ Q(base_finds__context_record__operation__in_charge=user.
+ ishtaruser.person) |
+ Q(base_finds__context_record__operation__collaborators__pk=user.
+ ishtaruser.person.pk) |
+ Q(history_creator=user)) \
+ & Q(base_finds__context_record__operation__end_date__isnull=True)
@classmethod
def get_owns(cls, user, menu_filtr=None, limit=None,
@@ -887,7 +913,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
return unicode(self)
@classmethod
- def cached_label_bulk_update(cls, operation_id=None, parcel_id=None):
+ def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
+ context_record_id=None):
if operation_id:
filters = """
INNER JOIN find_first_base_find myfbf
@@ -908,6 +935,14 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
ON acr.parcel_id = %s AND acr.id = mybf.context_record_id
"""
args = [int(parcel_id)]
+ elif context_record_id:
+ filters = """
+ INNER JOIN find_first_base_find myfbf
+ ON myfbf.find_id = myf.id
+ INNER JOIN archaeological_finds_basefind mybf
+ ON myfbf.basefind_id = mybf.id AND mybf.context_record_id = %s
+ """
+ args = [int(context_record_id)]
else:
return
@@ -1064,6 +1099,18 @@ class FindSource(Source):
class Meta:
verbose_name = _(u"Find documentation")
verbose_name_plural = _(u"Find documentations")
+ permissions = (
+ ("view_findsource",
+ ugettext(u"Can view all Find sources")),
+ ("view_own_findsource",
+ ugettext(u"Can view own Find source")),
+ ("add_own_findsource",
+ ugettext(u"Can add own Find source")),
+ ("change_own_findsource",
+ ugettext(u"Can change own Find source")),
+ ("delete_own_findsource",
+ ugettext(u"Can delete own Find source")),
+ )
find = models.ForeignKey(Find, verbose_name=_(u"Find"),
related_name="source")
@@ -1071,6 +1118,18 @@ class FindSource(Source):
def owner(self):
return self.find
+ @classmethod
+ def get_query_owns(cls, user):
+ return (Q(find__base_finds__context_record__operation__scientist=user.
+ ishtaruser.person) |
+ Q(find__base_finds__context_record__operation__in_charge=user.
+ ishtaruser.person) |
+ Q(
+ find__base_finds__context_record__operation__collaborators__pk=user.
+ ishtaruser.person.pk)) \
+ & Q(
+ find__base_finds__context_record__operation__end_date__isnull=True)
+
class Property(LightHistorizedItem):
find = models.ForeignKey(Find, verbose_name=_(u"Find"))
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 2efedbc22..20e91155a 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2016-2017 É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
@@ -30,7 +30,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from ishtar_common.utils import cached_label_changed
from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \
OwnPerms, HistoricalRecords, Person, Organization, Source, \
- ValueGetter, post_save_cache, ShortMenuItem
+ ValueGetter, post_save_cache, ShortMenuItem, DashboardFormItem
from archaeological_warehouse.models import Warehouse, Container
from archaeological_finds.models_finds import Find, FindBasket
from archaeological_operations.models import ClosedItem, Operation
@@ -69,7 +69,8 @@ post_save.connect(post_save_cache, sender=TreatmentState)
post_delete.connect(post_save_cache, sender=TreatmentState)
-class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
+class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
+ ImageModel, OwnPerms, ShortMenuItem):
SHOW_URL = 'show-treatment'
TABLE_COLS = ('year', 'index', 'treatment_types__label',
'treatment_state__label',
@@ -179,7 +180,8 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
if menu_filtr:
if 'treatmentfile' in menu_filtr:
replace_query = Q(file=menu_filtr['treatmentfile'])
- if 'find' in menu_filtr and 'basket' not in str(menu_filtr['find']):
+ if 'find' in menu_filtr and \
+ 'basket' not in str(menu_filtr['find']):
q = Q(upstream=menu_filtr['find']) | Q(
downstream=menu_filtr['find'])
if replace_query:
@@ -208,6 +210,21 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
"""
return u" ; ".join([unicode(t) for t in self.treatment_types.all()])
+ def get_values(self, prefix=''):
+ values = super(Treatment, self).get_values(prefix=prefix)
+ values[prefix + "upstream_finds"] = u" ; ".join(
+ [unicode(up) for up in self.upstream.all()])
+ values[prefix + "downstream_finds"] = u" ; ".join(
+ [unicode(down) for down in self.downstream.all()])
+ values[prefix + "operations"] = u" ; ".join(
+ [unicode(ope) for ope in self.get_query_operations().all()])
+ if self.upstream.count():
+ find = self.upstream.all()[0]
+ if 'associatedfind_' not in prefix:
+ values.update(
+ find.get_values(prefix=prefix + 'associatedfind_'))
+ return values
+
def pre_save(self):
# is not new
if self.pk is not None:
@@ -455,8 +472,8 @@ post_save.connect(post_save_cache, sender=TreatmentFileType)
post_delete.connect(post_save_cache, sender=TreatmentFileType)
-class TreatmentFile(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
- ShortMenuItem):
+class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem,
+ OwnPerms, ValueGetter, ShortMenuItem):
SLUG = 'treatmentfile'
SHOW_URL = 'show-treatmentfile'
TABLE_COLS = ['type', 'year', 'index', 'internal_reference', 'name']
@@ -502,6 +519,12 @@ class TreatmentFile(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
permissions = (
("view_filetreatment",
ugettext(u"Can view all Treatment requests")),
+ ("add_filetreatment",
+ ugettext(u"Can add Treatment request")),
+ ("change_filetreatment",
+ ugettext(u"Can change Treatment request")),
+ ("delete_filetreatment",
+ ugettext(u"Can delete Treatment request")),
("view_own_filetreatment",
ugettext(u"Can view own Treatment request")),
("add_own_filetreatment",
@@ -567,11 +590,24 @@ class TreatmentSource(Source):
Treatment, verbose_name=_(u"Treatment"), related_name="source")
BOOL_FIELDS = ['duplicate']
TABLE_COLS = ['treatment__cached_label'] + Source.TABLE_COLS
+ COL_LABELS = {'treatment__cached_label': _(u"Treatment")}
SHOW_URL = 'show-treatmentsource'
class Meta:
verbose_name = _(u"Treatment documentation")
verbose_name_plural = _(u"Treament documentations")
+ permissions = (
+ ("view_treatmentsource",
+ ugettext(u"Can view all Treatment source")),
+ ("view_own_treatmentsource",
+ ugettext(u"Can view own Treatment source")),
+ ("add_own_treatmentsource",
+ ugettext(u"Can add own Treatment source")),
+ ("change_own_treatmentsource",
+ ugettext(u"Can change own Treatment source")),
+ ("delete_own_treatmentsource",
+ ugettext(u"Can delete own Treatment source")),
+ )
@property
def owner(self):
@@ -584,11 +620,30 @@ class TreatmentFileSource(Source):
related_name="source")
BOOL_FIELDS = ['duplicate']
TABLE_COLS = ['treatment_file__cached_label'] + Source.TABLE_COLS
+ COL_LABELS = {'treatment_file__cached_label': _(u"Treatment file")}
SHOW_URL = 'show-treatmentfilesource'
class Meta:
verbose_name = _(u"Treatment request documentation")
verbose_name_plural = _(u"Treatment request documentations")
+ permissions = (
+ ("view_filetreatmentsource",
+ ugettext(u"Can view all Treatment request source")),
+ ("add_filetreatmentsource",
+ ugettext(u"Can add Treatment request source")),
+ ("change_filetreatmentsource",
+ ugettext(u"Can change Treatment request source")),
+ ("delete_filetreatmentsource",
+ ugettext(u"Can delete Treatment request source")),
+ ("view_own_filetreatmentsource",
+ ugettext(u"Can view own Treatment request source")),
+ ("add_own_filetreatmentsource",
+ ugettext(u"Can add own Treatment request source")),
+ ("change_own_filetreatmentsource",
+ ugettext(u"Can change own Treatment request source")),
+ ("delete_own_filetreatmentsource",
+ ugettext(u"Can delete own Treatment request source")),
+ )
@property
def owner(self):
diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html
index 6f8b12e6d..b6d4ffd42 100644
--- a/archaeological_finds/templates/ishtar/sheet_findbasket.html
+++ b/archaeological_finds/templates/ishtar/sheet_findbasket.html
@@ -9,5 +9,5 @@
<p class="window-refs">{{ item.label|default:"" }}</p>
{% field "Owned by" item.user %}
{% field "Comment" item.comment %}
-{% dynamic_table_document_large finds 'finds_for_ope' 'basket' item.pk 'TABLE_COLS_FOR_OPE' output %}
+{% dynamic_table_document finds 'finds_for_ope' 'basket' item.pk 'TABLE_COLS_FOR_OPE' output %}
{% endblock %}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html
index 633fa1829..9d6c75425 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatment.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatment.html
@@ -1,10 +1,10 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n window_field from_dict link_to_window window_tables window_header humanize %}
+{% load i18n window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %}
{% load url from future %}
{% block head_title %}{% trans "Treatment" %}{% endblock %}
{% block content %}
-{% window_nav item window_id 'show-treatment' 'treatment_modify' %}
+{% window_nav item window_id 'show-treatment' 'treatment_modify' 'show-historized-treatment' 'revert-treatment' previous next 1 %}
{% if item.image %}
<a href='{{item.image.url}}' rel="prettyPhoto" title="{{item.label}}" class='photo'><img src='{{item.thumbnail.url}}'/></a>
@@ -56,5 +56,14 @@
{% trans "Related operations" as related_operations %}
{% dynamic_table_document related_operations 'operations' 'related_treatment' item.pk 'TABLE_COLS' output %}
+{% if item.source.count %}
+{% trans "Associated documents" as associated_docs %}
+{% dynamic_table_document associated_docs 'treatments_docs' 'treatment' item.pk '' output %}
+{% endif %}
+
+{% if item.administrative_act.count %}
+{% trans "Administrative acts" as admact_lbl %}
+{% table_administrativact admact_lbl item.administrative_act.all %}
+{% endif %}
{% endblock %}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
index 097f5defd..b84f60883 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
@@ -1,10 +1,10 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n window_field from_dict link_to_window window_tables window_header humanize %}
+{% load i18n window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %}
{% load url from future %}
{% block head_title %}{% trans "Treatment request" %}{% endblock %}
{% block content %}
-{% window_nav item window_id 'show-treatmentfile' 'treatmentfile_modify' %}
+{% window_nav item window_id 'show-treatmentfile' 'treatmentfile_modify' 'show-historized-treatmentfile' 'revert-treatmentfile' previous next 1 %}
<p class="window-refs">{{ item.name|default:"" }}</p>
{% if item.internal_reference %}
@@ -42,9 +42,19 @@
{% field "Contact" item.applicant.address_lbl %}
{% endif %}
-{% trans "Treatments" as treatments %}
{% if item.treatments.count %}
+{% trans "Treatments" as treatments %}
{% dynamic_table_document treatments 'treatments' 'file' item.pk '' output '' 'treatment' %}
{% endif %}
+{% if item.source.count %}
+{% trans "Associated documents" as associated_docs %}
+{% dynamic_table_document associated_docs 'treatmentfiles_docs' 'treatment_file' item.pk '' output %}
+{% endif %}
+
+{% if item.administrative_act.count %}
+{% trans "Administrative acts" as admact_lbl %}
+{% table_administrativact admact_lbl item.administrative_act.all %}
+{% endif %}
+
{% endblock %}
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index e274c757f..1268b4f03 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -21,6 +21,7 @@ import json
from django.conf import settings
from django.contrib.auth.models import User
+from django.core.files import File
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
from django.test.client import Client
@@ -474,8 +475,14 @@ class PackagingTest(FindInit, TestCase):
model = models.Find
def setUp(self):
+ img = settings.ROOT_PATH + \
+ '../ishtar_common/static/media/images/ishtar-bg.jpg'
+
self.create_finds({"label": u"Find 1"}, force=True)
self.create_finds({"label": u"Find 2"}, force=True)
+ self.finds[0].image.save('ishtar-bg.jpg', File(open(img)))
+ self.finds[0].save()
+
self.basket = models.FindBasket.objects.create(
label="My basket", user=IshtarUser.objects.get(
pk=self.get_default_user().pk))
@@ -490,11 +497,26 @@ class PackagingTest(FindInit, TestCase):
treatment_type = models.TreatmentType.objects.get(txt_idx='packaging')
treatment = models.Treatment()
items_nb = models.Find.objects.count()
+
+ first_find = self.finds[0]
+
treatment.save(user=self.get_default_user(), items=self.basket)
self.assertEqual(items_nb + self.basket.items.count(),
models.Find.objects.count(),
msg="Packaging doesn't generate enough new finds")
treatment.treatment_types.add(treatment_type)
+
+ resulting_find = models.Find.objects.get(
+ upstream_treatment__upstream=first_find,
+ base_finds__pk=first_find.base_finds.all()[0].pk
+ )
+
+ # image names used to be altered on save: check for this bug
+ self.assertEqual(
+ resulting_find.image.name,
+ models.Find.objects.get(pk=first_find.pk).image.name
+ )
+
# new version of the find is in the basket
for item in self.basket.items.all():
self.assertNotIn(
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index 9c554a124..9c331ccc9 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -24,7 +24,7 @@ import views
from archaeological_finds import models
-# be carreful: each check_rights must be relevant with ishtar_menu
+# be careful: each check_rights must be relevant with ishtar_menu
# forms
urlpatterns = patterns(
@@ -33,7 +33,7 @@ urlpatterns = patterns(
check_rights(['view_find', 'view_own_find'])(
views.find_search_wizard), name='find_search'),
url(r'find_creation/(?P<step>.+)?$',
- check_rights(['add_find'])(
+ check_rights(['add_find', 'add_own_find'])(
views.find_creation_wizard), name='find_creation'),
url(r'find_modification/(?P<step>.+)?$',
check_rights(['change_find', 'change_own_find'])(
@@ -284,6 +284,10 @@ urlpatterns += patterns(
kwargs={'full': 'shortcut'}),
url(r'^show-treatment(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_treatment',
name=models.Treatment.SHOW_URL),
+ url(r'show-historized-treatment/(?P<pk>.+)?/(?P<date>.+)?$',
+ 'show_treatment', name='show-historized-treatment'),
+ url(r'^revert-treatment/(?P<pk>.+)/(?P<date>.+)$',
+ 'revert_treatment', name='revert-treatment'),
url(r'get-treatmentfile/(?P<type>.+)?$',
'get_treatmentfile', name='get-treatmentfile'),
url(r'get-treatmentfile-shortcut/(?P<type>.+)?$',
@@ -292,6 +296,10 @@ urlpatterns += patterns(
url(r'^show-treatmentfile(?:/(?P<pk>.+))?/(?P<type>.+)?$',
'show_treatmentfile',
name=models.TreatmentFile.SHOW_URL),
+ url(r'show-historized-treatmentfile/(?P<pk>.+)?/(?P<date>.+)?$',
+ 'show_treatmentfile', name='show-historized-treatmentfile'),
+ url(r'^revert-treatmentfile/(?P<pk>.+)/(?P<date>.+)$',
+ 'revert_treatmentfile', name='revert-treatmentfile'),
# url(r'show-treatmentfile(?:/(?P<pk>.+))?/(?P<type>.+)?$',
# 'show_treatmentfile',
# name=models.TreatmentFile.SHOW_URL),
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 341734ae7..680faf421 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
from django.views.generic.edit import CreateView, FormView
-from ishtar_common.models import IshtarUser
+from ishtar_common.models import IshtarUser, get_current_profile
from archaeological_operations.models import AdministrativeAct
from ishtar_common.forms import FinalForm
@@ -58,6 +58,7 @@ get_find_for_treatment = get_item(
own_table_cols=models.Find.TABLE_COLS_FOR_OPE, base_request={})
show_treatment = show_item(models.Treatment, 'treatment')
+revert_treatment = revert_item(models.Treatment)
get_treatment = get_item(models.Treatment, 'get_treatment', 'treatment')
get_administrativeacttreatment = get_item(
@@ -66,6 +67,7 @@ get_administrativeacttreatment = get_item(
base_request={"treatment__pk__isnull": False})
show_treatmentfile = show_item(models.TreatmentFile, 'treatmentfile')
+revert_treatmentfile = revert_item(models.TreatmentFile)
get_treatmentfile = get_item(models.TreatmentFile, 'get_treatmentfile',
'treatmentfile')
@@ -115,6 +117,15 @@ show_findbasket = show_item(models.FindBasket, 'findbasket')
display_findbasket = display_item(models.FindBasket,
show_url='show-find/basket-')
+
+def check_warehouse_module(self):
+ return get_current_profile().warehouse
+
+
+def check_not_warehouse_module(self):
+ return not check_warehouse_module(self)
+
+
find_creation_steps = [
('selecrecord-find_creation', RecordFormSelectionTable),
('find-find_creation', FindForm),
@@ -127,32 +138,54 @@ find_creation_wizard = FindWizard.as_view(
label=_(u"New find"),
url_name='find_creation',)
+find_search_condition_dict = {
+ 'general-find_search': check_not_warehouse_module,
+ 'generalwarehouse-find_search': check_warehouse_module,
+}
+
find_search_wizard = SearchWizard.as_view([
- ('general-find_search', FindFormSelection)],
+ ('general-find_search', FindFormSelection),
+ ('generalwarehouse-find_search', FindFormSelectionWarehouseModule)],
label=_(u"Find search"),
- url_name='find_search',)
+ url_name='find_search',
+ condition_dict=find_search_condition_dict
+)
+
+find_modification_condition_dict = {
+ 'selec-find_modification': check_not_warehouse_module,
+ 'selecw-find_modification': check_warehouse_module,
+}
find_modification_wizard = FindModificationWizard.as_view([
('selec-find_modification', FindFormSelection),
+ ('selecw-find_modification', FindFormSelectionWarehouseModule),
('selecrecord-find_modification', RecordFormSelection),
('find-find_modification', FindForm),
('dating-find_modification', DatingFormSet),
('final-find_modification', FinalForm)],
+ condition_dict=find_modification_condition_dict,
label=_(u"Find modification"),
url_name='find_modification',)
def find_modify(request, pk):
- # view = find_modification_wizard(request)
+ find_modification_wizard(request)
FindModificationWizard.session_set_value(
request, 'selec-find_modification', 'pk', pk, reset=True)
return redirect(
reverse('find_modification',
kwargs={'step': 'selecrecord-find_modification'}))
+find_deletion_condition_dict = {
+ 'selec-find_deletion': check_not_warehouse_module,
+ 'selecw-find_deletion': check_warehouse_module,
+}
+
find_deletion_wizard = FindDeletionWizard.as_view([
('selec-find_deletion', FindFormSelection),
+ ('selecw-find_deletion', FindFormSelectionWarehouseModule),
('final-find_deletion', FindDeletionForm)],
+ condition_dict=find_deletion_condition_dict,
label=_(u"Find deletion"),
url_name='find_deletion',)
@@ -254,7 +287,10 @@ class SelectItemsInBasket(IshtarMixin, LoginRequiredMixin, TemplateView):
except models.FindBasket.DoesNotExist:
raise PermissionDenied
context['basket'] = self.basket
- context['form'] = MultipleFindFormSelection()
+ if get_current_profile().warehouse:
+ context['form'] = MultipleFindFormSelectionWarehouseModule()
+ else:
+ context['form'] = MultipleFindFormSelection()
context['add_url'] = reverse('add_iteminbasket')
context['list_url'] = reverse('list_iteminbasket',
kwargs={'pk': self.basket.pk})
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index 96a83e582..43fe6262f 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -74,7 +74,11 @@ class FindWizard(Wizard):
class FindModificationWizard(FindWizard):
modification = True
- filter_owns = {'selec-find_modification': ['pk']}
+ main_item_select_keys = ('selec-', 'selecw-')
+ filter_owns = {
+ 'selec-find_modification': ['pk'],
+ 'selecw-find_modification': ['pk'],
+ }
class FindDeletionWizard(DeletionWizard):