Make gallery item featuring exclusive (#241)

* Make gallery featured value exclusive

* Run prepare
This commit is contained in:
Geometrically
2021-08-29 15:18:45 -07:00
committed by GitHub
parent 69928219a3
commit f37e267a5e
3 changed files with 47 additions and 0 deletions

View File

@@ -442,6 +442,12 @@ pub async fn project_create_inner(
}
if let Some(gallery_items) = &project_create_data.gallery_items {
if gallery_items.iter().filter(|a| a.featured).count() > 1 {
return Err(CreateError::InvalidInput(String::from(
"Only one gallery image can be featured.",
)));
}
if let Some(item) = gallery_items.iter().find(|x| x.item == name) {
let mut data = Vec::new();
while let Some(chunk) = field.next().await {