summaryrefslogtreecommitdiff
path: root/archaeological_warehouse
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-08 18:30:15 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-08 18:30:15 +0200
commit8486380780073057736944ac6e6ef0aca9a52eec (patch)
tree83ab0b4fd2b1356f1e03d72f9562e730efcca165 /archaeological_warehouse
parentbbed42d3287dcbb47fadf1ed926dfdfe5fb3d93f (diff)
parent3714f0d1f3e8610d1fa789c8ea33e7fc9f773f25 (diff)
downloadIshtar-8486380780073057736944ac6e6ef0aca9a52eec.tar.bz2
Ishtar-8486380780073057736944ac6e6ef0aca9a52eec.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r--archaeological_warehouse/forms.py16
-rw-r--r--archaeological_warehouse/locale/django.pot62
-rw-r--r--archaeological_warehouse/views.py2
-rw-r--r--archaeological_warehouse/wizards.py25
4 files changed, 58 insertions, 47 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index f045fac1e..d56df8139 100644
--- a/archaeological_warehouse/forms.py
+++ b/archaeological_warehouse/forms.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2016 É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
@@ -22,12 +22,13 @@ from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from ishtar_common.models import Person, valid_id
-from archaeological_finds.models import TreatmentType
+from archaeological_finds.models import TreatmentType, FindBasket
import models
from ishtar_common import widgets
from ishtar_common.forms import name_validator, reverse_lazy, \
get_form_selection, TableSelect
-from archaeological_finds.forms import FindMultipleFormSelection
+from archaeological_finds.forms import FindMultipleFormSelection, \
+ SelectFindBasketForm
def get_warehouse_field(label=_(u"Warehouse"), required=True):
@@ -66,6 +67,8 @@ class WarehouseForm(forms.Form):
required=False)
def __init__(self, *args, **kwargs):
+ if 'limits' in kwargs:
+ kwargs.pop('limits')
super(WarehouseForm, self).__init__(*args, **kwargs)
self.fields['warehouse_type'].choices = \
models.WarehouseType.get_types()
@@ -99,6 +102,8 @@ class ContainerForm(forms.Form):
widget=forms.Textarea, required=False)
def __init__(self, *args, **kwargs):
+ if 'limits' in kwargs:
+ kwargs.pop('limits')
super(ContainerForm, self).__init__(*args, **kwargs)
self.fields['container_type'].choices = \
models.ContainerType.get_types()
@@ -135,11 +140,12 @@ ContainerFormSelection = get_form_selection(
new_message=_(u"Add a new container"))
-class BasePackagingForm(forms.Form):
+class BasePackagingForm(SelectFindBasketForm):
form_label = _(u"Packaging")
associated_models = {'treatment_type': TreatmentType,
'person': Person,
- 'location': models.Warehouse}
+ 'location': models.Warehouse,
+ 'basket': FindBasket}
treatment_type = forms.IntegerField(label="", widget=forms.HiddenInput)
person = forms.IntegerField(
label=_(u"Packager"),
diff --git a/archaeological_warehouse/locale/django.pot b/archaeological_warehouse/locale/django.pot
index cb0992a12..264ef3791 100644
--- a/archaeological_warehouse/locale/django.pot
+++ b/archaeological_warehouse/locale/django.pot
@@ -6,91 +6,95 @@
msgid ""
msgstr ""
-#: forms.py:34 forms.py:89 models.py:44 models.py:71
+#: forms.py:34 forms.py:96 models.py:44 models.py:73
msgid "Warehouse"
msgstr ""
-#: forms.py:42 models.py:35
+#: forms.py:43 models.py:35
msgid "Name"
msgstr ""
-#: forms.py:44 models.py:30 models.py:37
+#: forms.py:45 models.py:29 models.py:37
msgid "Warehouse type"
msgstr ""
-#: forms.py:46 models.py:40
+#: forms.py:48 models.py:40
msgid "Person in charge"
msgstr ""
-#: forms.py:51 forms.py:94 models.py:41 models.py:75
+#: forms.py:54 forms.py:101 models.py:41 models.py:77
msgid "Comment"
msgstr ""
-#: forms.py:53
+#: forms.py:56
msgid "Address"
msgstr ""
-#: forms.py:55
+#: forms.py:58
msgid "Address complement"
msgstr ""
-#: forms.py:57
+#: forms.py:60
msgid "Postal code"
msgstr ""
-#: forms.py:59 forms.py:63
+#: forms.py:62 forms.py:66
msgid "Town"
msgstr ""
-#: forms.py:60
+#: forms.py:63
msgid "Country"
msgstr ""
-#: forms.py:62
+#: forms.py:65
msgid "Phone"
msgstr ""
-#: forms.py:86 models.py:78
+#: forms.py:92 models.py:80
msgid "Container"
msgstr ""
-#: forms.py:87 forms.py:116 models.py:62
+#: forms.py:93 forms.py:127 models.py:63
msgid "Ref."
msgstr ""
-#: forms.py:88 forms.py:115 models.py:65 models.py:73
+#: forms.py:94 forms.py:126 models.py:66 models.py:75
msgid "Container type"
msgstr ""
-#: forms.py:126
+#: forms.py:137
msgid "Container search"
msgstr ""
-#: forms.py:128
+#: forms.py:139
msgid "You should select a container."
msgstr ""
-#: forms.py:129
+#: forms.py:140
msgid "Add a new container"
msgstr ""
-#: forms.py:132 views.py:94
+#: forms.py:144 ishtar_menu.py:33 views.py:94
msgid "Packaging"
msgstr ""
-#: forms.py:137
+#: forms.py:151
msgid "Packager"
msgstr ""
-#: forms.py:141
+#: forms.py:157
msgid "Date"
msgstr ""
-#: forms.py:150
+#: forms.py:166
msgid "Packaged finds"
msgstr ""
-#: models.py:31
+#: ishtar_menu.py:30
+msgid "Find"
+msgstr ""
+
+#: models.py:30
msgid "Warehouse types"
msgstr ""
@@ -118,30 +122,30 @@ msgstr ""
msgid "Can delete own Warehouse"
msgstr ""
-#: models.py:58
+#: models.py:59
msgid "Length (mm)"
msgstr ""
-#: models.py:59
+#: models.py:60
msgid "Width (mm)"
msgstr ""
-#: models.py:60
+#: models.py:61
msgid "Height (mm)"
msgstr ""
-#: models.py:61
+#: models.py:62
msgid "Volume (l)"
msgstr ""
-#: models.py:66
+#: models.py:67
msgid "Container types"
msgstr ""
-#: models.py:74
+#: models.py:76
msgid "Container ref."
msgstr ""
-#: models.py:79
+#: models.py:81
msgid "Containers"
msgstr ""
diff --git a/archaeological_warehouse/views.py b/archaeological_warehouse/views.py
index aab18ed40..be5e6150c 100644
--- a/archaeological_warehouse/views.py
+++ b/archaeological_warehouse/views.py
@@ -89,7 +89,7 @@ def autocomplete_container(request):
warehouse_packaging_wizard = PackagingWizard.as_view([
('seleccontainer-packaging', ContainerFormSelection),
('base-packaging', BasePackagingForm),
- ('multiselecitems-packaging', FindPackagingFormSelection),
+ # ('multiselecitems-packaging', FindPackagingFormSelection),
('final-packaging', FinalForm)],
label=_(u"Packaging"),
url_name='warehouse_packaging',)
diff --git a/archaeological_warehouse/wizards.py b/archaeological_warehouse/wizards.py
index 833c1c697..409f7b28f 100644
--- a/archaeological_warehouse/wizards.py
+++ b/archaeological_warehouse/wizards.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2012-2016 É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
@@ -25,23 +25,24 @@ from archaeological_finds.models import Treatment
class PackagingWizard(TreatmentWizard):
+
+ def get_form_kwargs(self, step):
+ kwargs = super(PackagingWizard, self).get_form_kwargs(step)
+ if 'base-packaging' not in step:
+ return kwargs
+ kwargs['user'] = self.request.user
+ return kwargs
+
def save_model(self, dct, m2m, whole_associated_models, form_list,
return_object):
dct = self.get_extra_model(dct, form_list)
obj = self.get_current_saved_object()
dct['location'] = dct['container'].location
- items = dct.pop('finds')
+ items = dct.pop('basket')
treatment = Treatment(**dct)
- treatment.save()
- if not hasattr(items, '__iter__'):
- items = [items]
- for item in items:
- new = item.duplicate(self.request.user)
- item.downstream_treatment = treatment
- item.save()
- new.upstream_treatment = treatment
- new.container = dct['container']
- new.save()
+ extra_args_for_new = {"container": dct['container']}
+ treatment.save(items=items, user=self.request.user,
+ extra_args_for_new=extra_args_for_new)
res = render_to_response('ishtar/wizard/wizard_done.html', {},
context_instance=RequestContext(self.request))
return return_object and (obj, res) or res