Add REST APIs for getting and adding contributors

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-01-22 10:48:33 -08:00
parent 5b906e731d
commit 1981de4cae
12 changed files with 206 additions and 56 deletions

View file

@ -0,0 +1,30 @@
use crate::db::UserId;
use sea_orm::entity::prelude::*;
use serde::Serialize;
/// A user who has signed the CLA.
#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel, Serialize)]
#[sea_orm(table_name = "contributors")]
pub struct Model {
#[sea_orm(primary_key)]
pub user_id: UserId,
pub signed_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id"
)]
User,
}
impl ActiveModelBehavior for ActiveModel {}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}