add: product uploads
This commit is contained in:
parent
292d302304
commit
3b5b0ce1a1
8 changed files with 27 additions and 7 deletions
|
@ -227,7 +227,7 @@
|
||||||
("hook" "long")
|
("hook" "long")
|
||||||
(text "{{ post.title }}"))
|
(text "{{ post.title }}"))
|
||||||
|
|
||||||
(button ("class" "small lowered") (icon (text "ellipsis"))))
|
(button ("title" "View post content") ("class" "small lowered") (icon (text "ellipsis"))))
|
||||||
(text "{% else %}")
|
(text "{% else %}")
|
||||||
(text "{% if not post.context.content_warning -%}")
|
(text "{% if not post.context.content_warning -%}")
|
||||||
(span
|
(span
|
||||||
|
@ -327,6 +327,7 @@
|
||||||
("class" "camo small")
|
("class" "camo small")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -922,6 +923,7 @@
|
||||||
("class" "camo small")
|
("class" "camo small")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -1035,6 +1037,7 @@
|
||||||
("class" "camo small")
|
("class" "camo small")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -1273,6 +1276,7 @@
|
||||||
("class" "camo small square")
|
("class" "camo small square")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -1494,6 +1498,7 @@
|
||||||
("title" "More options")
|
("title" "More options")
|
||||||
("onclick" "document.getElementById('post_options_dialog').showModal()")
|
("onclick" "document.getElementById('post_options_dialog').showModal()")
|
||||||
("type" "button")
|
("type" "button")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
|
|
||||||
(label
|
(label
|
||||||
|
@ -2085,6 +2090,7 @@
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
("style" "width: 32px")
|
("style" "width: 32px")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -2111,6 +2117,7 @@
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
("style" "width: 32px")
|
("style" "width: 32px")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -2202,6 +2209,7 @@
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
("style" "width: 32px")
|
("style" "width: 32px")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
@ -2281,6 +2289,7 @@
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
("style" "width: 32px")
|
("style" "width: 32px")
|
||||||
|
("title" "More options")
|
||||||
(text "{{ icon \"ellipsis\" }}"))
|
(text "{{ icon \"ellipsis\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "inner")
|
("class" "inner")
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
("style" "gap: var(--pad-1) !important")
|
("style" "gap: var(--pad-1) !important")
|
||||||
|
("title" "Account options")
|
||||||
(text "{{ components::avatar(username=user.username, size=\"24px\") }}")
|
(text "{{ components::avatar(username=user.username, size=\"24px\") }}")
|
||||||
(icon_class (text "chevron-down") (text "dropdown_arrow")))
|
(icon_class (text "chevron-down") (text "dropdown_arrow")))
|
||||||
|
|
||||||
|
|
|
@ -1493,7 +1493,7 @@
|
||||||
globalThis.apply_preset = async (preset) => {
|
globalThis.apply_preset = async (preset) => {
|
||||||
if (
|
if (
|
||||||
!(await trigger(\"atto::confirm\", [
|
!(await trigger(\"atto::confirm\", [
|
||||||
\"Are you sure you would like to do this? This will change all listed settings to the listed value.\",
|
\"Are you sure you would like to do this? This will change all listed settings to their listed values.\",
|
||||||
]))
|
]))
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -303,7 +303,7 @@ pub async fn stripe_webhook(
|
||||||
if let Err(e) = data
|
if let Err(e) = data
|
||||||
.create_notification(Notification::new(
|
.create_notification(Notification::new(
|
||||||
"It seems your recent payment has failed :(".to_string(),
|
"It seems your recent payment has failed :(".to_string(),
|
||||||
"No worries! Your subscription is still active and will be retried. Your supporter status will resume when you have a successful payment."
|
"No worries! Your subscription is still active and will be retried. Your supporter status will resume when you have a successful payment.\n\nIf you've cancelled your subscription, you can safely disregard this."
|
||||||
.to_string(),
|
.to_string(),
|
||||||
user.id,
|
user.id,
|
||||||
))
|
))
|
||||||
|
|
|
@ -7,5 +7,6 @@ CREATE TABLE IF NOT EXISTS products (
|
||||||
likes INT NOT NULL,
|
likes INT NOT NULL,
|
||||||
dislikes INT NOT NULL,
|
dislikes INT NOT NULL,
|
||||||
product_type TEXT NOT NULL,
|
product_type TEXT NOT NULL,
|
||||||
price TEXT NOT NULL
|
price TEXT NOT NULL,
|
||||||
|
uploads TEXT NOT NULL
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,8 @@ impl DataManager {
|
||||||
likes: get!(x->5(i32)) as isize,
|
likes: get!(x->5(i32)) as isize,
|
||||||
dislikes: get!(x->6(i32)) as isize,
|
dislikes: get!(x->6(i32)) as isize,
|
||||||
product_type: serde_json::from_str(&get!(x->7(String))).unwrap(),
|
product_type: serde_json::from_str(&get!(x->7(String))).unwrap(),
|
||||||
price: serde_json::from_str(&get!(x->9(String))).unwrap(),
|
price: serde_json::from_str(&get!(x->8(String))).unwrap(),
|
||||||
|
uploads: serde_json::from_str(&get!(x->9(String))).unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ impl DataManager {
|
||||||
|
|
||||||
let res = execute!(
|
let res = execute!(
|
||||||
&conn,
|
&conn,
|
||||||
"INSERT INTO products VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
"INSERT INTO products VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||||
params![
|
params![
|
||||||
&(data.id as i64),
|
&(data.id as i64),
|
||||||
&(data.created as i64),
|
&(data.created as i64),
|
||||||
|
@ -95,6 +96,7 @@ impl DataManager {
|
||||||
&0_i32,
|
&0_i32,
|
||||||
&serde_json::to_string(&data.product_type).unwrap(),
|
&serde_json::to_string(&data.product_type).unwrap(),
|
||||||
&serde_json::to_string(&data.price).unwrap(),
|
&serde_json::to_string(&data.price).unwrap(),
|
||||||
|
&serde_json::to_string(&data.uploads).unwrap(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,11 @@ impl DataManager {
|
||||||
question: &Question,
|
question: &Question,
|
||||||
) -> Result<Option<(User, Post)>> {
|
) -> Result<Option<(User, Post)>> {
|
||||||
Ok(if let Some(id) = question.context.asking_about {
|
Ok(if let Some(id) = question.context.asking_about {
|
||||||
let post = self.get_post_by_id(id).await?;
|
let post = match self.get_post_by_id(id).await {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => return Ok(None),
|
||||||
|
};
|
||||||
|
|
||||||
Some((self.get_user_by_id(post.owner).await?, post))
|
Some((self.get_user_by_id(post.owner).await?, post))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -14,6 +14,8 @@ pub struct Product {
|
||||||
pub dislikes: isize,
|
pub dislikes: isize,
|
||||||
pub product_type: ProductType,
|
pub product_type: ProductType,
|
||||||
pub price: ProductPrice,
|
pub price: ProductPrice,
|
||||||
|
/// Optional uploads to accompany the product title and description. Maximum of 4.
|
||||||
|
pub uploads: Vec<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -80,6 +82,7 @@ impl Product {
|
||||||
dislikes: 0,
|
dislikes: 0,
|
||||||
product_type: r#type,
|
product_type: r#type,
|
||||||
price,
|
price,
|
||||||
|
uploads: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue