liquid_feedback_frontend

view app/main/initiative/_show.lua @ 51:0849be391140

Public read access; Read-only API for initiatives; Prepared integration of OpenID
author bsw
date Sun Apr 04 22:05:11 2010 +0200 (2010-04-04)
parents 53a45356c107
children 733f65c0c0a0
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 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. "</b>")
16 slot.put(" &middot; ")
17 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
18 slot.put(" &middot; ")
19 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. "</b>")
20 slot.put(" &middot; ")
21 slot.put("<b>")
22 if initiative.rank == 1 then
23 slot.put(_"Approved")
24 elseif initiative.rank then
25 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
26 else
27 slot.put(_"Not approved")
28 end
29 slot.put("</b>")
30 end
31 }
32 end
34 if initiative.admitted == false then
35 local policy = initiative.issue.policy
36 ui.container{
37 attr = { class = "not_admitted_info" },
38 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
39 }
40 end
42 local web20 = config.user_tab_mode == "accordeon"
43 or config.user_tab_mode == "accordeon_first_expanded"
44 or config.user_tab_mode == "accordeon_all_expanded"
46 if not web20 and initiative.issue.state == "cancelled" then
47 local policy = initiative.issue.policy
48 ui.container{
49 attr = { class = "not_admitted_info" },
50 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
51 }
52 end
54 if initiative.revoked then
55 ui.container{
56 attr = { class = "revoked_info" },
57 content = function()
58 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
59 local suggested_initiative = initiative.suggested_initiative
60 if suggested_initiative then
61 slot.put("<br /><br />")
62 slot.put(_("The initiators suggest to support the following initiative:"))
63 slot.put(" ")
64 ui.link{
65 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
66 module = "initiative",
67 view = "show",
68 id = suggested_initiative.id
69 }
70 end
71 end
72 }
73 end
75 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
76 ui.container{
77 attr = { class = "initiator_invite_info" },
78 content = function()
79 slot.put(_"You are invited to become initiator of this initiative.")
80 slot.put(" ")
81 ui.link{
82 image = { static = "icons/16/tick.png" },
83 text = _"Accept invitation",
84 module = "initiative",
85 action = "accept_invitation",
86 id = initiative.id,
87 routing = {
88 default = {
89 mode = "redirect",
90 module = request.get_module(),
91 view = request.get_view(),
92 id = param.get_id_cgi(),
93 params = param.get_all_cgi()
94 }
95 }
96 }
97 slot.put(" ")
98 ui.link{
99 image = { static = "icons/16/cross.png" },
100 text = _"Refuse invitation",
101 module = "initiative",
102 action = "reject_initiator_invitation",
103 params = {
104 initiative_id = initiative.id,
105 member_id = app.session.member.id
106 },
107 routing = {
108 default = {
109 mode = "redirect",
110 module = request.get_module(),
111 view = request.get_view(),
112 id = param.get_id_cgi(),
113 params = param.get_all_cgi()
114 }
115 }
116 }
117 end
118 }
119 slot.put("<br />")
120 end
123 local supporter
125 if app.session.member_id then
126 supporter = app.session.member:get_reference_selector("supporters")
127 :add_where{ "initiative_id = ?", initiative.id }
128 :optional_object_mode()
129 :exec()
130 end
132 if supporter and not initiative.issue.closed then
133 local old_draft_id = supporter.draft_id
134 local new_draft_id = initiative.current_draft.id
135 if old_draft_id ~= new_draft_id then
136 ui.container{
137 attr = { class = "draft_updated_info" },
138 content = function()
139 slot.put(_"The draft of this initiative has been updated!")
140 slot.put(" ")
141 ui.link{
142 content = _"Show diff",
143 module = "draft",
144 view = "diff",
145 params = {
146 old_draft_id = old_draft_id,
147 new_draft_id = new_draft_id
148 }
149 }
150 slot.put(" ")
151 ui.link{
152 text = _"Refresh support to current draft",
153 module = "initiative",
154 action = "add_support",
155 id = initiative.id,
156 routing = {
157 default = {
158 mode = "redirect",
159 module = "initiative",
160 view = "show",
161 id = initiative.id
162 }
163 }
164 }
165 end
166 }
167 end
168 end
171 if app.session.member_id then
172 ui.container{
173 attr = {
174 id = "initiative_" .. tostring(initiative.id) .. "_support"
175 },
176 content = function()
177 execute.view{
178 module = "initiative",
179 view = "show_support",
180 params = {
181 initiative = initiative
182 }
183 }
184 end
185 }
186 end
188 if (initiative.discussion_url and #initiative.discussion_url > 0)
189 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
190 ui.container{
191 attr = { class = "vertical" },
192 content = function()
193 ui.container{
194 attr = { class = "ui_field_label" },
195 content = _"Discussion with initiators"
196 }
197 ui.tag{
198 tag = "span",
199 content = function()
200 if initiative.discussion_url:find("^https?://") then
201 if initiative.discussion_url and #initiative.discussion_url > 0 then
202 ui.link{
203 attr = {
204 class = "actions",
205 target = "_blank",
206 title = initiative.discussion_url
207 },
208 content = function()
209 slot.put(encode.html(initiative.discussion_url))
210 end,
211 external = initiative.discussion_url
212 }
213 end
214 else
215 slot.put(encode.html(initiative.discussion_url))
216 end
217 slot.put(" ")
218 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
219 ui.link{
220 attr = { class = "actions" },
221 text = _"(change URL)",
222 module = "initiative",
223 view = "edit",
224 id = initiative.id
225 }
226 end
227 end
228 }
229 end
230 }
231 end
235 execute.view{
236 module = "initiative",
237 view = "show_tab",
238 params = {
239 initiative = initiative,
240 initiator = initiator
241 }
242 }

Impressum / About Us