summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/admin.py11
-rw-r--r--archaeological_finds/forms.py1
-rw-r--r--archaeological_finds/migrations/0010_auto_20171011_1644.py61
-rw-r--r--archaeological_finds/migrations/0011_auto_20171012_1316.py65
-rw-r--r--archaeological_finds/migrations/0012_auto_20171017_1840.py61
-rw-r--r--archaeological_finds/models_finds.py18
-rw-r--r--archaeological_finds/models_treatments.py7
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html2
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html2
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatmentfile.html2
10 files changed, 219 insertions, 11 deletions
diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py
index b8ed15865..6f32365b9 100644
--- a/archaeological_finds/admin.py
+++ b/archaeological_finds/admin.py
@@ -47,11 +47,11 @@ class AdminBaseFindForm(forms.ModelForm):
class BaseFindAdmin(HistorizedObjectAdmin):
list_display = ('label', 'context_record', 'index')
- search_fields = ('label', 'context_record__parcel__operation__name',)
+ search_fields = ('label', 'cache_complete_id',)
model = models.BaseFind
form = AdminBaseFindForm
readonly_fields = HistorizedObjectAdmin.readonly_fields + [
- 'cache_short_id', 'cache_complete_id', 'imports'
+ 'cache_short_id', 'cache_complete_id',
]
admin_site.register(models.BaseFind, BaseFindAdmin)
@@ -69,7 +69,7 @@ class FindAdmin(HistorizedObjectAdmin):
'container': 'container'
})
readonly_fields = HistorizedObjectAdmin.readonly_fields + [
- 'imports', 'datings', 'cached_label'
+ 'datings', 'cached_label'
]
admin_site.register(models.Find, FindAdmin)
@@ -97,7 +97,7 @@ class PropertyAdmin(HistorizedObjectAdmin):
'person': 'person',
})
readonly_fields = HistorizedObjectAdmin.readonly_fields + [
- 'administrative_act', 'imports', ]
+ 'administrative_act']
def has_add_permission(self, request):
return False
@@ -118,7 +118,7 @@ class TreatmentAdmin(HistorizedObjectAdmin):
'container': 'container',
})
readonly_fields = HistorizedObjectAdmin.readonly_fields + [
- 'imports', 'cached_label', 'downstream_lbl', 'upstream_lbl'
+ 'cached_label', 'downstream_lbl', 'upstream_lbl'
]
def has_add_permission(self, request):
@@ -140,7 +140,6 @@ class TreatmentFileAdmin(HistorizedObjectAdmin):
'applicant': 'person',
'applicant_organisation': 'organization',
})
- exclude = ['imports']
readonly_fields = HistorizedObjectAdmin.readonly_fields + [
'cached_label',
]
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index aa0ae4621..1f81cf52f 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -366,6 +366,7 @@ DatingFormSet.form_label = _("Dating")
class FindSelect(TableSelect):
+ search_vector = forms.CharField(label=_(u"Full text search"))
base_finds__cache_short_id = forms.CharField(label=_(u"Short ID"))
base_finds__cache_complete_id = forms.CharField(label=_(u"Complete ID"))
label = forms.CharField(label=_(u"Free ID"))
diff --git a/archaeological_finds/migrations/0010_auto_20171011_1644.py b/archaeological_finds/migrations/0010_auto_20171011_1644.py
new file mode 100644
index 000000000..ce892e96d
--- /dev/null
+++ b/archaeological_finds/migrations/0010_auto_20171011_1644.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-11 16:44
+from __future__ import unicode_literals
+
+import django.contrib.postgres.search
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0009_auto_20171010_1644'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='basefind',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='find',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='historicalbasefind',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='historicalfind',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatment',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatmentfile',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='property',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='treatment',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ migrations.AddField(
+ model_name='treatmentfile',
+ name='search_vector',
+ field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'),
+ ),
+ ]
diff --git a/archaeological_finds/migrations/0011_auto_20171012_1316.py b/archaeological_finds/migrations/0011_auto_20171012_1316.py
new file mode 100644
index 000000000..6fabd578f
--- /dev/null
+++ b/archaeological_finds/migrations/0011_auto_20171012_1316.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-12 13:16
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0010_auto_20171011_1644'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='basefind',
+ name='cache_complete_id',
+ field=models.TextField(blank=True, db_index=True, help_text='Cached value - do not edit', null=True, verbose_name='Complete ID'),
+ ),
+ migrations.AlterField(
+ model_name='basefind',
+ name='cache_short_id',
+ field=models.TextField(blank=True, db_index=True, help_text='Cached value - do not edit', null=True, verbose_name='Short ID'),
+ ),
+ migrations.AlterField(
+ model_name='find',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ migrations.AlterField(
+ model_name='historicalbasefind',
+ name='cache_complete_id',
+ field=models.TextField(blank=True, db_index=True, help_text='Cached value - do not edit', null=True, verbose_name='Complete ID'),
+ ),
+ migrations.AlterField(
+ model_name='historicalbasefind',
+ name='cache_short_id',
+ field=models.TextField(blank=True, db_index=True, help_text='Cached value - do not edit', null=True, verbose_name='Short ID'),
+ ),
+ migrations.AlterField(
+ model_name='historicalfind',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ migrations.AlterField(
+ model_name='historicaltreatment',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ migrations.AlterField(
+ model_name='historicaltreatmentfile',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ migrations.AlterField(
+ model_name='treatment',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ migrations.AlterField(
+ model_name='treatmentfile',
+ name='cached_label',
+ field=models.TextField(blank=True, db_index=True, null=True, verbose_name='Cached name'),
+ ),
+ ]
diff --git a/archaeological_finds/migrations/0012_auto_20171017_1840.py b/archaeological_finds/migrations/0012_auto_20171017_1840.py
new file mode 100644
index 000000000..8c347b270
--- /dev/null
+++ b/archaeological_finds/migrations/0012_auto_20171017_1840.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2017-10-17 18:40
+from __future__ import unicode_literals
+
+import django.contrib.postgres.fields.jsonb
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0011_auto_20171012_1316'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='basefind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='find',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='historicalbasefind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='historicalfind',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatment',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='historicaltreatmentfile',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='property',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='treatment',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ migrations.AddField(
+ model_name='treatmentfile',
+ name='data',
+ field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default={}),
+ ),
+ ]
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e58d14f7e..8052601bf 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -231,14 +231,17 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms):
line = models.LineStringField(_(u"Line"), blank=True, null=True)
polygon = models.PolygonField(_(u"Polygon"), blank=True, null=True)
cache_short_id = models.TextField(
- _(u"Short ID"), blank=True, null=True,
+ _(u"Short ID"), blank=True, null=True, db_index=True,
help_text=_(u"Cached value - do not edit"))
cache_complete_id = models.TextField(
- _(u"Complete ID"), blank=True, null=True,
+ _(u"Complete ID"), blank=True, null=True, db_index=True,
help_text=_(u"Cached value - do not edit"))
history = HistoricalRecords()
RELATED_POST_PROCESS = ['find']
CACHED_LABELS = ['cache_short_id', 'cache_complete_id']
+ PARENT_SEARCH_VECTORS = ['context_record']
+ BASE_SEARCH_VECTORS = ["label", "description", "comment", "cache_short_id",
+ "cache_complete_id"]
class Meta:
verbose_name = _(u"Base find")
@@ -748,9 +751,18 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,
appraisal_date = models.DateField(_(u"Appraisal date"), blank=True,
null=True)
- cached_label = models.TextField(_(u"Cached name"), null=True, blank=True)
+ cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
+ db_index=True)
history = HistoricalRecords()
BASKET_MODEL = FindBasket
+ PARENT_SEARCH_VECTORS = ['base_finds']
+ BASE_SEARCH_VECTORS = [
+ "cached_label", "label", "description", "container__location__name",
+ "container__reference", "mark", "comment", "dating_comment",
+ "previous_id"]
+ M2M_SEARCH_VECTORS = [
+ "datings__period__label", "object_types__label", "integrities__label",
+ "remarkabilities__label", "material_types__label"]
class Meta:
verbose_name = _(u"Find")
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 0ffcd87fa..03eeed452 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -115,7 +115,8 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
blank=True, null=True)
target_is_basket = models.BooleanField(_(u"Target a basket"),
default=False)
- cached_label = models.TextField(_(u"Cached name"), null=True, blank=True)
+ cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
+ db_index=True)
history = HistoricalRecords()
class Meta:
@@ -224,6 +225,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
return values
def pre_save(self):
+ super(Treatment, self).pre_save()
# is not new
if self.pk is not None:
return
@@ -506,7 +508,8 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem,
reception_date = models.DateField(_(u'Reception date'), blank=True,
null=True)
comment = models.TextField(_(u"Comment"), null=True, blank=True)
- cached_label = models.TextField(_(u"Cached name"), null=True, blank=True)
+ cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
+ db_index=True)
history = HistoricalRecords()
class Meta:
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index efd38e406..68304740d 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -58,6 +58,8 @@
{% field "Description" item.description "<pre>" "</pre>" %}
{% field "Comment" item.comment "<pre>" "</pre>" %}
+{% include "ishtar/blocks/sheet_json.html" %}
+
{% if item.conservatory_state or item.conservatory_comment or item.alterations.count or item.alteration_causes.count or item.preservation_to_considers.count or item.treatment_emergency or item.insurance_value %}
<h4>{% trans "Preservation" %}</h4>
<ul class='form-flex'>
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html
index 5fc8f2aac..94f6e20a7 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatment.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatment.html
@@ -42,6 +42,8 @@
{% field "Goal" item.goal "<pre>" "</pre>" %}
{% endif %}
+{% include "ishtar/blocks/sheet_json.html" %}
+
{% trans "Upstream finds" as finds %}
{% if item.upstream.count %}
{% dynamic_table_document finds 'finds_for_treatment' 'downstream_treatment' item.pk 'TABLE_COLS_FOR_OPE' output %}
diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
index f8fb3e0aa..9567d3081 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html
@@ -26,6 +26,8 @@
</ul>
{% field "Comment" item.comment "<pre>" "</pre>" %}
+{% include "ishtar/blocks/sheet_json.html" %}
+
{% if item.applicant %}
<h3>{% trans "Applicant" %}</h3>
<ul class='form-flex'>