2020-08-28 13:23:03 +00:00
|
|
|
# Generated by Django 3.1 on 2020-08-28 13:14
|
2020-09-02 11:05:34 +00:00
|
|
|
from django.apps.registry import Apps
|
2020-08-28 13:23:03 +00:00
|
|
|
from django.db import migrations, models
|
2020-09-02 11:05:34 +00:00
|
|
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
|
|
|
|
|
|
|
|
|
|
|
def add_title_for_defaults(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
|
|
|
|
slug_title_map = {
|
2020-09-05 23:07:06 +00:00
|
|
|
"default-authentication-flow": "Welcome to passbook!",
|
2020-09-02 11:05:34 +00:00
|
|
|
"default-invalidation-flow": "Default Invalidation Flow",
|
2020-09-05 23:07:06 +00:00
|
|
|
"default-source-enrollment": "Welcome to passbook!",
|
|
|
|
"default-source-authentication": "Welcome to passbook!",
|
2020-09-02 11:05:34 +00:00
|
|
|
"default-provider-authorization-implicit-consent": "Default Provider Authorization Flow (implicit consent)",
|
|
|
|
"default-provider-authorization-explicit-consent": "Default Provider Authorization Flow (explicit consent)",
|
2020-09-05 23:07:06 +00:00
|
|
|
"default-password-change": "Change password",
|
2020-09-02 11:05:34 +00:00
|
|
|
}
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
Flow = apps.get_model("passbook_flows", "Flow")
|
|
|
|
for flow in Flow.objects.using(db_alias).all():
|
|
|
|
if flow.slug in slug_title_map:
|
|
|
|
flow.title = slug_title_map[flow.slug]
|
|
|
|
else:
|
|
|
|
flow.title = flow.name
|
|
|
|
flow.save()
|
2020-08-28 13:23:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
("passbook_flows", "0010_provider_flows"),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AlterModelOptions(
|
|
|
|
name="flow",
|
|
|
|
options={
|
|
|
|
"permissions": [("export_flow", "Can export a Flow")],
|
|
|
|
"verbose_name": "Flow",
|
|
|
|
"verbose_name_plural": "Flows",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
migrations.AddField(
|
|
|
|
model_name="flow",
|
|
|
|
name="title",
|
|
|
|
field=models.TextField(default="", blank=True),
|
|
|
|
preserve_default=False,
|
|
|
|
),
|
2020-09-02 11:05:34 +00:00
|
|
|
migrations.RunPython(add_title_for_defaults),
|
|
|
|
migrations.AlterField(
|
|
|
|
model_name="flow", name="title", field=models.TextField(),
|
|
|
|
),
|
2020-08-28 13:23:03 +00:00
|
|
|
]
|