Fix migration for mailing

This commit is contained in:
Antoine Bartuccio 2017-08-19 17:22:33 +02:00
parent 51992e1c30
commit cc8991a938

View File

@ -1342,14 +1342,11 @@ def migrate_mailings():
print("Migrating old database") print("Migrating old database")
mailing_db = cur.execute(""" cur.execute("""
SELECT * FROM mailing SELECT * FROM mailing
""") """)
mailing_sub_db = cur.execute("""
SELECT * FROM mailing_membres
""")
for mailing in mailing_db: for mailing in cur:
club = Club.objects.filter(id=mailing['id_asso_parent']) club = Club.objects.filter(id=mailing['id_asso_parent'])
if club.exists(): if club.exists():
print(mailing) print(mailing)
@ -1358,7 +1355,12 @@ def migrate_mailings():
mailing['nom'] = '.' + mailing['nom'] mailing['nom'] = '.' + mailing['nom']
Mailing(id=mailing['id_mailing'], club=club, email=str(club.unix_name + mailing['nom'] + '@utbm.fr')).save() Mailing(id=mailing['id_mailing'], club=club, email=str(club.unix_name + mailing['nom'] + '@utbm.fr')).save()
print("-------------------") print("-------------------")
for mailing_sub in mailing_sub_db:
cur.execute("""
SELECT * FROM mailing_membres
""")
for mailing_sub in cur:
mailing = Mailing.objects.filter(id=mailing_sub['id_mailing']) mailing = Mailing.objects.filter(id=mailing_sub['id_mailing'])
if mailing.exists(): if mailing.exists():
print(mailing_sub) print(mailing_sub)