rustio-admin-cli 0.30.0

Command-line tools for rustio-admin: project scaffolding, migrations, user management.
//! Demo `Comment` model — paired with `Post` via a `post_id`
//! foreign key. Together they show off relation-driven filters,
//! cross-model list links, and the framework's audit-on-mutation
//! pipeline for two related tables.

use rustio_admin::{DateTime, ModelAdmin, RustioAdmin, Utc};

// `#[derive(RustioAdmin)]` generates both the admin metadata and the
// `impl Model` ORM glue from these fields; `#[rustio(table = "…")]`
// pins the SQL table name.
#[derive(RustioAdmin)]
#[rustio(table = "comments")]
pub struct Comment {
    pub id: i64,
    pub post_id: i64,
    pub author_name: String,
    pub body: String,
    pub approved: bool,
    pub created_at: DateTime<Utc>,
}

impl ModelAdmin for Comment {
    fn list_display() -> &'static [&'static str] {
        &["author_name", "post_id", "approved", "created_at"]
    }
    fn list_filter() -> &'static [&'static str] {
        &["approved"]
    }
    fn search_fields() -> &'static [&'static str] {
        &["author_name", "body"]
    }
    fn ordering() -> &'static [&'static str] {
        &["-created_at"]
    }
}