liquid_feedback_frontend
diff app/main/initiative/_show.lua @ 493:01cf3c50cbee
Show (not)admitted notices in initiative head
author | bsw |
---|---|
date | Fri Mar 16 11:32:06 2012 +0100 (2012-03-16) |
parents | 0e25d0459b5f |
children | 63d6549cc00b |
line diff
1.1 --- a/app/main/initiative/_show.lua Thu Mar 15 21:03:57 2012 +0100 1.2 +++ b/app/main/initiative/_show.lua Fri Mar 16 11:32:06 2012 +0100 1.3 @@ -128,76 +128,78 @@ 1.4 1.5 util.help("initiative.show") 1.6 1.7 +slot.select("initiative_head", function() 1.8 1.9 -if initiative.issue.ranks_available and initiative.admitted then 1.10 - local class = initiative.winner and "admitted_info" or "not_admitted_info" 1.11 - ui.container{ 1.12 - attr = { class = class }, 1.13 - content = function() 1.14 - local max_value = initiative.issue.voter_count 1.15 - slot.put(" ") 1.16 - local positive_votes = initiative.positive_votes 1.17 - local negative_votes = initiative.negative_votes 1.18 - local sum_votes = initiative.positive_votes + initiative.negative_votes 1.19 - local function perc(votes, sum) 1.20 - if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end 1.21 - return "" 1.22 + if initiative.issue.ranks_available and initiative.admitted then 1.23 + local class = initiative.winner and "admitted_info" or "not_admitted_info" 1.24 + ui.container{ 1.25 + attr = { class = class }, 1.26 + content = function() 1.27 + local max_value = initiative.issue.voter_count 1.28 + slot.put(" ") 1.29 + local positive_votes = initiative.positive_votes 1.30 + local negative_votes = initiative.negative_votes 1.31 + local sum_votes = initiative.positive_votes + initiative.negative_votes 1.32 + local function perc(votes, sum) 1.33 + if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end 1.34 + return "" 1.35 + end 1.36 + slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>") 1.37 + slot.put(" · ") 1.38 + slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>") 1.39 + slot.put(" · ") 1.40 + slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>") 1.41 + slot.put(" · ") 1.42 + slot.put("<b>") 1.43 + if initiative.winner then 1.44 + slot.put(_"Approved") 1.45 + elseif initiative.rank then 1.46 + slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) 1.47 + else 1.48 + slot.put(_"Not approved") 1.49 + end 1.50 + slot.put("</b>") 1.51 end 1.52 - slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>") 1.53 - slot.put(" · ") 1.54 - slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>") 1.55 - slot.put(" · ") 1.56 - slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>") 1.57 - slot.put(" · ") 1.58 - slot.put("<b>") 1.59 - if initiative.winner then 1.60 - slot.put(_"Approved") 1.61 - elseif initiative.rank then 1.62 - slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) 1.63 - else 1.64 - slot.put(_"Not approved") 1.65 - end 1.66 - slot.put("</b>") 1.67 - end 1.68 - } 1.69 -end 1.70 + } 1.71 + end 1.72 1.73 -if initiative.admitted == false then 1.74 - local policy = initiative.issue.policy 1.75 - ui.container{ 1.76 - attr = { class = "not_admitted_info" }, 1.77 - content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) }) 1.78 - } 1.79 -end 1.80 - 1.81 -if initiative.issue.state == "cancelled" then 1.82 - local policy = initiative.issue.policy 1.83 - ui.container{ 1.84 - attr = { class = "not_admitted_info" }, 1.85 - content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) }) 1.86 - } 1.87 -end 1.88 + if initiative.admitted == false then 1.89 + local policy = initiative.issue.policy 1.90 + ui.container{ 1.91 + attr = { class = "not_admitted_info" }, 1.92 + content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) }) 1.93 + } 1.94 + end 1.95 1.96 -if initiative.revoked then 1.97 - ui.container{ 1.98 - attr = { class = "revoked_info" }, 1.99 - content = function() 1.100 - slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) 1.101 - local suggested_initiative = initiative.suggested_initiative 1.102 - if suggested_initiative then 1.103 - slot.put("<br /><br />") 1.104 - slot.put(_("The initiators suggest to support the following initiative:")) 1.105 - slot.put(" ") 1.106 - ui.link{ 1.107 - content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), 1.108 - module = "initiative", 1.109 - view = "show", 1.110 - id = suggested_initiative.id 1.111 - } 1.112 + if initiative.revoked then 1.113 + ui.container{ 1.114 + attr = { class = "revoked_info" }, 1.115 + content = function() 1.116 + slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) 1.117 + local suggested_initiative = initiative.suggested_initiative 1.118 + if suggested_initiative then 1.119 + slot.put("<br /><br />") 1.120 + slot.put(_("The initiators suggest to support the following initiative:")) 1.121 + slot.put(" ") 1.122 + ui.link{ 1.123 + content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), 1.124 + module = "initiative", 1.125 + view = "show", 1.126 + id = suggested_initiative.id 1.127 + } 1.128 + end 1.129 end 1.130 - end 1.131 - } 1.132 -end 1.133 + } 1.134 + end 1.135 + 1.136 + if initiative.issue.state == "cancelled" then 1.137 + local policy = initiative.issue.policy 1.138 + ui.container{ 1.139 + attr = { class = "not_admitted_info" }, 1.140 + content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) }) 1.141 + } 1.142 + end 1.143 +end) 1.144 1.145 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then 1.146 ui.container{