liquid_feedback_frontend
view app/main/initiative/_show.lua @ 92:42547a48774d
Fixed locking in add/remove interest action
author | bsw |
---|---|
date | Thu Aug 19 15:36:39 2010 +0200 (2010-08-19) |
parents | 733f65c0c0a0 |
children | a9ea02807b94 |
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(" · ")
17 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
18 slot.put(" · ")
19 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. "</b>")
20 slot.put(" · ")
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 if not initiative.revoked then
151 slot.put(" ")
152 ui.link{
153 text = _"Refresh support to current draft",
154 module = "initiative",
155 action = "add_support",
156 id = initiative.id,
157 routing = {
158 default = {
159 mode = "redirect",
160 module = "initiative",
161 view = "show",
162 id = initiative.id
163 }
164 }
165 }
166 end
167 end
168 }
169 end
170 end
173 if app.session.member_id then
174 ui.container{
175 attr = {
176 id = "initiative_" .. tostring(initiative.id) .. "_support"
177 },
178 content = function()
179 execute.view{
180 module = "initiative",
181 view = "show_support",
182 params = {
183 initiative = initiative
184 }
185 }
186 end
187 }
188 end
190 if (initiative.discussion_url and #initiative.discussion_url > 0)
191 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
192 ui.container{
193 attr = { class = "vertical" },
194 content = function()
195 ui.container{
196 attr = { class = "ui_field_label" },
197 content = _"Discussion with initiators"
198 }
199 ui.tag{
200 tag = "span",
201 content = function()
202 if initiative.discussion_url:find("^https?://") then
203 if initiative.discussion_url and #initiative.discussion_url > 0 then
204 ui.link{
205 attr = {
206 class = "actions",
207 target = "_blank",
208 title = initiative.discussion_url
209 },
210 content = function()
211 slot.put(encode.html(initiative.discussion_url))
212 end,
213 external = initiative.discussion_url
214 }
215 end
216 else
217 slot.put(encode.html(initiative.discussion_url))
218 end
219 slot.put(" ")
220 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
221 ui.link{
222 attr = { class = "actions" },
223 text = _"(change URL)",
224 module = "initiative",
225 view = "edit",
226 id = initiative.id
227 }
228 end
229 end
230 }
231 end
232 }
233 end
237 execute.view{
238 module = "initiative",
239 view = "show_tab",
240 params = {
241 initiative = initiative,
242 initiator = initiator
243 }
244 }