# {{name}}
A `rustio-admin` project. Generated by `rustio startproject {{name}}`.
## Quickstart
```sh
# 1. Create the database
createdb {{name}}_dev
# 2. Configure DATABASE_URL (only needed if your local Postgres user/password differs)
cp .env.example .env
$EDITOR .env
# 3. Apply migrations and create the first administrator
cargo install --git https://github.com/abdulwahed-sweden/rustio-admin rustio-admin-cli
rustio migrate apply
rustio user create --email admin@{{name}}.local --role administrator
# 4. Boot the admin
cargo run
```
The admin lands at <http://127.0.0.1:8000/admin>. Sign in with the
account from step 3.
## Adding a model
```sh
rustio startapp comment # generates src/comment.rs +
# migrations/<NNNN>_create_comments.sql
```
The CLI prints the exact `mod` / `use` / `.model::<>()` lines to
paste into `src/main.rs`. After that, `rustio migrate apply` and
re-run; the `/admin/comments` pages light up.
For the full walkthrough see
[`docs/getting-started.md`](https://github.com/abdulwahed-sweden/rustio-admin/blob/main/docs/getting-started.md)
and the
[`ModelAdmin` reference](https://github.com/abdulwahed-sweden/rustio-admin/blob/main/docs/modeladmin.md).
## Project layout
| Path | Purpose |
|---|---|
| `src/main.rs` | Boots the admin: connects to Postgres, applies migrations, registers models, mounts `/admin/*`. |
| `src/post.rs` | Demo `Post` model with a populated `ModelAdmin` impl. Rename or delete when you stop needing the example. |
| `migrations/` | Numerically prefixed `*.sql` files. `rustio migrate apply` runs every pending one transactionally. |
| `templates/admin/*.html` (optional) | Project-side overrides of any framework template. Set `RUSTIO_TEMPLATE_DIR=templates` to enable. |
## Operator commands
```sh
rustio doctor # health check
rustio migrate status # see what's applied / pending
rustio user list # show accounts
rustio user role --email <e> administrator # promote
rustio group create --name editors # create a group
rustio perm grant-group --group editors --perm posts.add_post
```