Commit 0635ec1c authored by Florent Chehab's avatar Florent Chehab

Parametrization of the admin user creation with env variables

parent 7a48bf38
......@@ -7,6 +7,8 @@ stages:
variables:
ENV: DEV
SECRET_KEY: stupid_key_for_CI
DJANGO_ADMIN_USERNAME: admin
DJANGO_ADMIN_PASSWORD: admin
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
......
from django.contrib.auth.models import User
import os
class LoadAdminUser(object):
......@@ -13,9 +14,13 @@ class LoadAdminUser(object):
self.admin = user[0]
else:
User.objects.create_superuser(
username="admin", email="null@null.fr", password="admin"
username=os.environ["DJANGO_ADMIN_USERNAME"],
email="null@null.fr",
password=os.environ["DJANGO_ADMIN_PASSWORD"],
)
self.admin = User.objects.filter(username="admin")[0]
self.admin = User.objects.filter(
username=os.environ["DJANGO_ADMIN_USERNAME"]
)[0]
def get(self):
return self.admin
......@@ -11,6 +11,8 @@ services:
environment:
- ENV=DEV
- SECRET_KEY=please_change_me
- DJANGO_ADMIN_USERNAME=admin
- DJANGO_ADMIN_PASSWORD=admin
- DB_HOST=database
- DB_PORT=5432
- POSTGRES_DB=postgres
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment