You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
594 B

  1. # Generated by Django 2.1.3 on 2018-11-20 20:04
  2. import json
  3. from django.db import migrations
  4. def combine_channel_names(apps, schema_editor):
  5. Channel = apps.get_model('api', 'Channel')
  6. for channel in Channel.objects.filter(kind="sms"):
  7. if channel.value.startswith("{"):
  8. doc = json.loads(channel.value)
  9. channel.name = doc.get("label", "")
  10. channel.save()
  11. class Migration(migrations.Migration):
  12. dependencies = [
  13. ('api', '0043_channel_name'),
  14. ]
  15. operations = [
  16. migrations.RunPython(combine_channel_names),
  17. ]