+# Generated by Django 4.0.3 on 2022-03-13 17:16
+
+from django.db import migrations, models
+
+SAFETY_CHOICES = (
+ ('G', 'G'),
+ ('PG', 'PG'),
+ ('PG13', 'PG13'),
+ ('R', 'R'),
+ ('X', 'X'),
+)
+
+BOULDER_DIFFICULTY_CHOICES = (
+ ('V0', 'V0'),
+ ('V1', 'V1'),
+ ('V2', 'V2'),
+ ('V3', 'V3'),
+ ('V4', 'V4'),
+ ('V5', 'V5'),
+ ('V6', 'V6'),
+ ('V7', 'V7'),
+ ('V8', 'V8'),
+ ('V9', 'V9'),
+ ('V10', 'V10'),
+ ('V11', 'V11'),
+ ('V12', 'V12'),
+ ('V13', 'V13'),
+ ('V14', 'V14'),
+ ('V15', 'V15'),
+ ('V16', 'V16'),
+ ('V17', 'V17'),
+)
+
+def forward(app, schema_editor):
+ Pitch = app.get_model('climbing', 'Pitch')
+ Problem = app.get_model('climbing', 'Problem')
+
+ safety_choices = {
+ s[0]: i
+ for i, s in enumerate(SAFETY_CHOICES)
+ }
+
+ difficulty_choices = {
+ d[0]: i
+ for i, d in enumerate(BOULDER_DIFFICULTY_CHOICES)
+ }
+
+ for p in Pitch.objects.all():
+ p.safety = safety_choices[p.safety_old]
+ p.save()
+
+ for p in Problem.objects.all():
+ p.difficulty = difficulty_choices[p.difficulty_old]
+ p.safety = safety[p.safety_old]
+ p.save()
+
+def backward(app, schema_editor):
+ Pitch = app.get_model('climbing', 'Pitch')
+ Problem = app.get_model('climbing', 'Problem')
+
+ for p in Pitch.objects.all():
+ p.safety_old = SAFETY_CHOICES[p.safety][0]
+ p.save()
+
+ for p in Problem.objects.all():
+ p.difficulty_old = BOULDER_DIFFICULTY_CHOICES[p.difficulty][0]
+ p.safety_old = SAFETY_CHOICES[p.safety][0]
+ p.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('climbing', '0009_rename_safety_pitch_safety_old_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='pitch',
+ name='safety',
+ field=models.IntegerField(choices=[(0, 'G'), (1, 'PG'), (2, 'PG13'), (3, 'R'), (4, 'X')], default=0),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='problem',
+ name='difficulty',
+ field=models.IntegerField(choices=[(0, 'V0'), (1, 'V1'), (2, 'V2'), (3, 'V3'), (4, 'V4'), (5, 'V5'), (6, 'V6'), (7, 'V7'), (8, 'V8'), (9, 'V9'), (10, 'V10'), (11, 'V11'), (12, 'V12'), (13, 'V13'), (14, 'V14'), (15, 'V15'), (16, 'V16'), (17, 'V17')], default=0),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='problem',
+ name='safety',
+ field=models.IntegerField(choices=[(0, 'G'), (1, 'PG'), (2, 'PG13'), (3, 'R'), (4, 'X')], default=0),
+ preserve_default=False,
+ ),
+ migrations.RunPython(forward, backward),
+ ]