summaryrefslogtreecommitdiff
path: root/archaeological_files
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-18 15:42:48 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-18 15:47:39 +0200
commit5d975efdb36f5f238bfe586497abd19d6d52617a (patch)
treea58b40c6190e146f6a3c04d80baa2f04d417f981 /archaeological_files
parent4c244578cd933128bb444c91c686cc7c8975391c (diff)
downloadIshtar-5d975efdb36f5f238bfe586497abd19d6d52617a.tar.bz2
Ishtar-5d975efdb36f5f238bfe586497abd19d6d52617a.zip
🗃️ archaeological files: new fields in database
- Monitoring justification type - Development type
Diffstat (limited to 'archaeological_files')
-rw-r--r--archaeological_files/admin.py4
-rw-r--r--archaeological_files/migrations/0116_developmenttype_monitoring_justif.py85
-rw-r--r--archaeological_files/migrations/0117_data_developmenttype_monitoring_justif.py28
-rw-r--r--archaeological_files/migrations/0117_developmenttype.json134
-rw-r--r--archaeological_files/migrations/0117_monitoringjustificationtype.json24
-rw-r--r--archaeological_files/models.py34
6 files changed, 308 insertions, 1 deletions
diff --git a/archaeological_files/admin.py b/archaeological_files/admin.py
index 6f73c1340..40fcfd42b 100644
--- a/archaeological_files/admin.py
+++ b/archaeological_files/admin.py
@@ -75,7 +75,9 @@ general_models = [
models.PermitType,
models.GenericEquipmentServiceType,
models.OperationTypeForRoyalties,
- models.AgreementType
+ models.AgreementType,
+ models.DevelopmentType,
+ models.MonitoringJustificationType
]
if settings.COUNTRY == "fr":
general_models.append(models.SaisineType)
diff --git a/archaeological_files/migrations/0116_developmenttype_monitoring_justif.py b/archaeological_files/migrations/0116_developmenttype_monitoring_justif.py
new file mode 100644
index 000000000..ae7dd325e
--- /dev/null
+++ b/archaeological_files/migrations/0116_developmenttype_monitoring_justif.py
@@ -0,0 +1,85 @@
+# Generated by Django 2.2.24 on 2024-09-18 15:06
+
+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_files', '0115_verbose_names'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='preventivefileequipmentservicecost',
+ options={'ordering': ('equipment_service_cost',), 'verbose_name': 'Equipment requirement', 'verbose_name_plural': 'Equipment requirements'},
+ ),
+ migrations.AlterModelOptions(
+ name='preventivefilegroundjob',
+ options={'ordering': ('job',), 'verbose_name': 'Human requirement on field', 'verbose_name_plural': 'Human requirements on field'},
+ ),
+ migrations.AlterModelOptions(
+ name='preventivefilejob',
+ options={'ordering': ('job',), 'verbose_name': 'Human requirement for post-excavation', 'verbose_name_plural': 'Human requirements for post-excavation'},
+ ),
+ migrations.CreateModel(
+ name='MonitoringJustificationType',
+ 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_files.MonitoringJustificationType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Monitoring justification type',
+ 'verbose_name_plural': 'Monitoring justification types',
+ 'ordering': ('label',),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.CreateModel(
+ name='DevelopmentType',
+ 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_files.DevelopmentType', verbose_name='Parent')),
+ ],
+ options={
+ 'verbose_name': 'Development type',
+ 'verbose_name_plural': 'Development types',
+ 'ordering': ('label',),
+ },
+ bases=(ishtar_common.models_common.Cached, models.Model),
+ ),
+ migrations.AddField(
+ model_name='file',
+ name='development_type',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_files.DevelopmentType', verbose_name='Development type'),
+ ),
+ migrations.AddField(
+ model_name='file',
+ name='monitoring_justification',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_files.MonitoringJustificationType', verbose_name='Monitoring justification'),
+ ),
+ migrations.AddField(
+ model_name='historicalfile',
+ name='development_type',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='archaeological_files.DevelopmentType', verbose_name='Development type'),
+ ),
+ migrations.AddField(
+ model_name='historicalfile',
+ name='monitoring_justification',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='archaeological_files.MonitoringJustificationType', verbose_name='Monitoring justification'),
+ ),
+ ]
diff --git a/archaeological_files/migrations/0117_data_developmenttype_monitoring_justif.py b/archaeological_files/migrations/0117_data_developmenttype_monitoring_justif.py
new file mode 100644
index 000000000..0ef72d773
--- /dev/null
+++ b/archaeological_files/migrations/0117_data_developmenttype_monitoring_justif.py
@@ -0,0 +1,28 @@
+import os
+
+from django.db import migrations
+from django.core.management import call_command
+
+
+def load_data(apps, __):
+ DevelopmentType = apps.get_model("archaeological_files", "developmenttype")
+ if not DevelopmentType.objects.count():
+ migration = "0117_developmenttype.json"
+ json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + [migration])
+ call_command("loaddata", json_path)
+ MonitoringJustificationType = apps.get_model("archaeological_files", "monitoringjustificationtype")
+ if not MonitoringJustificationType.objects.count():
+ migration = "0117_monitoringjustificationtype.json"
+ json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + [migration])
+ call_command("loaddata", json_path)
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_files', '0116_developmenttype_monitoring_justif'),
+ ]
+
+ operations = [
+ migrations.RunPython(load_data)
+ ]
diff --git a/archaeological_files/migrations/0117_developmenttype.json b/archaeological_files/migrations/0117_developmenttype.json
new file mode 100644
index 000000000..c45eea55e
--- /dev/null
+++ b/archaeological_files/migrations/0117_developmenttype.json
@@ -0,0 +1,134 @@
+[
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Am\u00e9nagement ferroviaire",
+ "txt_idx": "amenagement-ferroviaire",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Am\u00e9nagement routier",
+ "txt_idx": "amenagement-routier",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Am\u00e9nagement de r\u00e9seaux",
+ "txt_idx": "amenagement-de-reseaux",
+ "comment": "",
+ "available": true,
+ "order": 30,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Canal",
+ "txt_idx": "canal",
+ "comment": "",
+ "available": true,
+ "order": 40,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Construction",
+ "txt_idx": "construction",
+ "comment": "",
+ "available": true,
+ "order": 50,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Creusement",
+ "txt_idx": "creusement",
+ "comment": "",
+ "available": true,
+ "order": 60,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Lotissement",
+ "txt_idx": "lotissement",
+ "comment": "",
+ "available": true,
+ "order": 70,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Reconversion / r\u00e9novation",
+ "txt_idx": "reconversion-renovation",
+ "comment": "",
+ "available": true,
+ "order": 80,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Restauration sur monuments prot\u00e9g\u00e9s",
+ "txt_idx": "restauration-sur-monuments-proteges",
+ "comment": "",
+ "available": true,
+ "order": 90,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Travaux urbains",
+ "txt_idx": "travaux-urbains",
+ "comment": "",
+ "available": true,
+ "order": 100,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "ZAC",
+ "txt_idx": "zac",
+ "comment": "",
+ "available": true,
+ "order": 110,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.developmenttype",
+ "fields": {
+ "label": "Autre",
+ "txt_idx": "autre",
+ "comment": "",
+ "available": true,
+ "order": 120,
+ "parent": null
+ }
+}
+]
diff --git a/archaeological_files/migrations/0117_monitoringjustificationtype.json b/archaeological_files/migrations/0117_monitoringjustificationtype.json
new file mode 100644
index 000000000..587788f5c
--- /dev/null
+++ b/archaeological_files/migrations/0117_monitoringjustificationtype.json
@@ -0,0 +1,24 @@
+[
+{
+ "model": "archaeological_files.monitoringjustificationtype",
+ "fields": {
+ "label": "Emprise du terrain d'assiette",
+ "txt_idx": "emprise-du-terrain-dassiette",
+ "comment": "",
+ "available": true,
+ "order": 10,
+ "parent": null
+ }
+},
+{
+ "model": "archaeological_files.monitoringjustificationtype",
+ "fields": {
+ "label": "Localisation du terrain d'assiette",
+ "txt_idx": "localisation-du-terrain-dassiette",
+ "comment": "",
+ "available": true,
+ "order": 20,
+ "parent": null
+ }
+}
+]
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index c5e9399c4..74ce3a0d6 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -29,6 +29,8 @@ from django.core.validators import MinValueValidator, MaxValueValidator
from django.db.models import Q, Count, Sum, Max
from django.db.models.signals import post_save, m2m_changed, post_delete
from django.urls import reverse
+
+from ishtar_common.models_common import OrderedHierarchicalType
from ishtar_common.utils import ugettext_lazy as _, pgettext_lazy, get_current_profile
from ishtar_common.utils import (
@@ -353,6 +355,30 @@ post_save.connect(post_save_cache, sender=AgreementType)
post_delete.connect(post_save_cache, sender=AgreementType)
+class MonitoringJustificationType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Monitoring justification type")
+ verbose_name_plural = _("Monitoring justification types")
+ ordering = ("label",)
+ ADMIN_SECTION = _("Preventive")
+
+
+post_save.connect(post_save_cache, sender=MonitoringJustificationType)
+post_delete.connect(post_save_cache, sender=MonitoringJustificationType)
+
+
+class DevelopmentType(OrderedHierarchicalType):
+ class Meta:
+ verbose_name = _("Development type")
+ verbose_name_plural = _("Development types")
+ ordering = ("label",)
+ ADMIN_SECTION = _("Preventive")
+
+
+post_save.connect(post_save_cache, sender=DevelopmentType)
+post_delete.connect(post_save_cache, sender=DevelopmentType)
+
+
class OperationTypeForRoyalties(GeneralType):
increase_coefficient = models.FloatField(
_("Increase coefficient"), default=1)
@@ -719,6 +745,14 @@ class File(
# <-- research archaeology
# --> preventive detail
+ development_type = models.ForeignKey(
+ DevelopmentType, verbose_name=_("Development type"), blank=True, null=True,
+ on_delete=models.SET_NULL
+ )
+ monitoring_justification = models.ForeignKey(
+ MonitoringJustificationType, verbose_name=_("Monitoring justification"), blank=True, null=True,
+ on_delete=models.SET_NULL
+ )
price_agreement = models.ForeignKey(
PriceAgreement, verbose_name=_("Price agreement"), blank=True, null=True,
on_delete=models.SET_NULL