diff --git a/actix_mvc_app/src/controllers/governance.rs b/actix_mvc_app/src/controllers/governance.rs index 71e90df..aa51af5 100644 --- a/actix_mvc_app/src/controllers/governance.rs +++ b/actix_mvc_app/src/controllers/governance.rs @@ -443,6 +443,12 @@ impl GovernanceController { } } + // Calculate total vote counts for all proposals + let total_vote_counts = Self::calculate_total_vote_counts(&proposals); + ctx.insert("total_yes_votes", &total_vote_counts.0); + ctx.insert("total_no_votes", &total_vote_counts.1); + ctx.insert("total_abstain_votes", &total_vote_counts.2); + ctx.insert("votes", &user_votes); render_template(&tmpl, "governance/my_votes.html", &ctx) @@ -607,6 +613,30 @@ impl GovernanceController { } // The calculate_statistics_from_database function is now defined at the top of the impl block + + /// Calculate total vote counts across all proposals + /// Returns a tuple of (yes_count, no_count, abstain_count) + fn calculate_total_vote_counts(proposals: &[Proposal]) -> (usize, usize, usize) { + let mut yes_count = 0; + let mut no_count = 0; + let mut abstain_count = 0; + + for proposal in proposals { + // Extract votes from this proposal + let votes = Self::extract_votes_from_proposal(proposal); + + // Count votes by type + for vote in votes { + match vote.vote_type { + VoteType::Yes => yes_count += 1, + VoteType::No => no_count += 1, + VoteType::Abstain => abstain_count += 1, + } + } + } + + (yes_count, no_count, abstain_count) + } } /// Represents the data submitted in the proposal form diff --git a/actix_mvc_app/src/views/governance/create_proposal.html b/actix_mvc_app/src/views/governance/create_proposal.html index eb91862..c81435d 100644 --- a/actix_mvc_app/src/views/governance/create_proposal.html +++ b/actix_mvc_app/src/views/governance/create_proposal.html @@ -4,13 +4,6 @@ {% block content %}
-
-
-

Create Governance Proposal

-

Submit a new proposal for the community to vote on.

-
-
-
@@ -30,11 +23,26 @@
- - + + +
+
+
+ +
About Creating Proposals
+

Creating a proposal is an important step in our community governance process. Well-crafted proposals clearly state the problem, solution, and implementation details. The community will review and vote on your proposal, so be thorough and thoughtful in your submission.

+ +
+
+
+ +
-
-
+ +
+
New Proposal
@@ -49,7 +57,7 @@
-
Explain the purpose, benefits, and implementation details
@@ -84,12 +92,10 @@
-
- - -
-
-
+ + +
+
Proposal Guidelines
diff --git a/actix_mvc_app/src/views/governance/my_votes.html b/actix_mvc_app/src/views/governance/my_votes.html index 9a1085d..bca1cae 100644 --- a/actix_mvc_app/src/views/governance/my_votes.html +++ b/actix_mvc_app/src/views/governance/my_votes.html @@ -23,6 +23,57 @@
+ +
+
+
+ +
About Votes
+

Voting is a fundamental right of all token holders in our governance system. Each vote carries weight + proportional to your token holdings, ensuring fair representation. The voting statistics below show the + community's collective decision-making across all proposals.

+ +
+
+
+ + +
+
+
+
+
Yes Votes
+

+ {{ total_yes_votes }} +

+
+
+
+
+
+
+
No Votes
+

+ {{ total_no_votes }} +

+
+
+
+
+
+
+
Abstain Votes
+

+ {{ total_abstain_votes }} +

+
+
+
+
+
@@ -82,57 +133,5 @@
- -{% if votes | length > 0 %} -
-
-
-
-
Yes Votes
-

- {% set yes_count = 0 %} - {% for item in votes %}{% set vote = item.0 %}{% set proposal = item.1 %} - {% if vote.vote_type == 'Yes' %} - {% set yes_count = yes_count + 1 %} - {% endif %} - {% endfor %} - {{ yes_count }} -

-
-
-
-
-
-
-
No Votes
-

- {% set no_count = 0 %} - {% for item in votes %}{% set vote = item.0 %}{% set proposal = item.1 %} - {% if vote.vote_type == 'No' %} - {% set no_count = no_count + 1 %} - {% endif %} - {% endfor %} - {{ no_count }} -

-
-
-
-
-
-
-
Abstain Votes
-

- {% set abstain_count = 0 %} - {% for item in votes %}{% set vote = item.0 %}{% set proposal = item.1 %} - {% if vote.vote_type == 'Abstain' %} - {% set abstain_count = abstain_count + 1 %} - {% endif %} - {% endfor %} - {{ abstain_count }} -

-
-
-
-
-{% endif %} + {% endblock %} \ No newline at end of file