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@525
|
130 end }
|
bsw@313
|
131
|
bsw@313
|
132
|
bsw/jbe@19
|
133 util.help("initiative.show")
|
bsw/jbe@19
|
134
|
bsw@525
|
135 --slot.select("initiative_head", function()
|
bsw@272
|
136
|
bsw@493
|
137 if initiative.issue.ranks_available and initiative.admitted then
|
bsw@493
|
138 local class = initiative.winner and "admitted_info" or "not_admitted_info"
|
bsw@493
|
139 ui.container{
|
bsw@493
|
140 attr = { class = class },
|
bsw@493
|
141 content = function()
|
bsw@493
|
142 local max_value = initiative.issue.voter_count
|
bsw@493
|
143 slot.put(" ")
|
bsw@493
|
144 local positive_votes = initiative.positive_votes
|
bsw@493
|
145 local negative_votes = initiative.negative_votes
|
bsw@493
|
146 local sum_votes = initiative.positive_votes + initiative.negative_votes
|
bsw@493
|
147 local function perc(votes, sum)
|
bsw@493
|
148 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
|
bsw@493
|
149 return ""
|
bsw@493
|
150 end
|
bsw@493
|
151 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
|
bsw@493
|
152 slot.put(" · ")
|
bsw@493
|
153 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
|
bsw@493
|
154 slot.put(" · ")
|
bsw@493
|
155 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
|
bsw@493
|
156 slot.put(" · ")
|
bsw@493
|
157 slot.put("<b>")
|
bsw@493
|
158 if initiative.winner then
|
bsw@493
|
159 slot.put(_"Approved")
|
bsw@493
|
160 elseif initiative.rank then
|
bsw@493
|
161 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
|
bsw@493
|
162 else
|
bsw@493
|
163 slot.put(_"Not approved")
|
bsw@493
|
164 end
|
bsw@493
|
165 slot.put("</b>")
|
poelzi@167
|
166 end
|
bsw@493
|
167 }
|
bsw@493
|
168 end
|
bsw/jbe@19
|
169
|
bsw@493
|
170 if initiative.admitted == false then
|
bsw@493
|
171 local policy = initiative.issue.policy
|
bsw@493
|
172 ui.container{
|
bsw@493
|
173 attr = { class = "not_admitted_info" },
|
bsw@493
|
174 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
|
175 }
|
bsw@493
|
176 end
|
bsw/jbe@19
|
177
|
bsw@493
|
178 if initiative.revoked then
|
bsw@493
|
179 ui.container{
|
bsw@493
|
180 attr = { class = "revoked_info" },
|
bsw@493
|
181 content = function()
|
bsw@493
|
182 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
|
bsw@493
|
183 local suggested_initiative = initiative.suggested_initiative
|
bsw@493
|
184 if suggested_initiative then
|
bsw@493
|
185 slot.put("<br /><br />")
|
bsw@493
|
186 slot.put(_("The initiators suggest to support the following initiative:"))
|
bsw@493
|
187 slot.put(" ")
|
bsw@493
|
188 ui.link{
|
bsw@493
|
189 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
|
bsw@493
|
190 module = "initiative",
|
bsw@493
|
191 view = "show",
|
bsw@493
|
192 id = suggested_initiative.id
|
bsw@493
|
193 }
|
bsw@493
|
194 end
|
bsw/jbe@19
|
195 end
|
bsw@493
|
196 }
|
bsw@493
|
197 end
|
bsw@493
|
198
|
bsw@525
|
199 --end)
|
bsw/jbe@19
|
200
|
bsw@41
|
201 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
|
bsw/jbe@19
|
202 ui.container{
|
bsw/jbe@19
|
203 attr = { class = "initiator_invite_info" },
|
bsw/jbe@19
|
204 content = function()
|
bsw/jbe@19
|
205 slot.put(_"You are invited to become initiator of this initiative.")
|
bsw/jbe@19
|
206 slot.put(" ")
|
bsw/jbe@19
|
207 ui.link{
|
bsw/jbe@19
|
208 image = { static = "icons/16/tick.png" },
|
bsw/jbe@19
|
209 text = _"Accept invitation",
|
bsw/jbe@19
|
210 module = "initiative",
|
bsw/jbe@19
|
211 action = "accept_invitation",
|
bsw/jbe@19
|
212 id = initiative.id,
|
bsw/jbe@19
|
213 routing = {
|
bsw/jbe@19
|
214 default = {
|
bsw/jbe@19
|
215 mode = "redirect",
|
bsw/jbe@19
|
216 module = request.get_module(),
|
bsw/jbe@19
|
217 view = request.get_view(),
|
bsw/jbe@19
|
218 id = param.get_id_cgi(),
|
bsw/jbe@19
|
219 params = param.get_all_cgi()
|
bsw/jbe@19
|
220 }
|
bsw/jbe@19
|
221 }
|
bsw/jbe@19
|
222 }
|
bsw/jbe@19
|
223 slot.put(" ")
|
bsw/jbe@19
|
224 ui.link{
|
bsw/jbe@19
|
225 image = { static = "icons/16/cross.png" },
|
bsw/jbe@19
|
226 text = _"Refuse invitation",
|
bsw/jbe@19
|
227 module = "initiative",
|
bsw/jbe@19
|
228 action = "reject_initiator_invitation",
|
bsw/jbe@19
|
229 params = {
|
bsw/jbe@19
|
230 initiative_id = initiative.id,
|
bsw/jbe@19
|
231 member_id = app.session.member.id
|
bsw/jbe@19
|
232 },
|
bsw/jbe@19
|
233 routing = {
|
bsw/jbe@19
|
234 default = {
|
bsw/jbe@19
|
235 mode = "redirect",
|
bsw/jbe@19
|
236 module = request.get_module(),
|
bsw/jbe@19
|
237 view = request.get_view(),
|
bsw/jbe@19
|
238 id = param.get_id_cgi(),
|
bsw/jbe@19
|
239 params = param.get_all_cgi()
|
bsw/jbe@19
|
240 }
|
bsw/jbe@19
|
241 }
|
bsw/jbe@19
|
242 }
|
bsw/jbe@19
|
243 end
|
bsw/jbe@19
|
244 }
|
bsw/jbe@19
|
245 slot.put("<br />")
|
bsw/jbe@19
|
246 end
|
bsw/jbe@19
|
247
|
bsw/jbe@19
|
248
|
bsw@51
|
249 local supporter
|
bsw@51
|
250
|
bsw@51
|
251 if app.session.member_id then
|
bsw@51
|
252 supporter = app.session.member:get_reference_selector("supporters")
|
bsw@51
|
253 :add_where{ "initiative_id = ?", initiative.id }
|
bsw@51
|
254 :optional_object_mode()
|
bsw@51
|
255 :exec()
|
bsw@51
|
256 end
|
bsw/jbe@19
|
257
|
bsw/jbe@19
|
258 if supporter and not initiative.issue.closed then
|
bsw/jbe@19
|
259 local old_draft_id = supporter.draft_id
|
bsw/jbe@19
|
260 local new_draft_id = initiative.current_draft.id
|
bsw/jbe@19
|
261 if old_draft_id ~= new_draft_id then
|
bsw/jbe@19
|
262 ui.container{
|
bsw/jbe@19
|
263 attr = { class = "draft_updated_info" },
|
bsw/jbe@19
|
264 content = function()
|
bsw/jbe@19
|
265 slot.put(_"The draft of this initiative has been updated!")
|
bsw/jbe@19
|
266 slot.put(" ")
|
bsw/jbe@19
|
267 ui.link{
|
bsw/jbe@19
|
268 content = _"Show diff",
|
bsw/jbe@19
|
269 module = "draft",
|
bsw/jbe@19
|
270 view = "diff",
|
bsw/jbe@19
|
271 params = {
|
bsw/jbe@19
|
272 old_draft_id = old_draft_id,
|
bsw/jbe@19
|
273 new_draft_id = new_draft_id
|
bsw/jbe@19
|
274 }
|
bsw/jbe@19
|
275 }
|
bsw@75
|
276 if not initiative.revoked then
|
bsw@75
|
277 slot.put(" ")
|
bsw@75
|
278 ui.link{
|
bsw@75
|
279 text = _"Refresh support to current draft",
|
bsw@75
|
280 module = "initiative",
|
bsw@75
|
281 action = "add_support",
|
bsw@75
|
282 id = initiative.id,
|
bsw@75
|
283 routing = {
|
bsw@75
|
284 default = {
|
bsw@75
|
285 mode = "redirect",
|
bsw@75
|
286 module = "initiative",
|
bsw@75
|
287 view = "show",
|
bsw@75
|
288 id = initiative.id
|
bsw@75
|
289 }
|
bsw/jbe@19
|
290 }
|
bsw/jbe@19
|
291 }
|
bsw@75
|
292 end
|
bsw/jbe@19
|
293 end
|
bsw/jbe@19
|
294 }
|
bsw/jbe@19
|
295 end
|
bsw/jbe@19
|
296 end
|
bsw/jbe@19
|
297
|
bsw/jbe@19
|
298 execute.view{
|
bsw/jbe@19
|
299 module = "initiative",
|
bsw/jbe@19
|
300 view = "show_tab",
|
bsw/jbe@19
|
301 params = {
|
bsw/jbe@19
|
302 initiative = initiative,
|
bsw/jbe@19
|
303 initiator = initiator
|
bsw/jbe@19
|
304 }
|
bsw/jbe@19
|
305 }
|
bsw/jbe@19
|
306
|
bsw@280
|
307 if initiative.issue.snapshot then
|
bsw@431
|
308 slot.put("<br />")
|
bsw@280
|
309 ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot }
|
bsw@280
|
310 end
|
bsw@280
|
311
|
bsw@280
|
312
|
bsw@286
|
313
|