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