summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/admin.py3
-rw-r--r--archaeological_finds/migrations/0016_auto_20180215_1154.py41
-rw-r--r--archaeological_finds/models.py6
-rw-r--r--archaeological_finds/models_finds.py16
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html1
5 files changed, 65 insertions, 2 deletions
diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py
index e2348458b..91cbbada7 100644
--- a/archaeological_finds/admin.py
+++ b/archaeological_finds/admin.py
@@ -173,6 +173,9 @@ class MaterialTypeAdmin(HierarchicalTypeAdmin):
admin_site.register(models.MaterialType, MaterialTypeAdmin)
+admin_site.register(models.CommunicabilityType, HierarchicalTypeAdmin)
+
+
class TreatmentTypeAdmin(GeneralTypeAdmin):
list_display = HierarchicalTypeAdmin.list_display + [
'order', 'virtual', 'upstream_is_many', 'downstream_is_many']
diff --git a/archaeological_finds/migrations/0016_auto_20180215_1154.py b/archaeological_finds/migrations/0016_auto_20180215_1154.py
new file mode 100644
index 000000000..81b9c3bc3
--- /dev/null
+++ b/archaeological_finds/migrations/0016_auto_20180215_1154.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-02-15 11:54
+from __future__ import unicode_literals
+
+import django.core.validators
+from django.db import migrations, models
+import django.db.models.deletion
+import ishtar_common.models
+import re
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0015_auto_20180119_1516'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CommunicabilityType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.CharField(max_length=100, verbose_name='Label')),
+ ('txt_idx', models.CharField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', max_length=100, unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')], verbose_name='Textual ID')),
+ ('comment', models.TextField(blank=True, null=True, verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='archaeological_finds.CommunicabilityType', verbose_name='Parent')),
+ ],
+ options={
+ 'ordering': ('parent__label', 'label'),
+ 'verbose_name': 'Communicability type',
+ 'verbose_name_plural': 'Communicability types',
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.AddField(
+ model_name='find',
+ name='communicabilities',
+ field=models.ManyToManyField(blank=True, related_name='find', to='archaeological_finds.CommunicabilityType', verbose_name='Communicability'),
+ ),
+ ]
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index 2f7c547b8..a0f387620 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -2,7 +2,8 @@ from archaeological_finds.models_finds import MaterialType, ConservatoryState,\
IntegrityType, RemarkabilityType, ObjectType, BaseFind, \
FindBasket, Find, FindSource, Property, CHECK_CHOICES, BatchType, \
BFBulkView, FBulkView, FirstBaseFindView, AlterationType, \
- AlterationCauseType, TreatmentEmergencyType, TreatmentType
+ AlterationCauseType, TreatmentEmergencyType, TreatmentType, \
+ CommunicabilityType
from archaeological_finds.models_treatments import Treatment, \
AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \
FindTreatments, TreatmentSource, TreatmentFile, TreatmentFileType, \
@@ -16,4 +17,5 @@ __all__ = ['MaterialType', 'ConservatoryState',
'CHECK_CHOICES', 'BatchType', 'TreatmentType', 'TreatmentState',
'Treatment', 'AbsFindTreatments', 'FindUpstreamTreatments',
'FindDownstreamTreatments', 'FindTreatments', 'TreatmentSource',
- 'TreatmentFile', 'TreatmentFileType', 'TreatmentFileSource']
+ 'TreatmentFile', 'TreatmentFileType', 'TreatmentFileSource',
+ 'CommunicabilityType']
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e1c866f9d..34e3c4f87 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -89,6 +89,8 @@ class TreatmentType(GeneralType):
verbose_name = _(u"Treatment type")
verbose_name_plural = _(u"Treatment types")
ordering = ('label',)
+
+
post_save.connect(post_save_cache, sender=TreatmentType)
post_delete.connect(post_save_cache, sender=TreatmentType)
@@ -171,6 +173,17 @@ post_save.connect(post_save_cache, sender=TreatmentEmergencyType)
post_delete.connect(post_save_cache, sender=TreatmentEmergencyType)
+class CommunicabilityType(HierarchicalType):
+ class Meta:
+ verbose_name = _(u"Communicability type")
+ verbose_name_plural = _(u"Communicability types")
+ ordering = ('parent__label', 'label',)
+
+
+post_save.connect(post_save_cache, sender=CommunicabilityType)
+post_delete.connect(post_save_cache, sender=CommunicabilityType)
+
+
class BFBulkView(object):
CREATE_SQL = """
CREATE VIEW basefind_cached_bulk_update
@@ -699,6 +712,9 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,
remarkabilities = models.ManyToManyField(
RemarkabilityType, verbose_name=_(u"Remarkability"),
related_name='find', blank=True)
+ communicabilities = models.ManyToManyField(
+ CommunicabilityType, verbose_name=_(u"Communicability"),
+ related_name='find', blank=True)
min_number_of_individuals = models.IntegerField(
_(u"Minimum number of individuals (MNI)"), blank=True, null=True)
length = models.FloatField(_(u"Length (cm)"), blank=True, null=True)
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index 67cd479c3..ab97c7b24 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -53,6 +53,7 @@
{% field_flex_multiple "Object types" item.object_types %}
{% field_flex_multiple "Integrity / interest" item.integrities %}
{% field_flex_multiple "Remarkability" item.remarkabilities %}
+ {% field_flex_multiple "Communicability" item.communicabilities %}
{% field_flex "Estimated value" item.estimated_value|default_if_none:''|intcomma '' ' '|add:CURRENCY %}
{% if item.CHECK_DICT %}
{% field_flex "Checked" item.checked|from_dict:item.CHECK_DICT %}