Automatically create PasswordFactor on initial setup closes #16

This commit is contained in:
Jens Langhammer 2019-02-26 09:54:51 +01:00
parent 28da67abe6
commit ff9bc8aa70
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# Generated by Django 2.1.7 on 2019-02-26 08:50
from django.db import migrations
def create_initial_factor(apps, schema_editor):
"""Create initial PasswordFactor if none exists"""
PasswordFactor = apps.get_model("passbook_core", "PasswordFactor")
if not PasswordFactor.objects.exists():
PasswordFactor.objects.create(
name='password',
slug='password',
order=0,
backends=[]
)
class Migration(migrations.Migration):
dependencies = [
('passbook_core', '0013_invitation_needs_confirmation'),
]
operations = [
migrations.RunPython(create_initial_factor)
]