liquid_feedback_frontend

view app/main/initiative/_show.lua @ 431:9ce4da0e0783

Set maximum width of application
author bsw
date Sat Mar 10 20:28:57 2012 +0100 (2012-03-10)
parents 4cdf615ff358
children 0e25d0459b5f
line source
1 local initiative = param.get("initiative", "table")
2 local initiator = param.get("initiator", "table")
4 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
5 :add_field("initiator.accepted", "accepted")
6 :add_order_by("member.name")
7 if initiator and initiator.accepted then
8 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
9 else
10 initiators_members_selector:add_where("initiator.accepted")
11 end
13 local initiators = initiators_members_selector:exec()
16 local initiatives_selector = initiative.issue:get_reference_selector("initiatives")
17 slot.select("initiatives_list", function()
18 execute.view{
19 module = "initiative",
20 view = "_list",
21 params = {
22 issue = initiative.issue,
23 initiatives_selector = initiatives_selector,
24 no_sort = true, highlight_initiative = initiative, limit = 3
25 }
26 }
27 end)
29 slot.select("initiative_head", function()
31 ui.container{
32 attr = { class = "initiative_name" },
33 content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
34 }
36 if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then
37 ui.tag{
38 attr = { class = "initiator_names" },
39 content = function()
40 for i, initiator in ipairs(initiators) do
41 slot.put(" ")
42 ui.link{
43 content = function ()
44 execute.view{
45 module = "member_image",
46 view = "_show",
47 params = {
48 member = initiator,
49 image_type = "avatar",
50 show_dummy = true,
51 class = "micro_avatar",
52 popup_text = text
53 }
54 }
55 end,
56 module = "member", view = "show", id = initiator.id
57 }
58 slot.put(" ")
59 ui.link{
60 text = initiator.name,
61 module = "member", view = "show", id = initiator.id
62 }
63 if not initiator.accepted then
64 ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" }
65 end
66 end
67 end
68 }
69 end
71 if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
72 slot.put(" · ")
73 ui.link{
74 attr = { class = "action" },
75 content = function()
76 slot.put(_"Invite initiator")
77 end,
78 module = "initiative",
79 view = "add_initiator",
80 params = { initiative_id = initiative.id }
81 }
82 if #initiators > 1 then
83 slot.put(" · ")
84 ui.link{
85 content = function()
86 slot.put(_"Remove initiator")
87 end,
88 module = "initiative",
89 view = "remove_initiator",
90 params = { initiative_id = initiative.id }
91 }
92 end
93 end
94 if initiator and initiator.accepted == false then
95 slot.put(" · ")
96 ui.link{
97 text = _"Cancel refuse of invitation",
98 module = "initiative",
99 action = "remove_initiator",
100 params = {
101 initiative_id = initiative.id,
102 member_id = app.session.member.id
103 },
104 routing = {
105 ok = {
106 mode = "redirect",
107 module = "initiative",
108 view = "show",
109 id = initiative.id
110 }
111 }
112 }
113 end
114 if app.session.member_id then
115 execute.view{
116 module = "supporter",
117 view = "_show_box",
118 params = {
119 initiative = initiative
120 }
121 }
122 end
124 end )
127 util.help("initiative.show")
130 if initiative.issue.ranks_available and initiative.admitted then
131 local class = initiative.winner and "admitted_info" or "not_admitted_info"
132 ui.container{
133 attr = { class = class },
134 content = function()
135 local max_value = initiative.issue.voter_count
136 slot.put(" ")
137 local positive_votes = initiative.positive_votes
138 local negative_votes = initiative.negative_votes
139 local sum_votes = initiative.positive_votes + initiative.negative_votes
140 local function perc(votes, sum)
141 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
142 return ""
143 end
144 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
145 slot.put(" &middot; ")
146 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
147 slot.put(" &middot; ")
148 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
149 slot.put(" &middot; ")
150 slot.put("<b>")
151 if initiative.winner then
152 slot.put(_"Approved")
153 elseif initiative.rank then
154 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
155 else
156 slot.put(_"Not approved")
157 end
158 slot.put("</b>")
159 end
160 }
161 end
163 if initiative.admitted == false then
164 local policy = initiative.issue.policy
165 ui.container{
166 attr = { class = "not_admitted_info" },
167 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
168 }
169 end
171 if initiative.issue.state == "cancelled" then
172 local policy = initiative.issue.policy
173 ui.container{
174 attr = { class = "not_admitted_info" },
175 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
176 }
177 end
179 if initiative.revoked then
180 ui.container{
181 attr = { class = "revoked_info" },
182 content = function()
183 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
184 local suggested_initiative = initiative.suggested_initiative
185 if suggested_initiative then
186 slot.put("<br /><br />")
187 slot.put(_("The initiators suggest to support the following initiative:"))
188 slot.put(" ")
189 ui.link{
190 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
191 module = "initiative",
192 view = "show",
193 id = suggested_initiative.id
194 }
195 end
196 end
197 }
198 end
200 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
201 ui.container{
202 attr = { class = "initiator_invite_info" },
203 content = function()
204 slot.put(_"You are invited to become initiator of this initiative.")
205 slot.put(" ")
206 ui.link{
207 image = { static = "icons/16/tick.png" },
208 text = _"Accept invitation",
209 module = "initiative",
210 action = "accept_invitation",
211 id = initiative.id,
212 routing = {
213 default = {
214 mode = "redirect",
215 module = request.get_module(),
216 view = request.get_view(),
217 id = param.get_id_cgi(),
218 params = param.get_all_cgi()
219 }
220 }
221 }
222 slot.put(" ")
223 ui.link{
224 image = { static = "icons/16/cross.png" },
225 text = _"Refuse invitation",
226 module = "initiative",
227 action = "reject_initiator_invitation",
228 params = {
229 initiative_id = initiative.id,
230 member_id = app.session.member.id
231 },
232 routing = {
233 default = {
234 mode = "redirect",
235 module = request.get_module(),
236 view = request.get_view(),
237 id = param.get_id_cgi(),
238 params = param.get_all_cgi()
239 }
240 }
241 }
242 end
243 }
244 slot.put("<br />")
245 end
248 local supporter
250 if app.session.member_id then
251 supporter = app.session.member:get_reference_selector("supporters")
252 :add_where{ "initiative_id = ?", initiative.id }
253 :optional_object_mode()
254 :exec()
255 end
257 if supporter and not initiative.issue.closed then
258 local old_draft_id = supporter.draft_id
259 local new_draft_id = initiative.current_draft.id
260 if old_draft_id ~= new_draft_id then
261 ui.container{
262 attr = { class = "draft_updated_info" },
263 content = function()
264 slot.put(_"The draft of this initiative has been updated!")
265 slot.put(" ")
266 ui.link{
267 content = _"Show diff",
268 module = "draft",
269 view = "diff",
270 params = {
271 old_draft_id = old_draft_id,
272 new_draft_id = new_draft_id
273 }
274 }
275 if not initiative.revoked then
276 slot.put(" ")
277 ui.link{
278 text = _"Refresh support to current draft",
279 module = "initiative",
280 action = "add_support",
281 id = initiative.id,
282 routing = {
283 default = {
284 mode = "redirect",
285 module = "initiative",
286 view = "show",
287 id = initiative.id
288 }
289 }
290 }
291 end
292 end
293 }
294 end
295 end
297 execute.view{
298 module = "initiative",
299 view = "show_tab",
300 params = {
301 initiative = initiative,
302 initiator = initiator
303 }
304 }
306 if initiative.issue.snapshot then
307 slot.put("<br />")
308 ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot }
309 end

Impressum / About Us