short and long description
This commit is contained in:
@@ -52,6 +52,7 @@ struct ProductFields {
|
||||
name: String,
|
||||
slug: String,
|
||||
description: Option<String>,
|
||||
short_description: Option<String>,
|
||||
currency: String,
|
||||
category_id: Option<i32>,
|
||||
published: bool,
|
||||
@@ -67,6 +68,7 @@ async fn parse_product_fields(
|
||||
.ok_or_else(|| Error::BadRequest("product name is required".to_string()))?;
|
||||
let currency = form.text("currency").unwrap_or_else(|| "EUR".to_string());
|
||||
let description = form.text("description");
|
||||
let short_description = form.text("short_description");
|
||||
let category_id = form.text("category_id").and_then(|s| s.parse::<i32>().ok());
|
||||
let published = form.checked("published");
|
||||
|
||||
@@ -91,6 +93,7 @@ async fn parse_product_fields(
|
||||
name,
|
||||
slug,
|
||||
description,
|
||||
short_description,
|
||||
currency,
|
||||
category_id,
|
||||
published,
|
||||
@@ -438,6 +441,7 @@ async fn create(
|
||||
name: Set(fields.name),
|
||||
slug: Set(fields.slug),
|
||||
description: Set(fields.description),
|
||||
short_description: Set(fields.short_description),
|
||||
currency: Set(fields.currency),
|
||||
view_count: Set(0),
|
||||
published: Set(fields.published),
|
||||
@@ -552,6 +556,7 @@ async fn update(
|
||||
product.name = Set(fields.name);
|
||||
product.slug = Set(fields.slug);
|
||||
product.description = Set(fields.description);
|
||||
product.short_description = Set(fields.short_description);
|
||||
product.currency = Set(fields.currency);
|
||||
product.category_id = Set(fields.category_id);
|
||||
product.published = Set(fields.published);
|
||||
|
||||
@@ -15,6 +15,8 @@ pub struct Model {
|
||||
pub slug: String,
|
||||
#[sea_orm(column_type = "Text", nullable)]
|
||||
pub description: Option<String>,
|
||||
#[sea_orm(column_type = "Text", nullable)]
|
||||
pub short_description: Option<String>,
|
||||
pub currency: String,
|
||||
pub view_count: i32,
|
||||
pub published: bool,
|
||||
|
||||
@@ -27,6 +27,7 @@ pub fn product_card(
|
||||
"name": product.name,
|
||||
"slug": product.slug,
|
||||
"description": product.description,
|
||||
"short_description": product.short_description,
|
||||
"price": format_price(priced.price_cents),
|
||||
"on_sale": priced.is_reduced(),
|
||||
"is_business": priced.is_business,
|
||||
@@ -69,6 +70,7 @@ pub fn product_form(product: &products::Model, images: &[product_images::Model])
|
||||
"name": product.name,
|
||||
"slug": product.slug,
|
||||
"description": product.description,
|
||||
"short_description": product.short_description,
|
||||
"currency": product.currency,
|
||||
"published": product.published,
|
||||
"category_id": product.category_id,
|
||||
|
||||
Reference in New Issue
Block a user