headless_lms_models/
proposed_block_edits.rs

1use crate::prelude::*;
2use utoipa::ToSchema;
3
4#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
5
6pub struct NewProposedBlockEdit {
7    pub block_id: Uuid,
8    pub block_attribute: String,
9    pub original_text: String,
10    pub changed_text: String,
11}
12
13#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, sqlx::Type, ToSchema)]
14#[sqlx(type_name = "proposal_status", rename_all = "lowercase")]
15pub enum ProposalStatus {
16    Pending,
17    Accepted,
18    Rejected,
19}
20
21#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
22
23pub struct EditedBlockStillExistsData {
24    pub id: Uuid,
25    pub block_id: Uuid,
26    pub current_text: String,
27    pub changed_text: String,
28    pub original_text: String,
29    pub status: ProposalStatus,
30    pub accept_preview: Option<String>,
31}
32
33#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
34
35pub struct EditedBlockNoLongerExistsData {
36    pub id: Uuid,
37    pub block_id: Uuid,
38    pub changed_text: String,
39    pub original_text: String,
40    pub status: ProposalStatus,
41}
42
43#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
44#[serde(tag = "type", rename_all = "kebab-case")]
45pub enum BlockProposal {
46    EditedBlockStillExists(EditedBlockStillExistsData),
47    EditedBlockNoLongerExists(EditedBlockNoLongerExistsData),
48}
49
50#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
51
52pub struct BlockProposalInfo {
53    pub id: Uuid,
54    pub action: BlockProposalAction,
55}
56
57#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Eq, ToSchema)]
58#[serde(tag = "tag", content = "data")]
59pub enum BlockProposalAction {
60    Accept(String),
61    Reject,
62}