From 48e199eff5fca8f5e4aa71a4091d3ae7acc82b9b Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 30 Dec 2024 22:54:26 +0100 Subject: Add methods for modifying projects While doing that I realized I had forgotten to declare maintainers for projects. Also added default roles and changed so that review_users only contains overrides, so that changes to the project users is instantly applied to all reviews (unless there is an override). --- server/src/api_model.rs | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'server/src/api_model.rs') diff --git a/server/src/api_model.rs b/server/src/api_model.rs index a7c8e88..f3bb5cf 100644 --- a/server/src/api_model.rs +++ b/server/src/api_model.rs @@ -1,7 +1,7 @@ -use rocket::serde::Serialize; +use rocket::serde::{Deserialize, Serialize}; use utoipa::ToSchema; -#[derive(Serialize, Copy, Clone, ToSchema)] +#[derive(Deserialize, Serialize, Copy, Clone, ToSchema)] pub enum ReviewState { Draft, Open, @@ -9,6 +9,13 @@ pub enum ReviewState { Closed, } +#[derive(Deserialize, Serialize, Copy, Clone, ToSchema)] +pub enum UserReviewRole { + Reviewer, + Watcher, + None, +} + #[derive(Serialize, ToSchema)] pub struct User { #[schema(example = 1337u64)] @@ -21,6 +28,13 @@ pub struct User { pub active: bool, } +#[derive(Serialize, ToSchema)] +pub struct ReviewUserEntry { + pub user: User, + #[schema(example = UserReviewRole::Reviewer)] + pub role: UserReviewRole, +} + #[derive(Serialize, ToSchema)] pub struct Review { #[schema(example = 1000u64)] @@ -30,8 +44,7 @@ pub struct Review { #[schema(example = "We're adding more features because features are what we want.")] pub description: String, pub owner: User, - pub reviewers: Vec, - pub watchers: Vec, + pub users: Vec, #[schema(example = ReviewState::Open)] pub state: ReviewState, #[schema(example = 37.5)] @@ -64,6 +77,23 @@ pub struct Reviews { pub reviews: Vec, } +#[derive(Serialize, ToSchema)] +pub struct ProjectUserEntry { + pub user: User, + #[schema(example = UserReviewRole::Reviewer)] + pub default_role: UserReviewRole, + #[schema(example = false)] + pub maintainer: bool, +} + +#[derive(Deserialize, ToSchema)] +pub struct ProjectUserEntryData { + #[schema(example = UserReviewRole::Reviewer)] + pub default_role: Option, + #[schema(example = false)] + pub maintainer: Option, +} + #[derive(Serialize, ToSchema)] pub struct Project { #[schema(example = 1u64)] @@ -72,7 +102,15 @@ pub struct Project { pub title: String, #[schema(example = "Example project")] pub description: String, - pub members: Vec, + pub users: Vec, +} + +#[derive(Deserialize, ToSchema)] +pub struct ProjectData<'r> { + #[schema(example = "FAKE: Features All Kids Erase")] + pub title: Option<&'r str>, + #[schema(example = "Example project")] + pub description: Option<&'r str>, } #[derive(Serialize, ToSchema)] -- cgit v1.2.3-70-g09d2