summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/migrations/0104_findinsidecontainer.py26
-rw-r--r--archaeological_finds/models.py4
-rw-r--r--archaeological_finds/models_finds.py168
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html16
-rw-r--r--archaeological_finds/tests.py164
-rw-r--r--archaeological_finds/tests/import_loca_test.json305
-rw-r--r--archaeological_finds/urls.py5
-rw-r--r--archaeological_finds/views.py11
8 files changed, 668 insertions, 31 deletions
diff --git a/archaeological_finds/migrations/0104_findinsidecontainer.py b/archaeological_finds/migrations/0104_findinsidecontainer.py
new file mode 100644
index 000000000..20a91c9cf
--- /dev/null
+++ b/archaeological_finds/migrations/0104_findinsidecontainer.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.27 on 2020-04-03 16:33
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0103_auto_20200129_1944'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='FindInsideContainer',
+ fields=[
+ ('find', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='inside_container', serialize=False, to='archaeological_finds.Find', verbose_name='Find')),
+ ],
+ options={
+ 'db_table': 'find_inside_container',
+ 'managed': False,
+ },
+ ),
+ ]
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index ad349e315..53fa35c40 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -3,7 +3,7 @@ from archaeological_finds.models_finds import MaterialType, ConservatoryState, \
FindBasket, Find, Property, BatchType, BFBulkView, FBulkView, \
FirstBaseFindView, AlterationType, AlterationCauseType, \
TreatmentEmergencyType, TreatmentType, CommunicabilityType, \
- MaterialTypeQualityType, ObjectTypeQualityType
+ MaterialTypeQualityType, ObjectTypeQualityType, FindInsideContainer
from archaeological_finds.models_treatments import Treatment, \
AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \
FindTreatments, TreatmentFile, TreatmentFileType, \
@@ -18,4 +18,4 @@ __all__ = ['MaterialType', 'ConservatoryState', 'IntegrityType', 'CheckedType',
'FindNonModifTreatments', 'FindDownstreamTreatments',
'FindTreatments', 'TreatmentFile', 'TreatmentFileType',
'CommunicabilityType', 'MaterialTypeQualityType',
- 'ObjectTypeQualityType']
+ 'ObjectTypeQualityType', 'FindInsideContainer']
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 0260200e9..119a2022a 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -785,8 +785,7 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
'base_finds__context_record__label',
'cached_materials', 'cached_object_types',
'cached_periods',
- 'container__cached_label',
- 'container_ref__cached_label']
+ 'container__cached_label']
if settings.COUNTRY == 'fr':
TABLE_COLS.insert(
3, 'base_finds__context_record__operation__code_patriarche')
@@ -2294,7 +2293,8 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
def localisation_9(self):
return self.get_localisation(8)
- def set_localisation(self, place, context, value, is_ref=False):
+ def set_localisation(self, place, context, value, is_ref=False,
+ static=False):
"""
Get localisation reference in the warehouse
@@ -2302,6 +2302,7 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
:param context: context of the request - not used
:param value: localisation value
:param is_ref: if true - reference container else current container
+ :param static: if true: do not create new container
:return: None
"""
if is_ref:
@@ -2314,19 +2315,17 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
return
if is_ref:
raise ImporterError(
- _(u"No reference container have been set - the "
- u"localisation cannot be set."))
+ _("No reference container have been set - the "
+ "localisation cannot be set."))
else:
raise ImporterError(
- _(u"No container have been set - the localisation cannot "
- u"be set."))
+ _("No container have been set - the localisation cannot "
+ "be set."))
- localisation = container.set_localisation(place, value)
- if value and value != '-' and not localisation:
- raise ImporterError(
- str(_(u"The division number {} have not been set "
- u"for the warehouse {}.")).format(
- place + 1, container.location))
+ localisation, error = container.set_localisation(
+ place, value, static=static, return_errors=True)
+ if error:
+ raise ImporterError(error)
@post_importer_action
def set_reference_localisation_1(self, context, value):
@@ -2374,6 +2373,60 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
set_reference_localisation_9.post_save = True
@post_importer_action
+ def set_reference_static_localisation_1(self, context, value):
+ return self.set_localisation(0, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_1.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_2(self, context, value):
+ return self.set_localisation(1, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_2.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_3(self, context, value):
+ return self.set_localisation(2, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_3.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_4(self, context, value):
+ return self.set_localisation(3, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_4.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_5(self, context, value):
+ return self.set_localisation(4, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_5.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_6(self, context, value):
+ return self.set_localisation(5, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_6.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_7(self, context, value):
+ return self.set_localisation(6, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_7.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_8(self, context, value):
+ return self.set_localisation(7, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_8.post_save = True
+
+ @post_importer_action
+ def set_reference_static_localisation_9(self, context, value):
+ return self.set_localisation(8, context, value, is_ref=True,
+ static=True)
+ set_reference_static_localisation_9.post_save = True
+
+ @post_importer_action
def set_localisation_1(self, context, value):
return self.set_localisation(0, context, value)
set_localisation_1.post_save = True
@@ -2418,6 +2471,51 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem,
return self.set_localisation(8, context, value)
set_localisation_9.post_save = True
+ @post_importer_action
+ def set_static_localisation_1(self, context, value):
+ return self.set_localisation(0, context, value, static=True)
+ set_static_localisation_1.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_2(self, context, value):
+ return self.set_localisation(1, context, value, static=True)
+ set_static_localisation_2.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_3(self, context, value):
+ return self.set_localisation(2, context, value, static=True)
+ set_static_localisation_3.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_4(self, context, value):
+ return self.set_localisation(3, context, value, static=True)
+ set_static_localisation_4.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_5(self, context, value):
+ return self.set_localisation(4, context, value, static=True)
+ set_static_localisation_5.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_6(self, context, value):
+ return self.set_localisation(5, context, value, static=True)
+ set_static_localisation_6.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_7(self, context, value):
+ return self.set_localisation(6, context, value, static=True)
+ set_static_localisation_7.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_8(self, context, value):
+ return self.set_localisation(7, context, value, static=True)
+ set_static_localisation_8.post_save = True
+
+ @post_importer_action
+ def set_static_localisation_9(self, context, value):
+ return self.set_localisation(8, context, value, static=True)
+ set_static_localisation_9.post_save = True
+
def generate_index(self):
"""
Generate index based on operation or context record (based on
@@ -2555,6 +2653,50 @@ m2m_changed.connect(base_find_find_changed, sender=Find.base_finds.through)
m2m_changed.connect(document_attached_changed,
sender=Find.documents.through)
+
+class FindInsideContainer(models.Model):
+ CREATE_SQL = """
+ CREATE VIEW find_inside_container AS
+ SELECT fb.id AS find_id, fb.container_id AS container_id
+ FROM archaeological_finds_find fb
+ WHERE fb.downstream_treatment_id IS NULL AND fb.container_id IS NOT NULL
+ UNION
+ SELECT f.id AS find_id, r.container_parent_id AS container_id
+ FROM archaeological_finds_find f
+ INNER JOIN container_tree r
+ ON r.container_id = f.container_id
+ WHERE f.downstream_treatment_id IS NULL;
+
+ -- deactivate deletion
+ CREATE RULE find_inside_container_del AS
+ ON DELETE TO find_inside_container
+ DO INSTEAD DELETE FROM archaeological_finds_find where id=NULL;
+ """
+ DELETE_SQL = """
+ DROP VIEW IF EXISTS find_inside_container;
+ """
+ TABLE_COLS = ["find__" + t for t in Find.TABLE_COLS]
+ COL_LABELS = {
+ "find__" + k: Find.COL_LABELS[k] for k in Find.COL_LABELS.keys()
+ }
+ EXTRA_REQUEST_KEYS = {
+ "find__" + k:
+ "find__" + Find.EXTRA_REQUEST_KEYS[k]
+ for k in Find.EXTRA_REQUEST_KEYS.keys()
+ }
+
+ find = models.OneToOneField(
+ Find, verbose_name=_("Find"), related_name="inside_container",
+ primary_key=True)
+ container = models.ForeignKey("archaeological_warehouse.Container",
+ verbose_name=_("Container"),
+ related_name="container_content")
+
+ class Meta:
+ managed = False
+ db_table = 'find_inside_container'
+
+
for attr in Find.HISTORICAL_M2M:
m2m_changed.connect(m2m_historization_changed,
sender=getattr(Find, attr).through)
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index a696bcf9f..2b2e868be 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -253,20 +253,10 @@
{% if display_warehouse_treatments %}
<div class="tab-pane fade" id="{{window_id}}-warehouse"
role="tabpanel" aria-labelledby="{{window_id}}-warehouse-tab">
- {% if item.container_ref %}
- <h3>{% trans "Warehouse - reference container"%}</h3>
+ {% if item.container %}
+ <h3>{% trans "Warehouse - container" %}</h3>
<div class='row'>
- {% field_flex_detail "Container" item.container_ref %}
- {% field_flex "Container ID" item.container_ref.cached_location %}
- {% field_flex_detail "Responsible warehouse" item.container_ref.responsible %}
- {% field_flex_detail "Location (warehouse)" item.container_ref.location %}
- {% field_flex "Precise localisation" item.container_ref.cached_division %}
- </div>
- {% endif %}
- {% if item.container and item.container_ref.pk != item.container.pk %}
- <h3>{% trans "Warehouse - current container"%}</h3>
- <div class='row'>
- {% field_flex_detail "Container" item.container %}
+ {% field_flex_detail "Container" item.container "large" %}
{% field_flex "Container ID" item.container.cached_location %}
{% field_flex_detail "Responsible warehouse" item.container.responsible %}
{% field_flex_detail "Location (warehouse)" item.container.location %}
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index 55006c4ca..80202f442 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -18,8 +18,11 @@
# See the file COPYING for details.
from copy import deepcopy
+import csv
import datetime
import json
+import os
+import tempfile
from rest_framework.test import APITestCase
from rest_framework.authtoken.models import Token
@@ -35,6 +38,7 @@ from django.test import tag
from django.test.client import Client
from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\
FormaterType, ImportTarget, IshtarSiteProfile, ProfileType
+from django.utils.text import slugify
from django.utils.translation import pgettext_lazy, gettext_lazy as _
from ishtar_common.models import Person, get_current_profile, UserProfile, \
@@ -598,15 +602,22 @@ class TreatmentWizardCreationTest(WizardTest, FindInit, TestCase):
# treat)
-class ImportFindTest(ImportTest, TestCase):
- fixtures = FIND_TOWNS_FIXTURES
+class ImportFindTest(ImportTest, FindInit, TestCase):
+ fixtures = FIND_TOWNS_FIXTURES + [
+ settings.ROOT_PATH +
+ '../archaeological_finds/tests/import_loca_test.json',
+ ]
+
+ def setUp(self):
+ super(ImportFindTest, self).setUp()
+ self.tmpdir = tempfile.TemporaryDirectory()
def test_mcc_import_finds(self):
self.init_context_record()
old_nb = models.BaseFind.objects.count()
old_nb_find = models.Find.objects.count()
- MCC = ImporterType.objects.get(name=u"MCC - Mobilier")
+ MCC = ImporterType.objects.get(name="MCC - Mobilier")
col = ImporterColumn.objects.create(col_number=25,
importer_type_id=MCC.pk)
@@ -671,6 +682,153 @@ class ImportFindTest(ImportTest, TestCase):
f.index, expected_index
))
+ def test_import_locations(self):
+ self.create_finds()
+ self.create_finds()
+ self.create_finds()
+ self.create_finds()
+ external_ids = []
+ for idx, f in enumerate(self.finds):
+ f.label = "Find {}".format(idx)
+ f.save()
+ external_ids.append(f.external_id)
+
+ wt, __ = WarehouseType.objects.get_or_create(label="WT", txt_idx="WT")
+
+ warehouse, __ = Warehouse.objects.get_or_create(
+ external_id="warehouse-test",
+ defaults={"name": "Warehouse test",
+ "warehouse_type": wt}
+ )
+
+ container_types = []
+ levels = ["Building", "Area", "Shelf", "Box"]
+ for level in levels:
+ container_type, __ = ContainerType.objects.get_or_create(
+ label=level, txt_idx=slugify(level)
+ )
+ container_types.append(container_type)
+
+ for idx in range(len(levels[:-1])):
+ WarehouseDivisionLink.objects.get_or_create(
+ warehouse=warehouse,
+ container_type=container_types[idx],
+ order=(idx + 1) * 10
+ )
+
+ old_nb = models.BaseFind.objects.count()
+ old_nb_find = models.Find.objects.count()
+ old_nb_container = Container.objects.count()
+
+ importer_type = ImporterType.objects.get(slug="importeur-test")
+
+ imp_filename = os.path.join(self.tmpdir.name, "imp_locations.csv")
+
+ with open(imp_filename, "w") as impfile:
+ w = csv.writer(impfile)
+ w.writerow(['External ID', "Warehouse", "Ref.",
+ "Container type", "Localisation 1", "Localisation 2",
+ "Localisation 3"])
+ for idx, ext_id in enumerate(external_ids):
+ if idx < 2:
+ w.writerow([ext_id, "warehouse-test",
+ "Réf. {}".format((idx + 1) * 10),
+ container_types[-1].name,
+ "A", "42", idx + 1])
+ else:
+ w.writerow([ext_id, "warehouse-test",
+ "Réf. {}".format((idx + 1) * 10),
+ container_types[-1].name,
+ "A", 43])
+
+ imp_file = open(imp_filename, "rb")
+ file_dict = {'imported_file': SimpleUploadedFile(imp_file.name,
+ imp_file.read())}
+ post_dict = {'importer_type': importer_type.pk, 'skip_lines': 1,
+ "encoding": 'utf-8', "name": 'init_find_import',
+ "csv_sep": ","}
+ form = forms_common.NewImportForm(data=post_dict, files=file_dict,
+ user=self.user)
+ form.is_valid()
+ self.assertTrue(form.is_valid())
+ impt = form.save(self.ishtar_user)
+ impt.initialize()
+
+ impt.importation()
+ # no new finds has now been imported
+ current_nb = models.BaseFind.objects.count()
+ self.assertEqual(current_nb, old_nb)
+ current_nb = models.Find.objects.count()
+ self.assertEqual(current_nb, old_nb_find)
+
+ current_nb = Container.objects.count()
+ self.assertEqual(current_nb, old_nb_container + 4 + 2 + 2 + 1)
+ containers = list(Container.objects.all())
+ for container in containers:
+ self.assertEqual(container.location, warehouse)
+ q = Container.objects.filter(container_type=container_types[0])
+ self.assertEqual(q.count(), 1)
+ building = q.all()[0]
+ self.assertIsNone(building.parent)
+
+ q = Container.objects.filter(container_type=container_types[1])
+ self.assertEqual(q.count(), 2)
+ areas = list(q.all())
+ area = q.all()[0]
+ self.assertEqual(area.parent, building)
+
+ q = Container.objects.filter(container_type=container_types[2])
+ self.assertEqual(q.count(), 2)
+ shelves = list(q.all())
+ for shelf in shelves:
+ self.assertEqual(shelf.parent, area)
+
+ q = Container.objects.filter(container_type=container_types[3])
+ self.assertEqual(q.count(), 4)
+ boxes = list(q.all().order_by("id"))
+ previous_shelf = None
+ for box in boxes[:2]:
+ if not previous_shelf:
+ previous_shelf = box.parent
+ else:
+ # on a different shelf
+ self.assertNotEqual(previous_shelf, box.parent)
+ self.assertIn(box.parent_id, [s.pk for s in shelves])
+ previous_area = None
+ for box in boxes[2:]:
+ if not previous_area:
+ previous_area = box.parent
+ else:
+ self.assertEqual(previous_area, box.parent) # on the same area
+ self.assertIn(box.parent_id, [s.pk for s in areas])
+
+ importer_type = ImporterType.objects.get(slug="importeur-test")
+ cols = list(ImporterColumn.objects.filter(
+ importer_type=importer_type,
+ col_number__gte=5).values_list("id", flat=True))
+ for target in ImportTarget.objects.filter(column_id__in=cols):
+ target.target = target.target.replace("set_localisation",
+ "set_static_localisation")
+ target.save()
+
+ # delete area 43 and all boxes
+ Container.objects.filter(reference="43").delete()
+ Container.objects.filter(container_type=container_types[-1]).delete()
+
+ # reimport
+ impt.initialize()
+ impt.importation()
+ # check errors
+ self.assertEqual(len(impt.errors), 2)
+ for error in impt.errors:
+ self.assertEqual(
+ error['error'],
+ "The division Area 43 do not exist for the location Warehouse "
+ "test.")
+
+ def tearDown(self):
+ self.tmpdir.cleanup()
+
class FindTest(FindInit, TestCase):
fixtures = FIND_FIXTURES
diff --git a/archaeological_finds/tests/import_loca_test.json b/archaeological_finds/tests/import_loca_test.json
new file mode 100644
index 000000000..1f0a9054a
--- /dev/null
+++ b/archaeological_finds/tests/import_loca_test.json
@@ -0,0 +1,305 @@
+[
+{
+ "model": "ishtar_common.importertype",
+ "fields": {
+ "name": "Importeur test",
+ "slug": "importeur-test",
+ "description": null,
+ "associated_models": [
+ "archaeological_finds.models_finds.Find"
+ ],
+ "is_template": false,
+ "unicity_keys": "external_id",
+ "available": true,
+ "users": [],
+ "created_models": [
+ [
+ "archaeological_warehouse.models.Container"
+ ],
+ [
+ "archaeological_finds.models_finds.Find"
+ ],
+ [
+ "archaeological_finds.models.BaseFind"
+ ]
+ ]
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "ID externe",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 1,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": true,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 1",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 5,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 2",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 6,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Localisation 3",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 7,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "D\u00e9p\u00f4t",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 2,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Ref. container",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 3,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importercolumn",
+ "fields": {
+ "label": "Type de contenant",
+ "importer_type": [
+ "importeur-test"
+ ],
+ "col_number": 4,
+ "description": "",
+ "regexp_pre_filter": null,
+ "value_format": null,
+ "required": false,
+ "export_field_name": null
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 1
+ ],
+ "target": "external_id",
+ "formater_type": [
+ "UnicodeFormater",
+ "100",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 5
+ ],
+ "target": "set_localisation_1",
+ "formater_type": [
+ "UnicodeFormater",
+ "10",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 6
+ ],
+ "target": "set_localisation_2",
+ "formater_type": [
+ "UnicodeFormater",
+ "10",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 7
+ ],
+ "target": "set_localisation_3",
+ "formater_type": [
+ "UnicodeFormater",
+ "10",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 2
+ ],
+ "target": "container__location__external_id",
+ "formater_type": [
+ "UnicodeFormater",
+ "100",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 3
+ ],
+ "target": "container__reference",
+ "formater_type": [
+ "UnicodeFormater",
+ "30",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importtarget",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 4
+ ],
+ "target": "container__container_type",
+ "formater_type": [
+ "TypeFormater",
+ "archaeological_warehouse.models.ContainerType",
+ ""
+ ],
+ "force_new": false,
+ "concat": false,
+ "concat_str": null,
+ "comment": ""
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 2
+ ],
+ "field_name": "container__responsible__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": null
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 3
+ ],
+ "field_name": "container__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+},
+{
+ "model": "ishtar_common.importerduplicatefield",
+ "fields": {
+ "column": [
+ "importeur-test",
+ 2
+ ],
+ "field_name": "container__external_id",
+ "force_new": false,
+ "concat": false,
+ "concat_str": "-"
+ }
+}
+]
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index 588777552..bab3fc6b4 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -270,6 +270,11 @@ urlpatterns = [
name='get-own-find-for-treatment', kwargs={'force_own': True}),
url(r'get-find-for-treatment/(?P<type>.+)?$', views.get_find_for_treatment,
name='get-find-for-treatment'),
+ url(r'get-find-inside-container/own/(?P<type>.+)?$',
+ views.get_find_inside_container,
+ name='get-find-inside-container', kwargs={'force_own': True}),
+ url(r'get-find-inside-container/(?P<type>.+)?$',
+ views.get_find_inside_container, name='get-find-inside-container'),
url(r'get-find-full/own/(?P<type>.+)?$', views.get_find,
name='get-own-find-full', kwargs={'full': True, 'force_own': True}),
url(r'get-find-full/(?P<type>.+)?$', views.get_find,
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 1fc2b3722..cf82cceb8 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -66,6 +66,11 @@ def get_table_cols_for_ope():
return settings.TABLE_COLS[tb_key]
+def get_table_cols_for_container():
+ table_col = get_table_cols_for_ope()
+ return ["find__" + tc for tc in table_col]
+
+
get_find_for_ope = get_item(models.Find, 'get_find', 'find',
own_table_cols=get_table_cols_for_ope())
@@ -73,6 +78,12 @@ get_find_for_treatment = get_item(
models.Find, 'get_find', 'find',
own_table_cols=get_table_cols_for_ope(), base_request={})
+get_find_inside_container = get_item(
+ models.FindInsideContainer, 'get_find_inside_container',
+ 'find',
+ extra_request_keys=models.FindInsideContainer.EXTRA_REQUEST_KEYS,
+ own_table_cols=get_table_cols_for_container())
+
autocomplete_find = get_autocomplete_item(model=models.Find)