You've already forked AstralRinth
forked from didirus/AstralRinth
a1b59d4545
* untested, unformatted, un-refactored * minor simplification * simplification fix * refactoring, changes * some fixes * fixes, refactoring * missed cache * revs * revs - more! * removed donation links; added all org members to route * renamed slug to title --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
use super::{
|
|
ids::{Base62Id, TeamId},
|
|
teams::TeamMember,
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// The ID of a team
|
|
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(from = "Base62Id")]
|
|
#[serde(into = "Base62Id")]
|
|
pub struct OrganizationId(pub u64);
|
|
|
|
/// An organization of users who control a project
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct Organization {
|
|
/// The id of the organization
|
|
pub id: OrganizationId,
|
|
/// The title (and slug) of the organization
|
|
pub title: String,
|
|
/// The associated team of the organization
|
|
pub team_id: TeamId,
|
|
/// The description of the organization
|
|
pub description: String,
|
|
|
|
/// The icon url of the organization
|
|
pub icon_url: Option<String>,
|
|
/// The color of the organization (picked from the icon)
|
|
pub color: Option<u32>,
|
|
|
|
/// A list of the members of the organization
|
|
pub members: Vec<TeamMember>,
|
|
}
|
|
|
|
impl Organization {
|
|
pub fn from(
|
|
data: crate::database::models::organization_item::Organization,
|
|
team_members: Vec<TeamMember>,
|
|
) -> Self {
|
|
Self {
|
|
id: data.id.into(),
|
|
title: data.title,
|
|
team_id: data.team_id.into(),
|
|
description: data.description,
|
|
members: team_members,
|
|
icon_url: data.icon_url,
|
|
color: data.color,
|
|
}
|
|
}
|
|
}
|