liquid_feedback_frontend

view app/main/initiative/_show.lua @ 114:4785cb961a76

voting result also with percent values
author jorges
date Mon Sep 20 01:43:19 2010 +0200 (2010-09-20)
parents 733f65c0c0a0
children 1fdf1e607494
line source
1 local initiative = param.get("initiative", "table")
2 local initiator = param.get("initiator", "table")
4 util.help("initiative.show")
6 if initiative.issue.ranks_available and initiative.admitted then
7 local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
8 ui.container{
9 attr = { class = class },
10 content = function()
11 local max_value = initiative.issue.voter_count
12 slot.put(" ")
13 local positive_votes = initiative.positive_votes
14 local negative_votes = initiative.negative_votes
15 local sum_votes = initiative.positive_votes + initiative.negative_votes
16 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. " (" .. string.format("%.f", positive_votes * 100 / sum_votes ) .. "%)" .. "</b>")
17 slot.put(" &middot; ")
18 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
19 slot.put(" &middot; ")
20 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. " (" .. string.format( "%.f", negative_votes * 100 / sum_votes ) .. "%)" .. "</b>")
21 slot.put(" &middot; ")
22 slot.put("<b>")
23 if initiative.rank == 1 then
24 slot.put(_"Approved")
25 elseif initiative.rank then
26 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
27 else
28 slot.put(_"Not approved")
29 end
30 slot.put("</b>")
31 end
32 }
33 end
35 if initiative.admitted == false then
36 local policy = initiative.issue.policy
37 ui.container{
38 attr = { class = "not_admitted_info" },
39 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
40 }
41 end
43 local web20 = config.user_tab_mode == "accordeon"
44 or config.user_tab_mode == "accordeon_first_expanded"
45 or config.user_tab_mode == "accordeon_all_expanded"
47 if not web20 and initiative.issue.state == "cancelled" then
48 local policy = initiative.issue.policy
49 ui.container{
50 attr = { class = "not_admitted_info" },
51 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
52 }
53 end
55 if initiative.revoked then
56 ui.container{
57 attr = { class = "revoked_info" },
58 content = function()
59 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
60 local suggested_initiative = initiative.suggested_initiative
61 if suggested_initiative then
62 slot.put("<br /><br />")
63 slot.put(_("The initiators suggest to support the following initiative:"))
64 slot.put(" ")
65 ui.link{
66 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
67 module = "initiative",
68 view = "show",
69 id = suggested_initiative.id
70 }
71 end
72 end
73 }
74 end
76 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
77 ui.container{
78 attr = { class = "initiator_invite_info" },
79 content = function()
80 slot.put(_"You are invited to become initiator of this initiative.")
81 slot.put(" ")
82 ui.link{
83 image = { static = "icons/16/tick.png" },
84 text = _"Accept invitation",
85 module = "initiative",
86 action = "accept_invitation",
87 id = initiative.id,
88 routing = {
89 default = {
90 mode = "redirect",
91 module = request.get_module(),
92 view = request.get_view(),
93 id = param.get_id_cgi(),
94 params = param.get_all_cgi()
95 }
96 }
97 }
98 slot.put(" ")
99 ui.link{
100 image = { static = "icons/16/cross.png" },
101 text = _"Refuse invitation",
102 module = "initiative",
103 action = "reject_initiator_invitation",
104 params = {
105 initiative_id = initiative.id,
106 member_id = app.session.member.id
107 },
108 routing = {
109 default = {
110 mode = "redirect",
111 module = request.get_module(),
112 view = request.get_view(),
113 id = param.get_id_cgi(),
114 params = param.get_all_cgi()
115 }
116 }
117 }
118 end
119 }
120 slot.put("<br />")
121 end
124 local supporter
126 if app.session.member_id then
127 supporter = app.session.member:get_reference_selector("supporters")
128 :add_where{ "initiative_id = ?", initiative.id }
129 :optional_object_mode()
130 :exec()
131 end
133 if supporter and not initiative.issue.closed then
134 local old_draft_id = supporter.draft_id
135 local new_draft_id = initiative.current_draft.id
136 if old_draft_id ~= new_draft_id then
137 ui.container{
138 attr = { class = "draft_updated_info" },
139 content = function()
140 slot.put(_"The draft of this initiative has been updated!")
141 slot.put(" ")
142 ui.link{
143 content = _"Show diff",
144 module = "draft",
145 view = "diff",
146 params = {
147 old_draft_id = old_draft_id,
148 new_draft_id = new_draft_id
149 }
150 }
151 if not initiative.revoked then
152 slot.put(" ")
153 ui.link{
154 text = _"Refresh support to current draft",
155 module = "initiative",
156 action = "add_support",
157 id = initiative.id,
158 routing = {
159 default = {
160 mode = "redirect",
161 module = "initiative",
162 view = "show",
163 id = initiative.id
164 }
165 }
166 }
167 end
168 end
169 }
170 end
171 end
174 if app.session.member_id then
175 ui.container{
176 attr = {
177 id = "initiative_" .. tostring(initiative.id) .. "_support"
178 },
179 content = function()
180 execute.view{
181 module = "initiative",
182 view = "show_support",
183 params = {
184 initiative = initiative
185 }
186 }
187 end
188 }
189 end
191 if (initiative.discussion_url and #initiative.discussion_url > 0)
192 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
193 ui.container{
194 attr = { class = "vertical" },
195 content = function()
196 ui.container{
197 attr = { class = "ui_field_label" },
198 content = _"Discussion with initiators"
199 }
200 ui.tag{
201 tag = "span",
202 content = function()
203 if initiative.discussion_url:find("^https?://") then
204 if initiative.discussion_url and #initiative.discussion_url > 0 then
205 ui.link{
206 attr = {
207 class = "actions",
208 target = "_blank",
209 title = initiative.discussion_url
210 },
211 content = function()
212 slot.put(encode.html(initiative.discussion_url))
213 end,
214 external = initiative.discussion_url
215 }
216 end
217 else
218 slot.put(encode.html(initiative.discussion_url))
219 end
220 slot.put(" ")
221 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
222 ui.link{
223 attr = { class = "actions" },
224 text = _"(change URL)",
225 module = "initiative",
226 view = "edit",
227 id = initiative.id
228 }
229 end
230 end
231 }
232 end
233 }
234 end
238 execute.view{
239 module = "initiative",
240 view = "show_tab",
241 params = {
242 initiative = initiative,
243 initiator = initiator
244 }
245 }

Impressum / About Us