Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
8ff87029
Verified
Commit
8ff87029
authored
10 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: add initialize & loadfixtures management commands
parent
e7496867
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/management/commands/initialize.py
+62
-0
62 additions, 0 deletions
program/management/commands/initialize.py
program/management/commands/loadfixtures.py
+17
-0
17 additions, 0 deletions
program/management/commands/loadfixtures.py
with
79 additions
and
0 deletions
program/management/commands/initialize.py
0 → 100644
+
62
−
0
View file @
8ff87029
import
os
from
django.core.management
import
call_command
from
django.core.management.base
import
BaseCommand
,
CommandError
class
Command
(
BaseCommand
):
help
=
"
Initializes the application.
"
def
handle
(
self
,
*
args
,
**
options
):
AURA_PROTO
=
os
.
getenv
(
"
AURA_PROTO
"
)
AURA_HOST
=
os
.
getenv
(
"
AURA_HOST
"
)
TANK_CALLBACK_BASE_URL
=
os
.
getenv
(
"
TANK_CALLBACK_BASE_URL
"
,
default
=
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
/tank
"
,
)
DASHBOARD_CALLBACK_BASE_URL
=
os
.
getenv
(
"
DASHBOARD_CALLBACK_BASE_URL
"
,
default
=
f
"
{
AURA_PROTO
}
://$
{
AURA_HOST
}
"
,
)
call_command
(
"
migrate
"
,
"
--no-input
"
)
try
:
call_command
(
"
createsuperuser
"
,
"
--no-input
"
)
except
CommandError
:
raise
CommandError
(
f
"
The application is already initialized.
"
)
call_command
(
"
collectstatic
"
,
"
--no-input
"
)
call_command
(
"
create_oidc_client
"
,
"
dashboard
"
,
"
public
"
,
"
--client-id
"
,
os
.
getenv
(
"
DASHBOARD_OIDC_CLIENT_ID
"
),
"
--client-secret
"
,
os
.
getenv
(
"
DASHBOARD_OIDC_CLIENT_SECRET
"
),
"
-r
"
,
"
id_token token
"
,
"
-u
"
,
f
"
{
DASHBOARD_CALLBACK_BASE_URL
}
/oidc_callback.html
"
,
"
-u
"
,
f
"
{
DASHBOARD_CALLBACK_BASE_URL
}
/oidc_callback_silentRenew.html
"
,
"
-p
"
,
DASHBOARD_CALLBACK_BASE_URL
,
)
call_command
(
"
create_oidc_client
"
,
"
tank
"
,
"
confidential
"
,
"
--client-id
"
,
os
.
getenv
(
"
TANK_OIDC_CLIENT_ID
"
),
"
--client-secret
"
,
os
.
getenv
(
"
TANK_OIDC_CLIENT_SECRET
"
),
"
-r
"
,
"
code
"
,
"
-u
"
,
f
"
{
TANK_CALLBACK_BASE_URL
}
/tank/auth/oidc/callback
"
,
)
call_command
(
"
addpermissions
"
)
call_command
(
"
creatersakey
"
)
This diff is collapsed.
Click to expand it.
program/management/commands/loadfixtures.py
0 → 100644
+
17
−
0
View file @
8ff87029
import
glob
from
django.core.management
import
BaseCommand
,
call_command
class
Command
(
BaseCommand
):
help
=
"
Loads the fixtures from the directory.
"
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
"
directory
"
,
help
=
"
Directory with fixtures.
"
,
nargs
=
"
+
"
,
type
=
str
)
def
handle
(
self
,
*
args
,
**
options
):
directories
=
options
[
"
directory
"
]
for
directory
in
directories
:
if
files
:
=
glob
.
glob
(
f
"
fixtures/
{
directory
}
/*.json
"
):
call_command
(
"
loaddata
"
,
files
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment