rev |
line source |
bsw@527
|
1 local initiative = Initiative:by_id(param.get_id())
|
bsw@716
|
2 initiative:load_everything_for_member_id(app.session.member_id)
|
bsw/jbe@0
|
3
|
bsw@548
|
4 local issue = initiative.issue
|
bsw@548
|
5
|
bsw@548
|
6 if app.session.member_id then
|
bsw@548
|
7 issue:load_everything_for_member_id(app.session.member_id)
|
bsw@548
|
8 end
|
bsw@548
|
9
|
jorges@103
|
10 app.html_title.title = initiative.name
|
jorges@103
|
11 app.html_title.subtitle = _("Initiative ##{id}", { id = initiative.id })
|
jorges@103
|
12
|
bsw@526
|
13 slot.select("head", function()
|
bsw@526
|
14 execute.view{
|
bsw@527
|
15 module = "issue", view = "_head",
|
bsw@548
|
16 params = { issue = issue, initiative = initiative }
|
bsw@526
|
17 }
|
bsw@526
|
18 end)
|
bsw@526
|
19
|
bsw@718
|
20 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
|
bsw@718
|
21 :add_field("initiator.accepted", "accepted")
|
bsw@718
|
22 :add_order_by("member.name")
|
bsw@718
|
23 if initiator and initiator.accepted then
|
bsw@718
|
24 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
|
bsw@718
|
25 else
|
bsw@718
|
26 initiators_members_selector:add_where("initiator.accepted")
|
bsw@718
|
27 end
|
bsw@718
|
28
|
bsw@718
|
29 local initiators = initiators_members_selector:exec()
|
bsw@718
|
30
|
bsw@718
|
31
|
bsw@718
|
32 local initiatives_selector = initiative.issue:get_reference_selector("initiatives")
|
bsw@718
|
33 slot.select("head", function()
|
bsw@718
|
34 execute.view{
|
bsw@718
|
35 module = "issue",
|
bsw@718
|
36 view = "_show",
|
bsw@718
|
37 params = {
|
bsw@718
|
38 issue = initiative.issue,
|
bsw@718
|
39 initiative_limit = 3,
|
bsw@718
|
40 for_initiative = initiative
|
bsw@718
|
41 }
|
bsw@718
|
42 }
|
bsw@718
|
43 end)
|
bsw@718
|
44
|
bsw@718
|
45 util.help("initiative.show")
|
bsw@718
|
46
|
bsw@718
|
47 ui.container{ attr = { class = "initiative_head" }, content = function()
|
bsw@718
|
48
|
bsw@718
|
49 ui.container{
|
bsw@718
|
50 attr = { class = "title" },
|
bsw@718
|
51 content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
|
bsw@718
|
52 }
|
bsw@718
|
53
|
bsw@718
|
54 ui.container{ attr = { class = "content" }, content = function()
|
bsw@718
|
55 if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then
|
bsw@718
|
56 ui.tag{
|
bsw@718
|
57 attr = { class = "initiator_names" },
|
bsw@718
|
58 content = function()
|
bsw@718
|
59 for i, initiator in ipairs(initiators) do
|
bsw@718
|
60 slot.put(" ")
|
bsw@718
|
61 if app.session.member_id or config.public_access == "full" then
|
bsw@718
|
62 ui.link{
|
bsw@718
|
63 content = function ()
|
bsw@718
|
64 execute.view{
|
bsw@718
|
65 module = "member_image",
|
bsw@718
|
66 view = "_show",
|
bsw@718
|
67 params = {
|
bsw@718
|
68 member = initiator,
|
bsw@718
|
69 image_type = "avatar",
|
bsw@718
|
70 show_dummy = true,
|
bsw@718
|
71 class = "micro_avatar",
|
bsw@718
|
72 popup_text = text
|
bsw@718
|
73 }
|
bsw@718
|
74 }
|
bsw@718
|
75 end,
|
bsw@718
|
76 module = "member", view = "show", id = initiator.id
|
bsw@718
|
77 }
|
bsw@718
|
78 slot.put(" ")
|
bsw@718
|
79 end
|
bsw@718
|
80 ui.link{
|
bsw@718
|
81 text = initiator.name,
|
bsw@718
|
82 module = "member", view = "show", id = initiator.id
|
bsw@718
|
83 }
|
bsw@718
|
84 if not initiator.accepted then
|
bsw@718
|
85 ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" }
|
bsw@718
|
86 end
|
bsw@718
|
87 end
|
bsw@718
|
88 end
|
bsw@718
|
89 }
|
bsw@718
|
90 end
|
bsw@718
|
91
|
bsw@718
|
92 if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@718
|
93 slot.put(" · ")
|
bsw@718
|
94 ui.link{
|
bsw@718
|
95 attr = { class = "action" },
|
bsw@718
|
96 content = function()
|
bsw@718
|
97 slot.put(_"Invite initiator")
|
bsw@718
|
98 end,
|
bsw@718
|
99 module = "initiative",
|
bsw@718
|
100 view = "add_initiator",
|
bsw@718
|
101 params = { initiative_id = initiative.id }
|
bsw@718
|
102 }
|
bsw@718
|
103 if #initiators > 1 then
|
bsw@718
|
104 slot.put(" · ")
|
bsw@718
|
105 ui.link{
|
bsw@718
|
106 content = function()
|
bsw@718
|
107 slot.put(_"Remove initiator")
|
bsw@718
|
108 end,
|
bsw@718
|
109 module = "initiative",
|
bsw@718
|
110 view = "remove_initiator",
|
bsw@718
|
111 params = { initiative_id = initiative.id }
|
bsw@718
|
112 }
|
bsw@718
|
113 end
|
bsw@718
|
114 end
|
bsw@718
|
115 if initiator and initiator.accepted == false then
|
bsw@718
|
116 slot.put(" · ")
|
bsw@718
|
117 ui.link{
|
bsw@718
|
118 text = _"Cancel refuse of invitation",
|
bsw@718
|
119 module = "initiative",
|
bsw@718
|
120 action = "remove_initiator",
|
bsw@718
|
121 params = {
|
bsw@718
|
122 initiative_id = initiative.id,
|
bsw@718
|
123 member_id = app.session.member.id
|
bsw@718
|
124 },
|
bsw@718
|
125 routing = {
|
bsw@718
|
126 ok = {
|
bsw@718
|
127 mode = "redirect",
|
bsw@718
|
128 module = "initiative",
|
bsw@718
|
129 view = "show",
|
bsw@718
|
130 id = initiative.id
|
bsw@718
|
131 }
|
bsw@718
|
132 }
|
bsw@718
|
133 }
|
bsw@718
|
134 end
|
bsw@718
|
135 end }
|
bsw@718
|
136 ui.container{ attr = { class = "content" }, content = function()
|
bsw@718
|
137 if app.session.member_id then
|
bsw@718
|
138 execute.view{
|
bsw@718
|
139 module = "supporter",
|
bsw@718
|
140 view = "_show_box",
|
bsw@718
|
141 params = {
|
bsw@718
|
142 initiative = initiative
|
bsw@718
|
143 }
|
bsw@718
|
144 }
|
bsw@718
|
145 end
|
bsw@718
|
146
|
bsw@718
|
147 end }
|
bsw@718
|
148
|
bsw@718
|
149
|
bsw@718
|
150 -- voting results
|
bsw@718
|
151 if initiative.issue.ranks_available and initiative.admitted then
|
bsw@718
|
152 local class = initiative.winner and "admitted_info" or "not_admitted_info"
|
bsw@718
|
153 ui.container{
|
bsw@718
|
154 attr = { class = class },
|
bsw@718
|
155 content = function()
|
bsw@718
|
156 local max_value = initiative.issue.voter_count
|
bsw@718
|
157 slot.put(" ")
|
bsw@718
|
158 local positive_votes = initiative.positive_votes
|
bsw@718
|
159 local negative_votes = initiative.negative_votes
|
bsw@718
|
160 local sum_votes = initiative.positive_votes + initiative.negative_votes
|
bsw@718
|
161 local function perc(votes, sum)
|
bsw@718
|
162 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
|
bsw@718
|
163 return ""
|
bsw@718
|
164 end
|
bsw@718
|
165 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
|
bsw@718
|
166 slot.put(" · ")
|
bsw@718
|
167 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
|
bsw@718
|
168 slot.put(" · ")
|
bsw@718
|
169 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
|
bsw@718
|
170 slot.put(" · ")
|
bsw@718
|
171 slot.put("<b>")
|
bsw@718
|
172 if initiative.winner then
|
bsw@718
|
173 slot.put(_"Approved")
|
bsw@718
|
174 elseif initiative.rank then
|
bsw@718
|
175 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
|
bsw@718
|
176 else
|
bsw@718
|
177 slot.put(_"Not approved")
|
bsw@718
|
178 end
|
bsw@718
|
179 slot.put("</b>")
|
bsw@718
|
180 end
|
bsw@718
|
181 }
|
bsw@718
|
182 end
|
bsw@718
|
183
|
bsw@718
|
184 ui.container{ attr = { class = "content" }, content = function()
|
bsw@718
|
185 execute.view{
|
bsw@718
|
186 module = "initiative",
|
bsw@718
|
187 view = "_battles",
|
bsw@718
|
188 params = { initiative = initiative }
|
bsw@718
|
189 }
|
bsw@718
|
190 end }
|
bsw@718
|
191
|
bsw@718
|
192 -- initiative not admitted info
|
bsw@718
|
193 if initiative.admitted == false then
|
bsw@718
|
194 local policy = initiative.issue.policy
|
bsw@718
|
195 ui.container{
|
bsw@718
|
196 attr = { class = "not_admitted_info" },
|
bsw@718
|
197 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
|
bsw@718
|
198 }
|
bsw@718
|
199 end
|
bsw@718
|
200
|
bsw@718
|
201 -- initiative revoked info
|
bsw@718
|
202 if initiative.revoked then
|
bsw@718
|
203 ui.container{
|
bsw@718
|
204 attr = { class = "revoked_info" },
|
bsw@718
|
205 content = function()
|
bsw@718
|
206 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
|
bsw@718
|
207 local suggested_initiative = initiative.suggested_initiative
|
bsw@718
|
208 if suggested_initiative then
|
bsw@718
|
209 slot.put("<br /><br />")
|
bsw@718
|
210 slot.put(_("The initiators suggest to support the following initiative:"))
|
bsw@718
|
211 slot.put(" ")
|
bsw@718
|
212 ui.link{
|
bsw@718
|
213 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
|
bsw@718
|
214 module = "initiative",
|
bsw@718
|
215 view = "show",
|
bsw@718
|
216 id = suggested_initiative.id
|
bsw@718
|
217 }
|
bsw@718
|
218 end
|
bsw@718
|
219 end
|
bsw@718
|
220 }
|
bsw@718
|
221 end
|
bsw@718
|
222
|
bsw@718
|
223
|
bsw@718
|
224 -- invited as initiator
|
bsw@718
|
225 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
|
bsw@718
|
226 ui.container{
|
bsw@718
|
227 attr = { class = "initiator_invite_info" },
|
bsw@718
|
228 content = function()
|
bsw@718
|
229 slot.put(_"You are invited to become initiator of this initiative.")
|
bsw@718
|
230 slot.put(" ")
|
bsw@718
|
231 ui.link{
|
bsw@718
|
232 image = { static = "icons/16/tick.png" },
|
bsw@718
|
233 text = _"Accept invitation",
|
bsw@718
|
234 module = "initiative",
|
bsw@718
|
235 action = "accept_invitation",
|
bsw@718
|
236 id = initiative.id,
|
bsw@718
|
237 routing = {
|
bsw@718
|
238 default = {
|
bsw@718
|
239 mode = "redirect",
|
bsw@718
|
240 module = request.get_module(),
|
bsw@718
|
241 view = request.get_view(),
|
bsw@718
|
242 id = param.get_id_cgi(),
|
bsw@718
|
243 params = param.get_all_cgi()
|
bsw@718
|
244 }
|
bsw@718
|
245 }
|
bsw@718
|
246 }
|
bsw@718
|
247 slot.put(" ")
|
bsw@718
|
248 ui.link{
|
bsw@718
|
249 image = { static = "icons/16/cross.png" },
|
bsw@718
|
250 text = _"Refuse invitation",
|
bsw@718
|
251 module = "initiative",
|
bsw@718
|
252 action = "reject_initiator_invitation",
|
bsw@718
|
253 params = {
|
bsw@718
|
254 initiative_id = initiative.id,
|
bsw@718
|
255 member_id = app.session.member.id
|
bsw@718
|
256 },
|
bsw@718
|
257 routing = {
|
bsw@718
|
258 default = {
|
bsw@718
|
259 mode = "redirect",
|
bsw@718
|
260 module = request.get_module(),
|
bsw@718
|
261 view = request.get_view(),
|
bsw@718
|
262 id = param.get_id_cgi(),
|
bsw@718
|
263 params = param.get_all_cgi()
|
bsw@718
|
264 }
|
bsw@718
|
265 }
|
bsw@718
|
266 }
|
bsw@718
|
267 end
|
bsw@718
|
268 }
|
bsw@718
|
269 end
|
bsw@718
|
270
|
bsw@718
|
271 -- draft updated
|
bsw@718
|
272 local supporter
|
bsw@718
|
273
|
bsw@718
|
274 if app.session.member_id then
|
bsw@718
|
275 supporter = app.session.member:get_reference_selector("supporters")
|
bsw@718
|
276 :add_where{ "initiative_id = ?", initiative.id }
|
bsw@718
|
277 :optional_object_mode()
|
bsw@718
|
278 :exec()
|
bsw@718
|
279 end
|
bsw@718
|
280
|
bsw@718
|
281 if supporter and not initiative.issue.closed then
|
bsw@718
|
282 local old_draft_id = supporter.draft_id
|
bsw@718
|
283 local new_draft_id = initiative.current_draft.id
|
bsw@718
|
284 if old_draft_id ~= new_draft_id then
|
bsw@718
|
285 ui.container{
|
bsw@718
|
286 attr = { class = "draft_updated_info" },
|
bsw@718
|
287 content = function()
|
bsw@718
|
288 slot.put(_"The draft of this initiative has been updated!")
|
bsw@718
|
289 slot.put(" ")
|
bsw@718
|
290 ui.link{
|
bsw@718
|
291 content = _"Show diff",
|
bsw@718
|
292 module = "draft",
|
bsw@718
|
293 view = "diff",
|
bsw@718
|
294 params = {
|
bsw@718
|
295 old_draft_id = old_draft_id,
|
bsw@718
|
296 new_draft_id = new_draft_id
|
bsw@718
|
297 }
|
bsw@718
|
298 }
|
bsw@718
|
299 if not initiative.revoked then
|
bsw@718
|
300 slot.put(" ")
|
bsw@718
|
301 ui.link{
|
bsw@718
|
302 text = _"Refresh support to current draft",
|
bsw@718
|
303 module = "initiative",
|
bsw@718
|
304 action = "add_support",
|
bsw@718
|
305 id = initiative.id,
|
bsw@718
|
306 routing = {
|
bsw@718
|
307 default = {
|
bsw@718
|
308 mode = "redirect",
|
bsw@718
|
309 module = "initiative",
|
bsw@718
|
310 view = "show",
|
bsw@718
|
311 id = initiative.id
|
bsw@718
|
312 }
|
bsw@718
|
313 }
|
bsw@718
|
314 }
|
bsw@718
|
315 end
|
bsw@718
|
316 end
|
bsw@718
|
317 }
|
bsw@718
|
318 end
|
bsw@718
|
319 end
|
bsw@718
|
320
|
bsw@718
|
321
|
bsw@718
|
322 execute.view{
|
bsw@718
|
323 module = "draft",
|
bsw@718
|
324 view = "_show",
|
bsw@718
|
325 params = {
|
bsw@718
|
326 draft = initiative.current_draft
|
bsw@718
|
327 }
|
bsw@718
|
328 }
|
bsw@718
|
329
|
bsw@718
|
330 end }
|
bsw@718
|
331
|
bsw@718
|
332 execute.view{
|
bsw@718
|
333 module = "suggestion",
|
bsw@718
|
334 view = "_list",
|
bsw@718
|
335 params = {
|
bsw@718
|
336 initiative = initiative,
|
bsw@718
|
337 suggestions_selector = initiative:get_reference_selector("suggestions"),
|
bsw@718
|
338 tab_id = param.get("tab_id")
|
bsw@718
|
339 }
|
bsw@718
|
340 }
|
bsw@718
|
341
|
bsw@718
|
342
|
bsw@718
|
343 if config.public_access == "full" or app.session.member_id then
|
bsw@718
|
344 if initiative.issue.ranks_available then
|
bsw@718
|
345 local members_selector = initiative.issue:get_reference_selector("direct_voters")
|
bsw@718
|
346 :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id })
|
bsw@718
|
347 :add_field("direct_voter.weight as voter_weight")
|
bsw@718
|
348 :add_field("coalesce(vote.grade, 0) as grade")
|
bsw@718
|
349 :left_join("initiative", nil, "initiative.id = vote.initiative_id")
|
bsw@718
|
350 :left_join("issue", nil, "issue.id = initiative.issue_id")
|
bsw@720
|
351
|
bsw@720
|
352 ui.anchor{ name = "voter", attr = { class = "heading" }, content = _"Member voter" }
|
bsw@718
|
353
|
bsw@718
|
354 execute.view{
|
bsw@718
|
355 module = "member",
|
bsw@718
|
356 view = "_list",
|
bsw@718
|
357 params = {
|
bsw@718
|
358 initiative = initiative,
|
bsw@718
|
359 for_votes = true,
|
bsw@720
|
360 members_selector = members_selector,
|
bsw@720
|
361 paginator_name = "voter"
|
bsw@718
|
362 }
|
bsw@718
|
363 }
|
bsw@718
|
364 end
|
bsw@718
|
365
|
bsw@718
|
366 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
|
bsw@718
|
367 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
|
bsw@718
|
368 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
|
bsw@718
|
369 :add_field("direct_interest_snapshot.weight")
|
bsw@718
|
370 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
|
bsw@718
|
371 :add_where("direct_supporter_snapshot.satisfied")
|
bsw@718
|
372 :add_field("direct_supporter_snapshot.informed", "is_informed")
|
bsw@718
|
373
|
bsw@718
|
374 if members_selector:count() > 0 then
|
bsw@718
|
375 if issue.fully_frozen then
|
bsw@720
|
376 ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters (before begin of voting)" }
|
bsw@718
|
377 else
|
bsw@720
|
378 ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters" }
|
bsw@718
|
379 end
|
bsw@718
|
380
|
bsw@718
|
381 execute.view{
|
bsw@718
|
382 module = "member",
|
bsw@718
|
383 view = "_list",
|
bsw@718
|
384 params = {
|
bsw@718
|
385 initiative = initiative,
|
bsw@720
|
386 members_selector = members_selector,
|
bsw@720
|
387 paginator_name = "supporters"
|
bsw@718
|
388 }
|
bsw@718
|
389 }
|
bsw@718
|
390 else
|
bsw@718
|
391 if issue.fully_frozen then
|
bsw@720
|
392 ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters (before begin of voting)" }
|
bsw@718
|
393 else
|
bsw@720
|
394 ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters" }
|
bsw@718
|
395 end
|
bsw@718
|
396 slot.put("<br />")
|
bsw@718
|
397 end
|
bsw@718
|
398
|
bsw@718
|
399 local members_selector = initiative:get_reference_selector("supporting_members_snapshot")
|
bsw@718
|
400 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
|
bsw@718
|
401 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
|
bsw@718
|
402 :add_field("direct_interest_snapshot.weight")
|
bsw@718
|
403 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
|
bsw@718
|
404 :add_where("NOT direct_supporter_snapshot.satisfied")
|
bsw@718
|
405 :add_field("direct_supporter_snapshot.informed", "is_informed")
|
bsw@718
|
406
|
bsw@718
|
407 if members_selector:count() > 0 then
|
bsw@718
|
408 if issue.fully_frozen then
|
bsw@720
|
409 ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters (before begin of voting)" }
|
bsw@718
|
410 else
|
bsw@720
|
411 ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters" }
|
bsw@718
|
412 end
|
bsw@718
|
413
|
bsw@718
|
414 execute.view{
|
bsw@718
|
415 module = "member",
|
bsw@718
|
416 view = "_list",
|
bsw@718
|
417 params = {
|
bsw@718
|
418 initiative = initiative,
|
bsw@720
|
419 members_selector = members_selector,
|
bsw@720
|
420 paginator_name = "potential_supporters"
|
bsw@718
|
421 }
|
bsw@718
|
422 }
|
bsw@718
|
423 else
|
bsw@718
|
424 if issue.fully_frozen then
|
bsw@720
|
425 ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters (before begin of voting)" }
|
bsw@718
|
426 else
|
bsw@720
|
427 ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters" }
|
bsw@718
|
428 end
|
bsw@718
|
429 slot.put("<br />")
|
bsw@718
|
430 end
|
bsw@718
|
431
|
bsw@720
|
432 ui.container{ attr = { class = "heading" }, content = _"Details" }
|
bsw@718
|
433 execute.view {
|
bsw@718
|
434 module = "initiative",
|
bsw@718
|
435 view = "_details",
|
bsw@718
|
436 params = {
|
bsw@718
|
437 initiative = initiative,
|
bsw@718
|
438 members_selector = members_selector
|
bsw@718
|
439 }
|
bsw@718
|
440 }
|
bsw@718
|
441
|
bsw@718
|
442 end
|