liquid_feedback_frontend
view app/main/initiative/_sidebar_state.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
author | bsw |
---|---|
date | Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) |
parents | |
children | ba47b1e9ab00 |
line source
1 local initiative = param.get("initiative", "table")
4 -- voting results
5 if initiative.issue.fully_frozen and initiative.issue.closed and initiative.admitted
6 and initiative.issue.voter_count then
7 local class = initiative.winner and "sectionRow admitted_info" or "sectionRow not_admitted_info"
8 ui.container{
9 attr = { class = class },
10 content = function()
11 local max_value = initiative.issue.voter_count
12 local positive_votes = initiative.positive_votes
13 local negative_votes = initiative.negative_votes
14 local abstention_votes = max_value -
15 negative_votes -
16 positive_votes
17 local function perc(votes, sum)
18 if sum > 0 then return string.format( "%.f", votes * 100 / sum ) .. "%" end
19 return ""
20 end
21 local head_text
22 if initiative.winner then
23 head_text = _"Approved"
24 elseif initiative.rank then
25 head_text = _("Rejected (rank #{rank})", { rank = initiative.rank })
26 else
27 head_text = _"Rejected"
28 end
30 util.initiative_pie( initiative )
32 ui.heading { level = 1, content = head_text }
34 ui.tag { tag = "table", content = function ()
35 ui.tag { tag = "tr", attr = { class = "yes" }, content = function ()
36 ui.tag { tag = "td", content =
37 tostring(positive_votes)
38 }
39 ui.tag { tag = "th", content = _"Yes" }
40 ui.tag { tag = "td", content =
41 perc(positive_votes, max_value)
42 }
43 ui.tag { tag = "th", content = _"Yes" }
44 end }
45 ui.tag { tag = "tr", attr = { class = "abstention" }, content = function ()
46 ui.tag { tag = "td", content =
47 tostring(abstention_votes)
48 }
49 ui.tag { tag = "th", content = _"Abstention" }
50 ui.tag { tag = "td", content =
51 perc(abstention_votes, max_value)
52 }
53 ui.tag { tag = "th", content = _"Abstention" }
54 end }
55 ui.tag { tag = "tr", attr = { class = "no" }, content = function ()
56 ui.tag { tag = "td", content =
57 tostring(negative_votes)
58 }
59 ui.tag { tag = "th", content = _"No" }
60 ui.tag { tag = "td", content =
61 perc(negative_votes, max_value)
62 }
63 ui.tag { tag = "th", content = _"No" }
64 end }
65 end }
66 end
67 }
68 end
70 -- initiative not admitted info
71 if initiative.admitted == false then
72 local policy = initiative.issue.policy
73 ui.container{
74 attr = { class = "sectionRow not_admitted_info" },
75 content = function ()
76 ui.heading { level = 1, content = _"Initiative not admitted" }
77 ui.container { content = _("This initiative has not been admitted! It failed the 2nd quorum of #{quorum}.", { quorum = format.percentage ( policy.initiative_quorum_num / policy.initiative_quorum_den ) } ) }
78 end
79 }
80 end
82 -- initiative revoked info
83 if initiative.revoked then
84 ui.container{
85 attr = { class = "sectionRow revoked_info" },
86 content = function()
87 ui.heading { level = 1, content = _"Initiative revoked" }
88 slot.put(_("This initiative has been revoked at #{revoked} by:", {
89 revoked = format.timestamp(initiative.revoked)
90 }))
91 slot.put(" ")
92 ui.link{
93 module = "member", view = "show", id = initiative.revoked_by_member_id,
94 content = initiative.revoked_by_member.name
95 }
96 local suggested_initiative = initiative.suggested_initiative
97 if suggested_initiative then
98 slot.put("<br /><br />")
99 slot.put(_("The initiators suggest to support the following initiative:"))
100 slot.put("<br />")
101 ui.link{
102 content = suggested_initiative.display_name,
103 module = "initiative",
104 view = "show",
105 id = suggested_initiative.id
106 }
107 end
108 end
109 }
110 end