From fda61b52aad939229fae502f4831422325fb653d Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Mon, 19 Oct 2015 15:58:02 -0400 Subject: [PATCH] Reserve ecommerce worker username Django's user model allows email addresses to be blank. However, edx-platform includes a migration requiring that email addresses be unique. Someone in our production environment already had a blank email address, so this migration was failing earlier. --- .../0001_add_ecommerce_service_user.py | 26 +++++++++++++++++++ .../commerce/migrations/__init__.py | 0 lms/envs/common.py | 1 + 3 files changed, 27 insertions(+) create mode 100644 lms/djangoapps/commerce/migrations/0001_add_ecommerce_service_user.py create mode 100644 lms/djangoapps/commerce/migrations/__init__.py diff --git a/lms/djangoapps/commerce/migrations/0001_add_ecommerce_service_user.py b/lms/djangoapps/commerce/migrations/0001_add_ecommerce_service_user.py new file mode 100644 index 0000000000..2c96467493 --- /dev/null +++ b/lms/djangoapps/commerce/migrations/0001_add_ecommerce_service_user.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from django.conf import settings +from django.contrib.auth.models import User +from django.db import models +from south.db import db +from south.utils import datetime_utils as datetime +from south.v2 import DataMigration + + +class Migration(DataMigration): + username = settings.ECOMMERCE_SERVICE_WORKER_USERNAME + email = username + '@fake.email' + + def forwards(self, orm): + """Add the service user.""" + user = User.objects.create(username=self.username, email=self.email) + user.set_unusable_password() + user.save() + + def backwards(self, orm): + """Remove the service user.""" + User.objects.get(username=self.username, email=self.email).delete() + + models = {} + complete_apps = ['commerce'] + symmetrical = True diff --git a/lms/djangoapps/commerce/migrations/__init__.py b/lms/djangoapps/commerce/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/envs/common.py b/lms/envs/common.py index 0ec36066f4..7cf5392f76 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2578,6 +2578,7 @@ ECOMMERCE_PUBLIC_URL_ROOT = None ECOMMERCE_API_URL = None ECOMMERCE_API_SIGNING_KEY = None ECOMMERCE_API_TIMEOUT = 5 +ECOMMERCE_SERVICE_WORKER_USERNAME = 'ecommerce_worker' # Reverification checkpoint name pattern CHECKPOINT_PATTERN = r'(?P[^/]+)'