Created
June 22, 2017 18:18
-
-
Save BenjiLee/e25b5b5aa4c319e7178accdf5d123503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.conf import settings | |
from django.contrib.auth import get_user_model | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
def add_service_user(apps, schema_editor): | |
User = apps.get_model('core', 'User') | |
service_user = User.objects.create( | |
username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, | |
is_superuser=True | |
) | |
service_user.set_unusable_password() | |
service_user.save() | |
def remove_service_user(apps, schema_editor): | |
User = apps.get_model('core', 'User') | |
User.objects.get(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME).delete() | |
dependencies = [ | |
('core', '0005_auto_20150924_0123'), | |
] | |
operations = [ | |
migrations.RunPython(add_service_user, remove_service_user) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment