summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-16 19:04:34 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-16 19:04:34 +0200
commitfd5e330ede426a7152deab41620b6a60b63df220 (patch)
tree02fb227e93c929db6dc4a3d6ef254516bdc6f2fe
parent0f88ac0c7abd4ecb5e9bed54474af23752efcbcd (diff)
downloadIshtar-fd5e330ede426a7152deab41620b6a60b63df220.tar.bz2
Ishtar-fd5e330ede426a7152deab41620b6a60b63df220.zip
🗃️ context records new fields, default values, admin interface - town add notice (refs #6024)
Town: - notice Context records: - excavated length - excavated width - structure - texture - colors - details on colors - inclusions
-rw-r--r--Makefile.example4
-rw-r--r--archaeological_context_records/admin.py4
-rw-r--r--archaeological_context_records/migrations/0118_context_record_new_fields_new_types.py139
-rw-r--r--archaeological_context_records/migrations/0119_default_typos.json310
-rw-r--r--archaeological_context_records/migrations/0119_default_typos.py23
-rw-r--r--archaeological_context_records/models.py65
-rw-r--r--ishtar_common/migrations/0249_town_notice.py24
-rw-r--r--ishtar_common/models_common.py1
8 files changed, 569 insertions, 1 deletions
diff --git a/Makefile.example b/Makefile.example
index ece0024e7..e3225daa4 100644
--- a/Makefile.example
+++ b/Makefile.example
@@ -287,6 +287,10 @@ fixtures_context_records:
archaeological_context_records.datingtype \
archaeological_context_records.excavationtechnictype \
archaeological_context_records.documentationtype \
+ archaeological_context_records.structuretype \
+ archaeological_context_records.texturetype \
+ archaeological_context_records.colortype \
+ archaeological_context_records.inclusiontype \
> '../archaeological_context_records/fixtures/initial_data-'$(default_data)'.json'
cd $(project); $(PYTHON) ./manage.py dumpdata --indent 4 --natural-primary --natural-foreign \
archaeological_context_records.relationtype \
diff --git a/archaeological_context_records/admin.py b/archaeological_context_records/admin.py
index 518650874..ab3e98797 100644
--- a/archaeological_context_records/admin.py
+++ b/archaeological_context_records/admin.py
@@ -111,6 +111,10 @@ general_models = [
models.DocumentationType,
models.ActivityType,
models.ExcavationTechnicType,
+ models.InclusionType,
+ models.ColorType,
+ models.TextureType,
+ models.StructureType
]
for model in general_models:
admin_site.register(model, GeneralTypeAdmin)
diff --git a/archaeological_context_records/migrations/0118_context_record_new_fields_new_types.py b/archaeological_context_records/migrations/0118_context_record_new_fields_new_types.py
new file mode 100644
index 000000000..fc79df86d
--- /dev/null
+++ b/archaeological_context_records/migrations/0118_context_record_new_fields_new_types.py
@@ -0,0 +1,139 @@
+# Generated by Django 2.2.24 on 2024-09-16 17:22
+
+import django.core.validators
+from django.db import migrations, models
+import django.db.models.deletion
+import ishtar_common.models_common
+import re
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0117_identification_m2m'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='details_on_color',
+ field=models.TextField(blank=True, default='', verbose_name='Details on color'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='excavated_length',
+ field=models.FloatField(blank=True, null=True, verbose_name='Excavated length (m)'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='excavated_width',
+ field=models.FloatField(blank=True, null=True, verbose_name='Excavated width (m)'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='details_on_color',
+ field=models.TextField(blank=True, default='', verbose_name='Details on color'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='excavated_length',
+ field=models.FloatField(blank=True, null=True, verbose_name='Excavated length (m)'),
+ ),
+ migrations.AddField(
+ model_name='historicalcontextrecord',
+ name='excavated_width',
+ field=models.FloatField(blank=True, null=True, verbose_name='Excavated width (m)'),
+ ),
+ migrations.CreateModel(
+ name='TextureType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', 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, default='', verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('order', models.IntegerField(default=10, verbose_name='Order')),
+ ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.TextureType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Texture Type',
+ 'verbose_name_plural': 'Texture Types',
+ 'ordering': ('order', 'label'),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='StructureType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', 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, default='', verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('order', models.IntegerField(default=10, verbose_name='Order')),
+ ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.StructureType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Structure Type',
+ 'verbose_name_plural': 'Structure Types',
+ 'ordering': ('order', 'label'),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='InclusionType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', 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, default='', verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('order', models.IntegerField(default=10, verbose_name='Order')),
+ ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.InclusionType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Inclusion Type',
+ 'verbose_name_plural': 'Inclusion Types',
+ 'ordering': ('order', 'label'),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='ColorType',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('label', models.TextField(verbose_name='Label')),
+ ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', 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, default='', verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ('order', models.IntegerField(default=10, verbose_name='Order')),
+ ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.ColorType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Color Type',
+ 'verbose_name_plural': 'Color Types',
+ 'ordering': ('order', 'label'),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='colors',
+ field=models.ManyToManyField(blank=True, to='archaeological_context_records.ColorType'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='inclusions',
+ field=models.ManyToManyField(blank=True, to='archaeological_context_records.InclusionType'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='structures',
+ field=models.ManyToManyField(blank=True, to='archaeological_context_records.StructureType'),
+ ),
+ migrations.AddField(
+ model_name='contextrecord',
+ name='textures',
+ field=models.ManyToManyField(blank=True, to='archaeological_context_records.TextureType'),
+ ),
+ ]
diff --git a/archaeological_context_records/migrations/0119_default_typos.json b/archaeological_context_records/migrations/0119_default_typos.json
new file mode 100644
index 000000000..2a1c508d2
--- /dev/null
+++ b/archaeological_context_records/migrations/0119_default_typos.json
@@ -0,0 +1,310 @@
+[
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Homog\u00e8ne",
+ "txt_idx": "homogeneous",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "H\u00e9t\u00e9rog\u00e8ne",
+ "txt_idx": "heterogeneous",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Compacte",
+ "txt_idx": "compact",
+ "comment": "",
+ "available": true,
+ "order": 30,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Meuble",
+ "txt_idx": "loose",
+ "comment": "",
+ "available": true,
+ "order": 40,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Particulaire",
+ "txt_idx": "particular",
+ "comment": "",
+ "available": true,
+ "order": 50,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Grumeleuse",
+ "txt_idx": "lumpy",
+ "comment": "",
+ "available": true,
+ "order": 60,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Poly\u00e9drique",
+ "txt_idx": "polyedral",
+ "comment": "",
+ "available": true,
+ "order": 70,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.structuretype",
+ "fields": {
+ "label": "Massive",
+ "txt_idx": "massive",
+ "comment": "",
+ "available": true,
+ "order": 80,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.texturetype",
+ "fields": {
+ "label": "Argile",
+ "txt_idx": "clay",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.texturetype",
+ "fields": {
+ "label": "Limons",
+ "txt_idx": "silt",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.texturetype",
+ "fields": {
+ "label": "Sables",
+ "txt_idx": "sand",
+ "comment": "",
+ "available": true,
+ "order": 30,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.texturetype",
+ "fields": {
+ "label": "Graviers",
+ "txt_idx": "gravel",
+ "comment": "",
+ "available": true,
+ "order": 40,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.texturetype",
+ "fields": {
+ "label": "Cailloutis",
+ "txt_idx": "pebbles",
+ "comment": "",
+ "available": true,
+ "order": 50,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Jaune",
+ "txt_idx": "yellow",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Beige",
+ "txt_idx": "beige",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Ocre",
+ "txt_idx": "ochre",
+ "comment": "",
+ "available": true,
+ "order": 30,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Orange",
+ "txt_idx": "orange",
+ "comment": "",
+ "available": true,
+ "order": 40,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Rouge",
+ "txt_idx": "red",
+ "comment": "",
+ "available": true,
+ "order": 50,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Brun",
+ "txt_idx": "brown",
+ "comment": "",
+ "available": true,
+ "order": 60,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Gris",
+ "txt_idx": "grey",
+ "comment": "",
+ "available": true,
+ "order": 70,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Blanc",
+ "txt_idx": "white",
+ "comment": "",
+ "available": true,
+ "order": 80,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.colortype",
+ "fields": {
+ "label": "Autre",
+ "txt_idx": "other",
+ "comment": "",
+ "available": true,
+ "order": 90,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Cendre",
+ "txt_idx": "ash",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Charbons",
+ "txt_idx": "coals",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Cailloutis",
+ "txt_idx": "pebbles",
+ "comment": "",
+ "available": true,
+ "order": 30,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Blocs",
+ "txt_idx": "boulders",
+ "comment": "",
+ "available": true,
+ "order": 40,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Racines",
+ "txt_idx": "roots",
+ "comment": "",
+ "available": true,
+ "order": 50,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_context_records.inclusiontype",
+ "fields": {
+ "label": "Autre",
+ "txt_idx": "other",
+ "comment": "",
+ "available": true,
+ "order": 60,
+ "parent": null
+ }
+}
+]
diff --git a/archaeological_context_records/migrations/0119_default_typos.py b/archaeological_context_records/migrations/0119_default_typos.py
new file mode 100644
index 000000000..10cdab665
--- /dev/null
+++ b/archaeological_context_records/migrations/0119_default_typos.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.24 on 2024-03-25 17:24
+
+from django.db import migrations
+from ishtar_common.utils import migrations_load_data
+
+COLOR_WARNING = "\033[93m"
+COLOR_ENDC = "\033[0m"
+
+
+def load_data(_, __):
+ migrations_load_data("archaeological_context_records",
+ "0119_default_typos.json")
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0118_context_record_new_fields_new_types'),
+ ]
+
+ operations = [
+ migrations.RunPython(load_data)
+ ] \ No newline at end of file
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 3867997de..062535e04 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -347,6 +347,62 @@ post_save.connect(post_save_cache, sender=IdentificationType)
post_delete.connect(post_save_cache, sender=IdentificationType)
+class StructureType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Structure Type")
+ verbose_name_plural = _("Structure Types")
+ ordering = ("order", "label")
+
+ def __str__(self):
+ return self.label
+
+
+post_save.connect(post_save_cache, sender=StructureType)
+post_delete.connect(post_save_cache, sender=StructureType)
+
+
+class TextureType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Texture Type")
+ verbose_name_plural = _("Texture Types")
+ ordering = ("order", "label")
+
+ def __str__(self):
+ return self.label
+
+
+post_save.connect(post_save_cache, sender=TextureType)
+post_delete.connect(post_save_cache, sender=TextureType)
+
+
+class ColorType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Color Type")
+ verbose_name_plural = _("Color Types")
+ ordering = ("order", "label")
+
+ def __str__(self):
+ return self.label
+
+
+post_save.connect(post_save_cache, sender=ColorType)
+post_delete.connect(post_save_cache, sender=ColorType)
+
+
+class InclusionType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Inclusion Type")
+ verbose_name_plural = _("Inclusion Types")
+ ordering = ("order", "label")
+
+ def __str__(self):
+ return self.label
+
+
+post_save.connect(post_save_cache, sender=InclusionType)
+post_delete.connect(post_save_cache, sender=InclusionType)
+
+
class ExcavationTechnicType(GeneralType):
class Meta:
verbose_name = _("Excavation technique type")
@@ -774,7 +830,9 @@ class ContextRecord(
opening_date = models.DateField(_("Opening date"), blank=True, null=True)
closing_date = models.DateField(_("Closing date"), blank=True, null=True)
length = models.FloatField(_("Length (m)"), blank=True, null=True)
+ excavated_length = models.FloatField(_("Excavated length (m)"), blank=True, null=True)
width = models.FloatField(_("Width (m)"), blank=True, null=True)
+ excavated_width = models.FloatField(_("Excavated width (m)"), blank=True, null=True)
thickness = models.FloatField(_("Thickness (m)"), blank=True, null=True)
diameter = models.FloatField(_("Diameter (m)"), blank=True, null=True)
depth = models.FloatField(_("Depth (m)"), blank=True, null=True)
@@ -786,10 +844,15 @@ class ContextRecord(
_("Location"),
blank=True,
default="",
- help_text=_("A short description of the location of the context " "record"),
+ help_text=_("A short description of the location of the context record"),
)
datings = models.ManyToManyField(Dating, related_name="context_records")
documentations = models.ManyToManyField(DocumentationType, blank=True)
+ structures = models.ManyToManyField(StructureType, blank=True)
+ textures = models.ManyToManyField(TextureType, blank=True)
+ colors = models.ManyToManyField(ColorType, blank=True)
+ details_on_color = models.TextField(_("Details on color"), blank=True, default="")
+ inclusions = models.ManyToManyField(InclusionType, blank=True)
datings_comment = models.TextField(_("Comment on datings"), blank=True, default="")
unit = models.ForeignKey(
Unit,
diff --git a/ishtar_common/migrations/0249_town_notice.py b/ishtar_common/migrations/0249_town_notice.py
new file mode 100644
index 000000000..f4961a6a7
--- /dev/null
+++ b/ishtar_common/migrations/0249_town_notice.py
@@ -0,0 +1,24 @@
+# Generated by Django 2.2.24 on 2024-09-16 17:22
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0248_ishtarsiteprofile_no_context_button'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='town',
+ name='notice',
+ field=models.TextField(blank=True, default='', verbose_name='Notice'),
+ ),
+ migrations.AlterField(
+ model_name='ishtarsiteprofile',
+ name='no_context_button',
+ field=models.ForeignKey(blank=True, help_text='If provided a button is displayed on find add page to create a "No context" find', null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.ContextRecord', verbose_name='Context record for no context button'),
+ ),
+ ]
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 98dbb047b..9aec54534 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -3398,6 +3398,7 @@ class Town(GeographicItem, Imported, DocumentItem, MainItem, models.Model):
)
limit = models.MultiPolygonField(_("Limit"), blank=True, null=True)
numero_insee = models.CharField("Code commune (numéro INSEE)", max_length=120)
+ notice = models.TextField(_("Notice"), blank=True, default="")
departement = models.ForeignKey(
Department,
verbose_name=_("Department"),