Skip to content

Commit

Permalink
🚧 (dashboard) add superuser creation commands
Browse files Browse the repository at this point in the history
- Renamed `create-superuser` to `create-api-superuser` for clarity. Added `create-dashboard-superuser` target to handle Dashboard superuser creation. Add DJANGO_SUPERUSER_PASSWORD to env.d/dashboard
- Fix migrate-dashboard-db in Makefile
- Fix typo in readme.md
  • Loading branch information
ssorin committed Oct 31, 2024
1 parent e283c26 commit 3870b5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bootstrap: \
create-dashboard-db \
seed-metabase \
seed-oidc \
create-superuser \
create-api-superuser \
jupytext--to-ipynb \
seed-api
.PHONY: bootstrap
Expand Down Expand Up @@ -226,14 +226,13 @@ migrate-api: ## run alembic database migrations for the api service
.PHONY: migrate-api

migrate-dashboard-db: ## create dashboard database
@echo "Creating dashboard service database…"
@echo "Running dashboard service database engine"
@$(COMPOSE_UP) --wait postgresql
@echo "Creating dashboard service database…"
@$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "create database \"$${DASHBOARD_DB_NAME}\";"' || echo "Duly noted, skipping database creation."
@echo "Migrating dashboard database…"#
@bin/manage migrate
.PHONY: migrate-dashboard-db

create-superuser: ## create super user
create-api-superuser: ## create super user
@echo "Creating super user…"
@$(COMPOSE_RUN_API_PIPENV) python -m qualicharge create-user \
admin \
Expand All @@ -243,7 +242,17 @@ create-superuser: ## create super user
--is-superuser \
--is-staff \
--force
.PHONY: create-superuser
.PHONY: create-api-superuser

create-dashboard-superuser: ## create dashboard super user
@echo "Running dashboard service database engine…"
@$(COMPOSE_UP) --wait postgresql
@echo "Creating dashboard super user…"
@bin/manage createsuperuser \
--noinput \
--username admin \
--email [email protected]
.PHONY: create-dashboard-superuser

jupytext--to-md: ## convert local ipynb files into md
bin/jupytext --to md work/src/notebook/**/*.ipynb
Expand All @@ -257,7 +266,7 @@ reset-db: ## Reset the PostgreSQL database
$(COMPOSE) stop
$(COMPOSE) down postgresql metabase
$(MAKE) migrate-api
$(MAKE) create-superuser
$(MAKE) create-api-superuser
$(MAKE) create-api-test-db
$(MAKE) create-metabase-db
$(MAKE) seed-metabase
Expand Down
1 change: 1 addition & 0 deletions env.d/dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ DASHBOARD_DB_PORT=5432
DASHBOARD_DB_USER=qualicharge
DASHBOARD_DEBUG=1
DASHBOARD_SECRET_KEY=the_secret_key
DJANGO_SUPERUSER_PASSWORD=admin
2 changes: 1 addition & 1 deletion src/dashboard/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The dashboard allows operators to manage all of their data related to qualicharg
The qualicharge dashboard is available from the url:
[http://localhost:8030](http://localhost:8030).

## Shortuct to use Django manage.py script
## Shortcut to use Django manage.py script

```
./bin/manage <your_command>
Expand Down

0 comments on commit 3870b5a

Please sign in to comment.