2026-02-03 16:54:39 +00:00
|
|
|
use chrono::{DateTime, Utc};
|
2026-01-27 16:21:58 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use sqlx::FromRow;
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
|
|
|
|
#[sqlx(type_name = "proposal_status", rename_all = "lowercase")]
|
|
|
|
|
pub enum ProposalStatus {
|
|
|
|
|
Draft,
|
|
|
|
|
Discussion,
|
|
|
|
|
Voting,
|
|
|
|
|
Closed,
|
|
|
|
|
Archived,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
|
|
|
|
#[sqlx(type_name = "deliberation_phase", rename_all = "lowercase")]
|
|
|
|
|
pub enum DeliberationPhase {
|
|
|
|
|
Drafting,
|
|
|
|
|
Informing,
|
|
|
|
|
Discussing,
|
|
|
|
|
Voting,
|
|
|
|
|
Concluded,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
|
|
|
pub struct Proposal {
|
|
|
|
|
pub id: Uuid,
|
|
|
|
|
pub community_id: Uuid,
|
|
|
|
|
pub author_id: Uuid,
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub description: String,
|
|
|
|
|
pub status: ProposalStatus,
|
|
|
|
|
pub voting_method: String,
|
|
|
|
|
pub voting_starts_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub voting_ends_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub created_at: DateTime<Utc>,
|
|
|
|
|
pub updated_at: DateTime<Utc>,
|
|
|
|
|
pub deliberation_phase: Option<DeliberationPhase>,
|
|
|
|
|
pub inform_starts_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub inform_ends_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub discuss_starts_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub discuss_ends_at: Option<DateTime<Utc>>,
|
|
|
|
|
pub min_read_time_seconds: Option<i32>,
|
|
|
|
|
pub facilitator_id: Option<Uuid>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
pub struct ProposalOption {
|
|
|
|
|
pub id: Uuid,
|
|
|
|
|
pub proposal_id: Uuid,
|
|
|
|
|
pub label: String,
|
|
|
|
|
pub description: Option<String>,
|
|
|
|
|
pub sort_order: i32,
|
|
|
|
|
pub created_at: DateTime<Utc>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
|
pub struct ProposalWithOptions {
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
|
pub proposal: Proposal,
|
|
|
|
|
pub options: Vec<ProposalOptionWithVotes>,
|
|
|
|
|
pub author_name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
|
pub struct ProposalOptionWithVotes {
|
|
|
|
|
pub id: Uuid,
|
|
|
|
|
pub label: String,
|
|
|
|
|
pub description: Option<String>,
|
|
|
|
|
pub vote_count: i64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct CreateProposal {
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub description: String,
|
|
|
|
|
pub options: Vec<String>,
|
|
|
|
|
}
|