summaryrefslogtreecommitdiff
path: root/archaeological_finds/migrations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-13 17:44:41 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-13 18:26:04 +0200
commitf9cd1ea816f2f019afe08588df1349030355b5dd (patch)
treee6159eec34e222717933afcb1aac547099386693 /archaeological_finds/migrations
parent9537f2fb5bf2d9f6552d43cf0c4ed029e8e65ec7 (diff)
downloadIshtar-f9cd1ea816f2f019afe08588df1349030355b5dd.tar.bz2
Ishtar-f9cd1ea816f2f019afe08588df1349030355b5dd.zip
Find: migrate checked to a real type - Find select form configuration
Diffstat (limited to 'archaeological_finds/migrations')
-rw-r--r--archaeological_finds/migrations/0033_auto_20180813_1310.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/archaeological_finds/migrations/0033_auto_20180813_1310.py b/archaeological_finds/migrations/0033_auto_20180813_1310.py
new file mode 100644
index 000000000..aea94a8e9
--- /dev/null
+++ b/archaeological_finds/migrations/0033_auto_20180813_1310.py
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-08-13 13:10
+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
+
+
+def migrate_finds(apps, schema_editor):
+ Find = apps.get_model('archaeological_finds', 'Find')
+ CheckedType = apps.get_model('archaeological_finds',
+ 'RecordQualityType')
+
+ not_checked, c = CheckedType.objects.get_or_create(
+ txt_idx=u"not-checked",
+ defaults={
+ "label": u"Non vérifié",
+ "order": 10
+ }
+ )
+ checked_not_correct, c = CheckedType.objects.get_or_create(
+ txt_idx=u"checked-not-correct",
+ defaults={
+ "label": u"Vérifié mais incorrect",
+ "order": 20
+ }
+ )
+ checked_correct, c = CheckedType.objects.get_or_create(
+ txt_idx=u"checked-correct",
+ defaults={
+ "label": u"Vérifié et correct",
+ "order": 30
+ }
+ )
+ CHECK_CHOICES = {
+ 'NC': not_checked,
+ 'CI': checked_not_correct,
+ 'CC': checked_correct,
+ }
+
+ for f in Find.objects.all():
+ if not f.checked:
+ continue
+ f.checked_type = CHECK_CHOICES[f.checked]
+ f.skip_history_when_saving = True
+ f.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0032_auto_20180619_0911'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CheckedType',
+ 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, null=True, verbose_name='Comment')),
+ ('available', models.BooleanField(default=True, verbose_name='Available')),
+ ],
+ options={
+ 'ordering': ('label',),
+ 'verbose_name': 'Checked type',
+ 'verbose_name_plural': 'Checked types',
+ },
+ bases=(ishtar_common.models.Cached, models.Model),
+ ),
+ migrations.AddField(
+ model_name='find',
+ name='checked_type',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='archaeological_finds.CheckedType', verbose_name='Check'),
+ ),
+ migrations.AddField(
+ model_name='historicalfind',
+ name='checked_type',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='archaeological_finds.CheckedType'),
+ ),
+ migrations.RunPython(migrate_finds),
+ ]