//! Demo `Post` model. Rename or delete when you no longer need it.
//!
//! - `#[derive(RustioAdmin)]` produces the `AdminModel` impl that
//! drives every list / form / cell rendering, AND the `impl Model`
//! ORM contract (table, columns, row decoder, insert binder) — both
//! from the struct fields, so there is nothing to keep in sync by
//! hand. `#[rustio(table = "…")]` pins the SQL table name.
//! - `impl ModelAdmin for Post { … }` opts into Django-style
//! customisation. Override only the methods you care about; the
//! rest inherit framework defaults.
use rustio_admin::{DateTime, ModelAdmin, RustioAdmin, Utc};
#[derive(RustioAdmin)]
#[rustio(table = "posts")]
pub struct Post {
pub id: i64,
pub title: String,
pub body: String,
pub published: bool,
pub created_at: DateTime<Utc>,
}
impl ModelAdmin for Post {
fn list_display() -> &'static [&'static str] {
&["title", "published", "created_at"]
}
fn list_filter() -> &'static [&'static str] {
&["published"]
}
fn search_fields() -> &'static [&'static str] {
&["title", "body"]
}
fn ordering() -> &'static [&'static str] {
&["-created_at"]
}
}