summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms_treatments.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-04-28 13:04:25 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commit2a0ba35f42b2b981e5bed7f72952bc30577fd25c (patch)
tree4cf14347e35586fa0e8dbb6e075bd9e12243caa9 /archaeological_finds/forms_treatments.py
parente817ea1f7286523497bb81a897f4ffc2539f7e2c (diff)
downloadIshtar-2a0ba35f42b2b981e5bed7f72952bc30577fd25c.tar.bz2
Ishtar-2a0ba35f42b2b981e5bed7f72952bc30577fd25c.zip
QA packaging: can associate collection
Diffstat (limited to 'archaeological_finds/forms_treatments.py')
-rw-r--r--archaeological_finds/forms_treatments.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index b80b6c0fe..c62dbcc57 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -399,25 +399,29 @@ class TreatmentDeletionForm(FinalForm):
class QAFindTreatmentForm(IshtarForm):
container = forms.IntegerField(
- label=_(u"Container"),
+ label=_("Container"),
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-container'),
associated_model=Container, new=True),
validators=[valid_id(Container)])
container_to_change = forms.ChoiceField(
- label=_(u"Change "), required=True,
+ label=_("Change "), required=True,
choices=(
('current-and-reference', _(u"current and reference containers")),
('reference', _(u"the reference container")),
('current', _(u"the current container")),
)
)
+ collection = forms.BooleanField(
+ label=_("Associate to the collection of the container"), required=False,
+ widget=widgets.CheckboxInput
+ )
create_treatment = forms.BooleanField(
- label=_(u"Create a treatment"), required=False,
+ label=_("Create a treatment"), required=False,
widget=widgets.CheckboxInput
)
treatment_type = forms.ChoiceField(
- label=_(u"Treatment type"), choices=[], required=False
+ label=_("Treatment type"), choices=[], required=False
)
year = forms.IntegerField(
label=_("Year"), initial=lambda: datetime.datetime.now().year,
@@ -527,8 +531,14 @@ class QAFindTreatmentForm(IshtarForm):
container_attrs.append('container_ref')
if container_to_change in ('current', 'current-and-reference'):
container_attrs.append('container')
+ collection = None
+ if self.cleaned_data.get("collection"):
+ collection = container.location_id
for find in items:
changed = False
+ if collection and find.collection_id != collection:
+ find.collection_id = collection
+ changed = True
for container_attr in container_attrs:
if getattr(find, container_attr) == container:
continue