Skip to content

Commit

Permalink
Start wiring up a detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
richo committed Dec 27, 2019
1 parent 0e7e5e9 commit c135c2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/web/mod.rs
Expand Up @@ -105,6 +105,7 @@ pub fn configure_rocket() -> Rocket {
routes::rigging::index,
routes::rigging::customers,
routes::rigging::customer_create,
routes::rigging::customer_detail,
routes::rigging::equipment,
routes::rigging::equipment_create,
routes::rigging::service_bulletins,
Expand Down
13 changes: 13 additions & 0 deletions src/web/routes/rigging.rs
Expand Up @@ -31,6 +31,19 @@ pub fn customers(user: WebUser, conn: DbConn, flash: Option<FlashMessage<'_, '_>
Template::render("rigging/customers", context)
}

#[get("/customer/<id>")]
pub fn customer_detail(user: WebUser, conn: DbConn, id: i32, flash: Option<FlashMessage<'_, '_>>) -> Template {
let customer = user.user.customer_by_id(&*conn, id).expect("Couldn't load customers");

let view_data = CustomerView {
customers: vec![customer],
};
let context = Context::rigging(view_data)
.set_user(Some(user))
.flash(flash.map(|ref msg| (msg.name().into(), msg.msg().into())));
Template::render("rigging/customers", context)
}

#[derive(FromForm, Debug, Serialize)]
pub struct NewCustomerForm {
pub name: String,
Expand Down

0 comments on commit c135c2d

Please sign in to comment.