diff options
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 |
commit | ba2c713fd818e209bc5c894e45fe1fc17532a20c (patch) | |
tree | 4cf14347e35586fa0e8dbb6e075bd9e12243caa9 | |
parent | 52257bb404da82db28d497c3ece6de4b959e1fb9 (diff) | |
download | Ishtar-ba2c713fd818e209bc5c894e45fe1fc17532a20c.tar.bz2 Ishtar-ba2c713fd818e209bc5c894e45fe1fc17532a20c.zip |
QA packaging: can associate collection
-rw-r--r-- | archaeological_finds/forms_treatments.py | 18 | ||||
-rw-r--r-- | archaeological_finds/templates/ishtar/forms/qa_find_treatment.html | 12 | ||||
-rw-r--r-- | archaeological_warehouse/views.py | 6 |
3 files changed, 24 insertions, 12 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 diff --git a/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html b/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html index 38db02ff4..c7944f2a0 100644 --- a/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html +++ b/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html @@ -24,23 +24,25 @@ {% with form.container as field %} {% include "blocks/bs_field_snippet.html" %} {% endwith %} - </div> - - <div class="form-row"> {% with form.container_to_change as field %} {% include "blocks/bs_field_snippet.html" %} {% endwith %} </div> + <div class="form-row"> + {{ form.collection }} <label for="{{form.collection.auto_id}}"> + {% trans "Associate to the collection of the container" %} + </label> + </div> <div class="form-row"> {{ form.create_treatment }} <label for="{{form.create_treatment.auto_id}}"> - {% trans "Associate a treatment" %} + {% trans "Associate a treatment" %} </label> </div> <div id="new-treatment"> <div class="form-row"> {% with force_large_col=false %}{% for field in form %} - {% if field.name != 'container_to_change' and field.name != 'container' and field.name != 'create_treatment' %} + {% if field.name != 'container_to_change' and field.name != 'collection' and field.name != 'container' and field.name != 'create_treatment' %} {% include "blocks/bs_field_snippet.html" %} {% endif %} {% endfor %}{% endwith %} diff --git a/archaeological_warehouse/views.py b/archaeological_warehouse/views.py index 4c98b8ac3..354ad4af1 100644 --- a/archaeological_warehouse/views.py +++ b/archaeological_warehouse/views.py @@ -104,16 +104,16 @@ def autocomplete_container(request, warehouse_id=None): extra = Q(container_type__label__icontains=q) | \ Q(container_type__reference__icontains=q) | \ Q(reference__icontains=q) | \ - Q(cached_division__icontains=q) | \ + Q(cached_label__icontains=q) | \ Q(location__name=q) | \ Q(location__town=q) query = query & extra containers += list( models.Container.objects.filter(query).exclude( pk__in=[c['id'] for c in containers] - ).values('id', 'cached_division')[:limit]) + ).values('id', 'cached_label')[:limit]) data = json.dumps( - [{'id': container['id'], 'value': container['cached_division']} + [{'id': container['id'], 'value': container['cached_label']} for container in containers]) return HttpResponse(data, content_type='text/plain') |