Add credentials service user
This commit is contained in:
@@ -132,6 +132,7 @@ DATABASES = {
|
||||
# This hack disables migrations during tests. We want to create tables directly from the models for speed.
|
||||
# See https://groups.google.com/d/msg/django-developers/PWPj3etj3-U/kCl6pMsQYYoJ.
|
||||
MIGRATION_MODULES = {app: "app.migrations_not_used_in_tests" for app in INSTALLED_APPS}
|
||||
MIGRATION_MODULES["credentials"] = "app.migrations_not_used_in_tests"
|
||||
|
||||
LMS_BASE = "localhost:8000"
|
||||
FEATURES['PREVIEW_LMS_BASE'] = "preview"
|
||||
|
||||
@@ -2553,6 +2553,9 @@ ECOMMERCE_API_SIGNING_KEY = None
|
||||
ECOMMERCE_API_TIMEOUT = 5
|
||||
ECOMMERCE_SERVICE_WORKER_USERNAME = 'ecommerce_worker'
|
||||
|
||||
# Credentials configuration
|
||||
CREDENTIALS_SERVICE_USERNAME = 'credentials_service_user'
|
||||
|
||||
# Reverification checkpoint name pattern
|
||||
CHECKPOINT_PATTERN = r'(?P<checkpoint_name>[^/]+)'
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ DATABASES = {
|
||||
# This hack disables migrations during tests. We want to create tables directly from the models for speed.
|
||||
# See https://groups.google.com/d/msg/django-developers/PWPj3etj3-U/kCl6pMsQYYoJ.
|
||||
MIGRATION_MODULES = {app: "app.migrations_not_used_in_tests" for app in INSTALLED_APPS}
|
||||
MIGRATION_MODULES["credentials"] = "app.migrations_not_used_in_tests"
|
||||
|
||||
CACHES = {
|
||||
# This is the cache used for most things.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
def add_service_user(apps, schema_editor):
|
||||
"""Add service user."""
|
||||
user, created = User.objects.get_or_create(username=settings.CREDENTIALS_SERVICE_USERNAME, is_staff=True)
|
||||
if created:
|
||||
user.set_unusable_password()
|
||||
user.save()
|
||||
|
||||
|
||||
def remove_service_user(apps, schema_editor):
|
||||
"""Remove service user."""
|
||||
try:
|
||||
User.objects.get(username=settings.CREDENTIALS_SERVICE_USERNAME).delete()
|
||||
except User.DoesNotExist:
|
||||
return
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('credentials', '0002_credentialsapiconfig_cache_ttl'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_service_user, remove_service_user),
|
||||
]
|
||||
Reference in New Issue
Block a user