liquid_feedback_frontend

view app/main/initiative/_show.lua @ 231:068ad175ebd7

Added "Chrome" to browser warning text
author jbe
date Thu Oct 06 16:26:43 2011 +0200 (2011-10-06)
parents 1fdf1e607494
children 65a1f7a01e7b
line source
1 local initiative = param.get("initiative", "table")
2 local initiator = param.get("initiator", "table")
4 util.help("initiative.show")
6 if initiative.issue.ranks_available and initiative.admitted then
7 local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
8 ui.container{
9 attr = { class = class },
10 content = function()
11 local max_value = initiative.issue.voter_count
12 slot.put(" ")
13 local positive_votes = initiative.positive_votes
14 local negative_votes = initiative.negative_votes
15 local sum_votes = initiative.positive_votes + initiative.negative_votes
16 local function perc(votes, sum)
17 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
18 return ""
19 end
20 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
21 slot.put(" &middot; ")
22 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
23 slot.put(" &middot; ")
24 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
25 slot.put(" &middot; ")
26 slot.put("<b>")
27 if initiative.rank == 1 then
28 slot.put(_"Approved")
29 elseif initiative.rank then
30 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
31 else
32 slot.put(_"Not approved")
33 end
34 slot.put("</b>")
35 end
36 }
37 end
39 if initiative.admitted == false then
40 local policy = initiative.issue.policy
41 ui.container{
42 attr = { class = "not_admitted_info" },
43 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
44 }
45 end
47 local web20 = config.user_tab_mode == "accordeon"
48 or config.user_tab_mode == "accordeon_first_expanded"
49 or config.user_tab_mode == "accordeon_all_expanded"
51 if not web20 and initiative.issue.state == "cancelled" then
52 local policy = initiative.issue.policy
53 ui.container{
54 attr = { class = "not_admitted_info" },
55 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
56 }
57 end
59 if initiative.revoked then
60 ui.container{
61 attr = { class = "revoked_info" },
62 content = function()
63 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
64 local suggested_initiative = initiative.suggested_initiative
65 if suggested_initiative then
66 slot.put("<br /><br />")
67 slot.put(_("The initiators suggest to support the following initiative:"))
68 slot.put(" ")
69 ui.link{
70 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
71 module = "initiative",
72 view = "show",
73 id = suggested_initiative.id
74 }
75 end
76 end
77 }
78 end
80 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
81 ui.container{
82 attr = { class = "initiator_invite_info" },
83 content = function()
84 slot.put(_"You are invited to become initiator of this initiative.")
85 slot.put(" ")
86 ui.link{
87 image = { static = "icons/16/tick.png" },
88 text = _"Accept invitation",
89 module = "initiative",
90 action = "accept_invitation",
91 id = initiative.id,
92 routing = {
93 default = {
94 mode = "redirect",
95 module = request.get_module(),
96 view = request.get_view(),
97 id = param.get_id_cgi(),
98 params = param.get_all_cgi()
99 }
100 }
101 }
102 slot.put(" ")
103 ui.link{
104 image = { static = "icons/16/cross.png" },
105 text = _"Refuse invitation",
106 module = "initiative",
107 action = "reject_initiator_invitation",
108 params = {
109 initiative_id = initiative.id,
110 member_id = app.session.member.id
111 },
112 routing = {
113 default = {
114 mode = "redirect",
115 module = request.get_module(),
116 view = request.get_view(),
117 id = param.get_id_cgi(),
118 params = param.get_all_cgi()
119 }
120 }
121 }
122 end
123 }
124 slot.put("<br />")
125 end
128 local supporter
130 if app.session.member_id then
131 supporter = app.session.member:get_reference_selector("supporters")
132 :add_where{ "initiative_id = ?", initiative.id }
133 :optional_object_mode()
134 :exec()
135 end
137 if supporter and not initiative.issue.closed then
138 local old_draft_id = supporter.draft_id
139 local new_draft_id = initiative.current_draft.id
140 if old_draft_id ~= new_draft_id then
141 ui.container{
142 attr = { class = "draft_updated_info" },
143 content = function()
144 slot.put(_"The draft of this initiative has been updated!")
145 slot.put(" ")
146 ui.link{
147 content = _"Show diff",
148 module = "draft",
149 view = "diff",
150 params = {
151 old_draft_id = old_draft_id,
152 new_draft_id = new_draft_id
153 }
154 }
155 if not initiative.revoked then
156 slot.put(" ")
157 ui.link{
158 text = _"Refresh support to current draft",
159 module = "initiative",
160 action = "add_support",
161 id = initiative.id,
162 routing = {
163 default = {
164 mode = "redirect",
165 module = "initiative",
166 view = "show",
167 id = initiative.id
168 }
169 }
170 }
171 end
172 end
173 }
174 end
175 end
178 if app.session.member_id then
179 ui.container{
180 attr = {
181 id = "initiative_" .. tostring(initiative.id) .. "_support"
182 },
183 content = function()
184 execute.view{
185 module = "initiative",
186 view = "show_support",
187 params = {
188 initiative = initiative
189 }
190 }
191 end
192 }
193 end
195 if (initiative.discussion_url and #initiative.discussion_url > 0)
196 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
197 ui.container{
198 attr = { class = "vertical" },
199 content = function()
200 ui.container{
201 attr = { class = "ui_field_label" },
202 content = _"Discussion with initiators"
203 }
204 ui.tag{
205 tag = "span",
206 content = function()
207 if initiative.discussion_url:find("^https?://") then
208 if initiative.discussion_url and #initiative.discussion_url > 0 then
209 ui.link{
210 attr = {
211 class = "actions",
212 target = "_blank",
213 title = initiative.discussion_url
214 },
215 content = function()
216 slot.put(encode.html(initiative.discussion_url))
217 end,
218 external = initiative.discussion_url
219 }
220 end
221 else
222 slot.put(encode.html(initiative.discussion_url))
223 end
224 slot.put(" ")
225 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
226 ui.link{
227 attr = { class = "actions" },
228 text = _"(change URL)",
229 module = "initiative",
230 view = "edit",
231 id = initiative.id
232 }
233 end
234 end
235 }
236 end
237 }
238 end
242 execute.view{
243 module = "initiative",
244 view = "show_tab",
245 params = {
246 initiative = initiative,
247 initiator = initiator
248 }
249 }

Impressum / About Us