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