summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.example2
-rw-r--r--archaeological_context_records/migrations/0119_default_typos.py11
-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
-rw-r--r--archaeological_finds/migrations/0116_data_migration_museum_technical.py8
-rw-r--r--ishtar_common/migrations/0237_data_migration_licenses_shootingangle.py8
-rw-r--r--ishtar_common/migrations/0239_shootingangle_parent.py8
11 files changed, 330 insertions, 16 deletions
diff --git a/Makefile.example b/Makefile.example
index e3225daa4..305eb0782 100644
--- a/Makefile.example
+++ b/Makefile.example
@@ -344,6 +344,8 @@ fixtures_files:
archaeological_files.equipmentservicecost \
archaeological_files.operationtypeforroyalties \
archaeological_files.agreementtype \
+ archaeological_files.developmenttype \
+ archaeological_files.monitoringjustificationtype \
> '../archaeological_files/fixtures/initial_data-'$(default_data)'.json'
readme_md_to_rst:
diff --git a/archaeological_context_records/migrations/0119_default_typos.py b/archaeological_context_records/migrations/0119_default_typos.py
index 10cdab665..bdfa927ca 100644
--- a/archaeological_context_records/migrations/0119_default_typos.py
+++ b/archaeological_context_records/migrations/0119_default_typos.py
@@ -3,13 +3,12 @@
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")
+def load_data(apps, __):
+ StructureType = apps.get_model("archaeological_context_records", "structuretype")
+ if not StructureType.objects.count():
+ migrations_load_data("archaeological_context_records",
+ "0119_default_typos.json")
class Migration(migrations.Migration):
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
diff --git a/archaeological_finds/migrations/0116_data_migration_museum_technical.py b/archaeological_finds/migrations/0116_data_migration_museum_technical.py
index 523388f31..c2804c539 100644
--- a/archaeological_finds/migrations/0116_data_migration_museum_technical.py
+++ b/archaeological_finds/migrations/0116_data_migration_museum_technical.py
@@ -6,9 +6,11 @@ from django.db import migrations
from django.core.management import call_command
-def load_data(_, __):
- json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0116_data_migration.json"])
- call_command("loaddata", json_path)
+def load_data(apps, __):
+ TechnicalProcessType = apps.get_model("archaeological_finds", "technicalprocesstype")
+ if not TechnicalProcessType.objects.count():
+ json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0116_data_migration.json"])
+ call_command("loaddata", json_path)
class Migration(migrations.Migration):
diff --git a/ishtar_common/migrations/0237_data_migration_licenses_shootingangle.py b/ishtar_common/migrations/0237_data_migration_licenses_shootingangle.py
index bfebf20b5..ca4817fbf 100644
--- a/ishtar_common/migrations/0237_data_migration_licenses_shootingangle.py
+++ b/ishtar_common/migrations/0237_data_migration_licenses_shootingangle.py
@@ -6,9 +6,11 @@ from django.db import migrations
from django.core.management import call_command
-def load_data(_, __):
- json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0237_data_migration.json"])
- call_command("loaddata", json_path)
+def load_data(apps, __):
+ LicenseType = apps.get_model("ishtar_common", "licensetype")
+ if not LicenseType.objects.count():
+ json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0237_data_migration.json"])
+ call_command("loaddata", json_path)
class Migration(migrations.Migration):
diff --git a/ishtar_common/migrations/0239_shootingangle_parent.py b/ishtar_common/migrations/0239_shootingangle_parent.py
index 4c530b46c..e4b01fa04 100644
--- a/ishtar_common/migrations/0239_shootingangle_parent.py
+++ b/ishtar_common/migrations/0239_shootingangle_parent.py
@@ -6,9 +6,11 @@ import django.db.models.deletion
from django.core.management import call_command
-def load_data(_, __):
- json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0237_data_migration.json"])
- call_command("loaddata", json_path)
+def load_data(apps, __):
+ ShootingAngle = apps.get_model("ishtar_common", "shootingangle")
+ if not ShootingAngle.objects.count():
+ json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ["0239_shootingangle_parent.json"])
+ call_command("loaddata", json_path)
class Migration(migrations.Migration):