This commit is contained in:
2023-08-29 21:34:01 +02:00
parent 5eee5309ad
commit ce17b74cbf
3 changed files with 10 additions and 12 deletions

View File

@@ -64,9 +64,9 @@ impl fmt::Display for UriPath {
} }
} }
impl<'a> Into<&'a str> for &'a UriPath { impl<'a> From<&'a UriPath> for &'a str {
fn into(self) -> &'a str { fn from(val: &'a UriPath) -> Self {
self.0.as_str() val.0.as_str()
} }
} }

View File

@@ -29,7 +29,7 @@ impl Inventory {
.collect::<Result<Vec<Category>, Error>>()?; .collect::<Result<Vec<Category>, Error>>()?;
for category in &mut categories { for category in &mut categories {
category.populate_items(&ctx, &pool).await?; category.populate_items(ctx, pool).await?;
} }
Ok(Self { categories }) Ok(Self { categories })

View File

@@ -450,13 +450,11 @@ pub async fn trip_edit_attribute(
Form(trip_update): Form<TripUpdate>, Form(trip_update): Form<TripUpdate>,
) -> Result<Redirect, Error> { ) -> Result<Redirect, Error> {
let ctx = Context::build(current_user); let ctx = Context::build(current_user);
if attribute == models::trips::TripAttribute::Name { if attribute == models::trips::TripAttribute::Name && trip_update.new_value.is_empty() {
if trip_update.new_value.is_empty() {
return Err(Error::Request(RequestError::EmptyFormElement { return Err(Error::Request(RequestError::EmptyFormElement {
name: "name".to_string(), name: "name".to_string(),
})); }));
} }
}
models::trips::Trip::set_attribute( models::trips::Trip::set_attribute(
&ctx, &ctx,
&state.database_pool, &state.database_pool,
@@ -477,7 +475,7 @@ pub async fn trip_item_set_state(
key: models::trips::TripItemStateKey, key: models::trips::TripItemStateKey,
value: bool, value: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
models::trips::TripItem::set_state(&ctx, &state.database_pool, trip_id, item_id, key, value) models::trips::TripItem::set_state(ctx, &state.database_pool, trip_id, item_id, key, value)
.await?; .await?;
Ok(()) Ok(())
} }
@@ -500,7 +498,7 @@ pub async fn trip_row(
trip_id, trip_id,
&item, &item,
models::inventory::InventoryItem::get_category_max_weight( models::inventory::InventoryItem::get_category_max_weight(
&ctx, ctx,
&state.database_pool, &state.database_pool,
item.item.category_id, item.item.category_id,
) )