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")
|
||||
(text "{{ post.title }}"))
|
||||
|
||||
(button ("class" "small lowered") (icon (text "ellipsis"))))
|
||||
(button ("title" "View post content") ("class" "small lowered") (icon (text "ellipsis"))))
|
||||
(text "{% else %}")
|
||||
(text "{% if not post.context.content_warning -%}")
|
||||
(span
|
||||
|
@ -327,6 +327,7 @@
|
|||
("class" "camo small")
|
||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -922,6 +923,7 @@
|
|||
("class" "camo small")
|
||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -1035,6 +1037,7 @@
|
|||
("class" "camo small")
|
||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -1273,6 +1276,7 @@
|
|||
("class" "camo small square")
|
||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -1494,6 +1498,7 @@
|
|||
("title" "More options")
|
||||
("onclick" "document.getElementById('post_options_dialog').showModal()")
|
||||
("type" "button")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
|
||||
(label
|
||||
|
@ -2085,6 +2090,7 @@
|
|||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("style" "width: 32px")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -2111,6 +2117,7 @@
|
|||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("style" "width: 32px")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -2202,6 +2209,7 @@
|
|||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("style" "width: 32px")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
@ -2281,6 +2289,7 @@
|
|||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("style" "width: 32px")
|
||||
("title" "More options")
|
||||
(text "{{ icon \"ellipsis\" }}"))
|
||||
(div
|
||||
("class" "inner")
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||
("exclude" "dropdown")
|
||||
("style" "gap: var(--pad-1) !important")
|
||||
("title" "Account options")
|
||||
(text "{{ components::avatar(username=user.username, size=\"24px\") }}")
|
||||
(icon_class (text "chevron-down") (text "dropdown_arrow")))
|
||||
|
||||
|
|
|
@ -1493,7 +1493,7 @@
|
|||
globalThis.apply_preset = async (preset) => {
|
||||
if (
|
||||
!(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;
|
||||
|
|
|
@ -303,7 +303,7 @@ pub async fn stripe_webhook(
|
|||
if let Err(e) = data
|
||||
.create_notification(Notification::new(
|
||||
"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(),
|
||||
user.id,
|
||||
))
|
||||
|
|
|
@ -7,5 +7,6 @@ CREATE TABLE IF NOT EXISTS products (
|
|||
likes INT NOT NULL,
|
||||
dislikes INT 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,
|
||||
dislikes: get!(x->6(i32)) as isize,
|
||||
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!(
|
||||
&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![
|
||||
&(data.id as i64),
|
||||
&(data.created as i64),
|
||||
|
@ -95,6 +96,7 @@ impl DataManager {
|
|||
&0_i32,
|
||||
&serde_json::to_string(&data.product_type).unwrap(),
|
||||
&serde_json::to_string(&data.price).unwrap(),
|
||||
&serde_json::to_string(&data.uploads).unwrap(),
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -45,7 +45,11 @@ impl DataManager {
|
|||
question: &Question,
|
||||
) -> Result<Option<(User, Post)>> {
|
||||
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))
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -14,6 +14,8 @@ pub struct Product {
|
|||
pub dislikes: isize,
|
||||
pub product_type: ProductType,
|
||||
pub price: ProductPrice,
|
||||
/// Optional uploads to accompany the product title and description. Maximum of 4.
|
||||
pub uploads: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -80,6 +82,7 @@ impl Product {
|
|||
dislikes: 0,
|
||||
product_type: r#type,
|
||||
price,
|
||||
uploads: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue