db/specs/modelsold/governance/proposal.v

63 lines
2.8 KiB
V

module governance
import base
import freeflowuniverse.herolib.data.ourtime
// ProposalStatus enum is used from governance_enums.v in the same module
// Proposal represents a governance proposal that can be voted upon.
// It now incorporates the voting mechanism from biz/vote.v.
pub struct Proposal {
base.Base // Provides Proposal's own ID, created_at, updated_at
pub mut:
// Fields from original Proposal struct
creator_id string // User ID of the proposal creator
title string // Title of the proposal
description string // Detailed description of the proposal
status ProposalStatus // Status of the proposal lifecycle (draft, active, approved etc.)
// Fields from biz/vote.v's Vote struct (representing the voting event aspects of the proposal)
vote_start_date ourtime.OurTime // When voting on this proposal starts
vote_end_date ourtime.OurTime // When voting on this proposal ends
vote_status VoteEventStatus // Status of the voting event (open, closed, cancelled)
options []VoteOption // The choices users can vote for
ballots []Ballot // The cast votes by users
private_group []u32 // Optional: list of user IDs who are eligible to vote
}
// ProposalStatus defines the lifecycle status of a governance proposal itself
pub enum ProposalStatus {
draft // Proposal is being prepared
active // Proposal is active (might be pre-voting, during voting, or post-voting but not yet finalized)
approved // Proposal has been formally approved
rejected // Proposal has been formally rejected
cancelled// Proposal was cancelled
}
// -- Structures from biz/vote.v, adapted for integration --
// VoteEventStatus represents the status of the voting process for a proposal
// Renamed from VoteStatus in biz/vote.v to avoid confusion with ProposalStatus
pub enum VoteEventStatus {
open // Voting is currently open
closed // Voting has finished
cancelled // The voting event was cancelled
}
// VoteOption represents a specific choice that can be voted on within a proposal's voting event
pub struct VoteOption {
pub mut:
id u8 // Simple identifier for this option within this proposal's vote (e.g., 1, 2, 3)
text string // The descriptive text of the option (e.g., "Option A: Approve budget")
count int // How many votes this option has received
min_valid int // Optional: minimum votes needed for this option to be considered valid
}
// Ballot represents an individual vote cast by a user for a specific proposal
pub struct Ballot {
base.Base // Provides Ballot's own ID, created_at, updated_at
pub mut:
user_id u32 // The ID of the user who cast this ballot
vote_option_id u8 // The 'id' of the VoteOption chosen by the user
shares_count int // Number of shares/tokens/voting power used for this ballot
}