Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Rex Dri
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julien Jerphanion
Rex Dri
Commits
0635ec1c
Commit
0635ec1c
authored
Feb 11, 2019
by
Florent Chehab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parametrization of the admin user creation with env variables
parent
7a48bf38
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
.gitlab-ci.yml
.gitlab-ci.yml
+2
-0
backend/backend_app/load_data/loading_scripts/loadAdminUser.py
...nd/backend_app/load_data/loading_scripts/loadAdminUser.py
+7
-2
docker-compose.yml
docker-compose.yml
+2
-0
No files found.
.gitlab-ci.yml
View file @
0635ec1c
...
@@ -7,6 +7,8 @@ stages:
...
@@ -7,6 +7,8 @@ stages:
variables
:
variables
:
ENV
:
DEV
ENV
:
DEV
SECRET_KEY
:
stupid_key_for_CI
SECRET_KEY
:
stupid_key_for_CI
DJANGO_ADMIN_USERNAME
:
admin
DJANGO_ADMIN_PASSWORD
:
admin
POSTGRES_DB
:
postgres
POSTGRES_DB
:
postgres
POSTGRES_USER
:
postgres
POSTGRES_USER
:
postgres
POSTGRES_PASSWORD
:
postgres
POSTGRES_PASSWORD
:
postgres
...
...
backend/backend_app/load_data/loading_scripts/loadAdminUser.py
View file @
0635ec1c
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
import
os
class
LoadAdminUser
(
object
):
class
LoadAdminUser
(
object
):
...
@@ -13,9 +14,13 @@ class LoadAdminUser(object):
...
@@ -13,9 +14,13 @@ class LoadAdminUser(object):
self
.
admin
=
user
[
0
]
self
.
admin
=
user
[
0
]
else
:
else
:
User
.
objects
.
create_superuser
(
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
):
def
get
(
self
):
return
self
.
admin
return
self
.
admin
docker-compose.yml
View file @
0635ec1c
...
@@ -11,6 +11,8 @@ services:
...
@@ -11,6 +11,8 @@ services:
environment
:
environment
:
-
ENV=DEV
-
ENV=DEV
-
SECRET_KEY=please_change_me
-
SECRET_KEY=please_change_me
-
DJANGO_ADMIN_USERNAME=admin
-
DJANGO_ADMIN_PASSWORD=admin
-
DB_HOST=database
-
DB_HOST=database
-
DB_PORT=5432
-
DB_PORT=5432
-
POSTGRES_DB=postgres
-
POSTGRES_DB=postgres
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment