forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0009_fix_address_lists.py
More file actions
41 lines (29 loc) · 1.01 KB
/
0009_fix_address_lists.py
File metadata and controls
41 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright The IETF Trust 2020, All Rights Reserved
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-21 14:27
from tqdm import tqdm
from django.db import migrations
import debug # pyflakes:ignore
def forward(apps, schema_editor):
Message = apps.get_model('message', 'Message')
for m in tqdm(Message.objects.all()):
dirty = False
for fieldname in ['to', 'cc', 'bcc', ]:
f = getattr(m, fieldname)
if f.startswith("['") or f.startswith('[]') or f.startswith("[u'"):
l = eval(f)
if isinstance(l, list):
f = ','.join(l)
setattr(m, fieldname, f)
dirty = True
if dirty:
m.save()
def reverse(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
('message', '0008_set_message_sent'),
]
operations = [
migrations.RunPython(forward, reverse),
]