# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-11 17:28
from __future__ import unicode_literals

from django.db import migrations


def forwards_func(apps, schema_editor):
    User = apps.get_model('auth', 'User')

    old_password_patterns = (
        'sha1$',
        # RTD's production database doesn't have any of these
        # but they are included for completeness
        'md5$',
        'crypt$',
    )
    for pattern in old_password_patterns:
        users = User.objects.filter(password__startswith=pattern)
        for user in users:
            user.set_unusable_password()
            user.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0004_ad-opt-out'),
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.RunPython(forwards_func),
    ]

@@ -141,16 +141,70 @@
 rations%0A
+from django.contrib.auth.hashers import make_password%0A
 %0A%0Adef fo
@@ -634,19 +634,22 @@
 ser.
-set_unusabl
+password = mak
 e_pa
@@ -655,16 +655,20 @@
 assword(
+None
 )%0A      

Migrate old passwords without "set_unusable_password"