# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2018-08-03 08:45


from django.db import migrations

import re, sys

def remove_passwd_from_logs(apps, schema_editor):
    Log = apps.get_model('main', 'Log')
    r = re.compile(r'password: \w*')
    count = 0
    for l in Log.objects.filter(action='sent email password'):
        l.dump = re.sub(r, 'password: *****', l.dump)
        l.save()
        count += 1
    if count:
        sys.stdout.write(' --- {} log entries successfully cleaned\n'.format(count))

class Migration(migrations.Migration):

    dependencies = [
        ('main', '0020_auto_20170530_1020'),
    ]

    operations = [
        migrations.RunPython(remove_passwd_from_logs),
    ]
