add migration that overhauls report flow settings

This commit is contained in:
Laura Klünder 2024-03-24 15:24:36 +01:00
parent 868317dabf
commit 482da3b244
5 changed files with 74 additions and 7 deletions

View file

@ -0,0 +1,55 @@
# Generated by Django 5.0.1 on 2024-03-24 14:03
import c3nav.mapdata.fields
from django.db import migrations, models
def forwards_func(apps, schema_editor):
LocationGroup = apps.get_model('mapdata', 'LocationGroup')
LocationGroup.objects.filter(can_report_missing_old=True).update(can_report_missing="single")
def backwards_func(apps, schema_editor):
LocationGroup = apps.get_model('mapdata', 'LocationGroup')
LocationGroup.objects.exclude(can_report_missing__in=("single", "multiple")).update(can_report_missing_old=True)
class Migration(migrations.Migration):
dependencies = [
('mapdata', '0102_rename_bssid_rangingbeacon_wifi_bssid_and_more'),
]
operations = [
migrations.RenameField(
model_name='locationgroup',
old_name='can_report_missing',
new_name='can_report_missing_old',
),
migrations.AddField(
model_name='locationgroup',
name='description',
field=c3nav.mapdata.fields.I18nField(blank=True, fallback_any=True, help_text='to aid with selection in the report form', plural_name='descriptions', verbose_name='description'),
),
migrations.AddField(
model_name='locationgroup',
name='can_report_missing',
field=models.CharField(choices=[('dont_offer', "don't offer"), ('reject', 'offer in first step, then reject'), ('single', 'offer in first step, exclusive choice'), ('multiple', 'offer if nothing in the first step matches, multiple choice')], default='dont_offer', max_length=16, verbose_name='report missing location'),
),
migrations.AddField(
model_name='locationgroup',
name='report_help_text',
field=c3nav.mapdata.fields.I18nField(blank=True, fallback_any=True, help_text='to explain the report form or rejection', plural_name='report_help_texts', verbose_name='report help text'),
),
migrations.RunPython(forwards_func, backwards_func),
migrations.RemoveField(
model_name='locationgroup',
name='can_report_missing_old',
),
migrations.AlterField(
model_name='report',
name='created_groups',
field=models.ManyToManyField(blank=True, help_text='select all groups that apply, if any', related_name='+',
to='mapdata.locationgroup', verbose_name='location groups'),
),
]