projectlib/jsonb/
project_user.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use common::enums::status::Status;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::enums::participant_type::ParticipantType;

//todo fields
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProjectUser {
    pub id: Uuid,
    pub group_role: ParticipantType,
    pub status: Status,
}

impl ProjectUser {
    pub fn normalize(&self) -> ProjectUser {
        ProjectUser {
            id: self.id,
            group_role: self.group_role.clone(),
            status: self.status.clone(),
        }
    }

    pub fn add_requested_user(&self) -> ProjectUser {
        ProjectUser {
            id: self.id,
            group_role: self.group_role.clone(),
            status: Status::Requested,
        }
    }
}