use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(16))")]
#[serde(rename_all = "lowercase")]
pub enum Status {
#[sea_orm(string_value = "open")]
Open,
#[sea_orm(string_value = "decided")]
Decided,
#[sea_orm(string_value = "cancelled")]
Cancelled,
}
/// A lunch being decided: a ballot of options, people going, their votes.
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "outings")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub area_id: Uuid,
pub on_date: Date,
/// When the group means to eat; places closed then aren't drawn.
pub meal_time: Time,
pub status: Status,
/// How many options the ballot holds.
pub option_count: i32,
/// 1 for the first draw, +1 per re-roll.
pub rolls: i32,
/// The logged lunch, once decided.
pub lunch_id: Option<Uuid>,
pub created_by: Option<Uuid>,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::areas::Entity",
from = "Column::AreaId",
to = "super::areas::Column::Id",
on_delete = "Cascade"
)]
Areas,
}
impl Related<super::areas::Entity> for Entity {
fn to() -> RelationDef {
Relation::Areas.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/fieri-forever
the flavortown lunch engine
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
1.6 KiB · text
History
7a00c02