You've already forked AstralRinth
forked from didirus/AstralRinth
Add ordering to categories, gallery images, and team members (#501)
This commit is contained in:
@@ -1399,6 +1399,7 @@ pub struct GalleryCreateQuery {
|
||||
pub title: Option<String>,
|
||||
#[validate(length(min = 1, max = 2048))]
|
||||
pub description: Option<String>,
|
||||
pub ordering: Option<i64>,
|
||||
}
|
||||
|
||||
#[post("{id}/gallery")]
|
||||
@@ -1498,6 +1499,7 @@ pub async fn add_gallery_item(
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
created: Utc::now(),
|
||||
ordering: item.ordering.unwrap_or(0),
|
||||
}
|
||||
.insert(project_item.inner.id, &mut transaction)
|
||||
.await?;
|
||||
@@ -1532,6 +1534,7 @@ pub struct GalleryEditQuery {
|
||||
)]
|
||||
#[validate(length(min = 1, max = 2048))]
|
||||
pub description: Option<Option<String>>,
|
||||
pub ordering: Option<i64>,
|
||||
}
|
||||
|
||||
#[patch("{id}/gallery")]
|
||||
@@ -1653,6 +1656,19 @@ pub async fn edit_gallery_item(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
if let Some(ordering) = item.ordering {
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE mods_gallery
|
||||
SET ordering = $2
|
||||
WHERE id = $1
|
||||
",
|
||||
id,
|
||||
ordering
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user