diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-01-30 13:08:34 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-02-19 14:45:56 +0100 |
commit | 042b8f956369c115536dfe7e33d9c0461dafe539 (patch) | |
tree | 90f8577c5e52047be00f5aeb2f31d010f0d65fb2 /ishtar_common/migrations | |
parent | bfae6a086ff5d35c794a5c5c0380bf2332661452 (diff) | |
download | Ishtar-042b8f956369c115536dfe7e33d9c0461dafe539.tar.bz2 Ishtar-042b8f956369c115536dfe7e33d9c0461dafe539.zip |
✨ admin: better management of Import - Item keys, import/export, links all user/imports
Diffstat (limited to 'ishtar_common/migrations')
-rw-r--r-- | ishtar_common/migrations/0260_itemkey_importer_type.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0260_itemkey_importer_type.py b/ishtar_common/migrations/0260_itemkey_importer_type.py new file mode 100644 index 000000000..789f22162 --- /dev/null +++ b/ishtar_common/migrations/0260_itemkey_importer_type.py @@ -0,0 +1,62 @@ +# Generated by Django 2.2.24 on 2025-01-30 15:55 + +from django.db import migrations, models, connection +import django.db.models.deletion + + +def migrate_import_type(apps, __): + ItemKey = apps.get_model("ishtar_common", "ItemKey") + Import = apps.get_model("ishtar_common", "Import") + + with connection.cursor() as cursor: + cursor.execute("SELECT id, importer_id FROM ishtar_common_itemkey WHERE importer_id IS NOT NULL;") + for ik_id, import_id in cursor.fetchall(): + importer_type_id = Import.objects.get(pk=import_id).importer_type_id + ik = ItemKey.objects.get(pk=ik_id) + ik.importer_type_id = importer_type_id + ik.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0259_ishtarsiteprofile_default_location_for_treatment'), + ] + + operations = [ + migrations.AlterModelOptions( + name='targetkey', + options={'ordering': ('target', 'key'), 'verbose_name': 'Import - Target key', 'verbose_name_plural': 'Import - Targets keys'}, + ), + migrations.AddField( + model_name='itemkey', + name='importer_type', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterType'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='default_location_for_treatment', + field=models.ForeignKey(blank=True, help_text='If provided, treatment forms have by default this location set. Furthermore if this location has an organization attached, this organization is set by default.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_warehouse.Warehouse', verbose_name='Default location for treatments'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='find_external_id', + field=models.TextField(default='{{get_first_base_find__context_record__external_id}}-{{label}}{% if upstream_count %}-{{upstream_count}}{% endif %}', help_text='Formula to manage find external ID. Change this with care. With incorrect formula, the application might be unusable and import of external data can be destructive.', verbose_name='Find external id'), + ), + 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'), + ), + migrations.RunPython(migrate_import_type), + migrations.RenameField( + model_name='itemkey', + old_name='importer', + new_name='ishtar_import' + ), + migrations.AlterField( + model_name='itemkey', + name='ishtar_import', + field=models.ForeignKey(blank=True, help_text='Specific key to an import', null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Import'), + ), + ] |