diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2024-12-30 22:54:26 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2024-12-30 22:54:26 +0100 |
| commit | 48e199eff5fca8f5e4aa71a4091d3ae7acc82b9b (patch) | |
| tree | 7658a4b55b10293ead1f69e628e9c2731ce6b9f8 /server/src/api_model.rs | |
| parent | 74538f6e3050e67bd06916a111d55933108036d2 (diff) | |
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).
Diffstat (limited to 'server/src/api_model.rs')
| -rw-r--r-- | server/src/api_model.rs | 48 |
1 files changed, 43 insertions, 5 deletions
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)] @@ -22,6 +29,13 @@ pub struct User { } #[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)] pub id: u64, @@ -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<User>, - pub watchers: Vec<User>, + pub users: Vec<ReviewUserEntry>, #[schema(example = ReviewState::Open)] pub state: ReviewState, #[schema(example = 37.5)] @@ -65,6 +78,23 @@ pub struct Reviews { } #[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<UserReviewRole>, + #[schema(example = false)] + pub maintainer: Option<bool>, +} + +#[derive(Serialize, ToSchema)] pub struct Project { #[schema(example = 1u64)] pub id: u64, @@ -72,7 +102,15 @@ pub struct Project { pub title: String, #[schema(example = "Example project")] pub description: String, - pub members: Vec<User>, + pub users: Vec<ProjectUserEntry>, +} + +#[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)] |
