Add ordering to categories, gallery images, and team members (#501)

This commit is contained in:
triphora
2022-12-23 14:34:04 -05:00
committed by GitHub
parent 9fed1cde25
commit 16d5a70c08
11 changed files with 1217 additions and 1041 deletions

View File

@@ -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?;