liquid_feedback_frontend
view app/main/initiative/show.lua @ 9:0ee1e0c42d4c
Version beta5
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
author | bsw |
---|---|
date | Mon Jan 04 12:00:00 2010 +0100 (2010-01-04) |
parents | 8d91bccab0bf |
children | 72c5e0ee7c98 |
line source
1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
3 slot.select("actions", function()
4 ui.link{
5 content = function()
6 ui.image{ static = "icons/16/script.png" }
7 slot.put(_"Show all initiatives")
8 end,
9 module = "issue",
10 view = "show",
11 id = initiative.issue.id
12 }
13 end)
15 execute.view{
16 module = "issue",
17 view = "_show_head",
18 params = { issue = initiative.issue }
19 }
21 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
23 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
25 execute.view{
26 module = "supporter",
27 view = "_show_box",
28 params = { initiative = initiative }
29 }
31 slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
33 slot.select("actions", function()
34 if not initiative.issue.fully_frozen and not initiative.issue.closed then
35 ui.link{
36 attr = { class = "action" },
37 content = function()
38 ui.image{ static = "icons/16/script_add.png" }
39 slot.put(_"Create alternative initiative")
40 end,
41 module = "initiative",
42 view = "new",
43 params = { issue_id = initiative.issue.id }
44 }
45 end
46 end)
49 util.help("initiative.show")
52 ui.container{
53 attr = { class = "vertical" },
54 content = function()
55 ui.container{
56 attr = { class = "ui_field_label" },
57 content = _"Discussion URL"
58 }
59 ui.tag{
60 tag = "span",
61 content = function()
62 if initiative.discussion_url and #initiative.discussion_url > 0 then
63 ui.link{
64 attr = {
65 class = "actions",
66 target = "_blank",
67 title = initiative.discussion_url
68 },
69 content = function()
70 slot.put(encode.html(initiative.discussion_url))
71 end,
72 external = initiative.discussion_url
73 }
74 end
75 slot.put(" ")
76 if initiator then
77 ui.link{
78 attr = { class = "actions" },
79 content = _"(change URL)",
80 module = "initiative",
81 view = "edit",
82 id = initiative.id
83 }
84 end
85 end
86 }
87 end
88 }
92 ui.container{
93 attr = { id = "add_suggestion_form", class = "hidden_inline_form" },
94 content = function()
96 ui.link{
97 content = _"Close",
98 attr = {
99 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)",
100 style = "float: right;"
101 }
102 }
104 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" }
107 ui.form{
108 module = "suggestion",
109 action = "add",
110 params = { initiative_id = initiative.id },
111 routing = {
112 default = {
113 mode = "redirect",
114 module = "initiative",
115 view = "show",
116 id = initiative.id,
117 params = { tab = "suggestion" }
118 }
119 },
120 attr = { class = "vertical" },
121 content = function()
122 local supported = Supporter:by_pk(initiative.id, app.session.member.id) and true or false
123 if not supported then
124 ui.field.text{
125 attr = { class = "warning" },
126 value = _"You are currently not supporting this initiative. By adding suggestions to this initiative you will automatically become a potential supporter."
127 }
128 end
129 ui.field.text{ label = _"Title (80 chars max)", name = "name" }
130 ui.field.text{ label = _"Description", name = "description", multiline = true }
131 ui.field.select{
132 label = _"Degree",
133 name = "degree",
134 foreign_records = {
135 { id = 1, name = _"should"},
136 { id = 2, name = _"must"},
137 },
138 foreign_id = "id",
139 foreign_name = "name"
140 }
141 ui.submit{ text = _"Commit suggestion" }
142 end
143 }
144 end
145 }
147 local supporter = app.session.member:get_reference_selector("supporters")
148 :add_where{ "initiative_id = ?", initiative.id }
149 :optional_object_mode()
150 :exec()
152 if supporter then
153 local old_draft_id = supporter.draft_id
154 local new_draft_id = initiative.current_draft.id
155 if old_draft_id ~= new_draft_id then
156 ui.container{
157 attr = { class = "draft_updated_info" },
158 content = function()
159 slot.put("The draft of this initiative has been updated!")
160 slot.put(" ")
161 ui.link{
162 content = _"Show diff",
163 module = "draft",
164 view = "diff",
165 params = {
166 old_draft_id = old_draft_id,
167 new_draft_id = new_draft_id
168 }
169 }
170 slot.put(" ")
171 ui.link{
172 content = _"Refresh support to current draft",
173 module = "initiative",
174 action = "add_support",
175 id = initiative.id,
176 routing = {
177 default = {
178 mode = "redirect",
179 module = "initiative",
180 view = "show",
181 id = initiative.id
182 }
183 }
184 }
185 end
186 }
187 end
188 end
191 local current_draft_name = _"Current draft"
192 if initiative.issue.half_frozen then
193 current_draft_name = _"Voting proposal"
194 end
196 if initiative.issue.state == "finished" then
197 current_draft_name = _"Voted proposal"
198 end
200 local tabs = {
201 {
202 name = "current_draft",
203 label = current_draft_name,
204 content = function()
205 if initiator then
206 ui.link{
207 content = function()
208 ui.image{ static = "icons/16/script_add.png" }
209 slot.put(_"Edit draft")
210 end,
211 module = "draft",
212 view = "new",
213 params = { initiative_id = initiative.id }
214 }
215 end
216 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
217 end
218 }
219 }
221 if initiative.issue.ranks_available then
222 tabs[#tabs+1] = {
223 name = "voter",
224 label = _"Voter",
225 content = function()
226 execute.view{
227 module = "member",
228 view = "_list",
229 params = {
230 initiative = initiative,
231 members_selector = initiative.issue:get_reference_selector("direct_voters")
232 :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id })
233 :add_field("direct_voter.weight as voter_weight")
234 :add_field("coalesce(vote.grade, 0) as grade")
235 }
236 }
237 end
238 }
239 end
241 tabs[#tabs+1] = {
242 name = "suggestion",
243 label = _"Suggestions",
244 content = function()
245 execute.view{
246 module = "suggestion",
247 view = "_list",
248 params = {
249 initiative = initiative,
250 suggestions_selector = initiative:get_reference_selector("suggestions")
251 }
252 }
253 slot.put("<br />")
254 if not initiative.issue.fully_frozen and not initiative.issue.closed then
255 ui.link{
256 content = function()
257 ui.image{ static = "icons/16/comment_add.png" }
258 slot.put(_"Add new suggestion")
259 end,
260 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
261 static = "#"
262 }
263 end
264 end
265 }
267 tabs[#tabs+1] = {
268 name = "satisfied_supporter",
269 label = _"Supporter",
270 content = function()
271 execute.view{
272 module = "member",
273 view = "_list",
274 params = {
275 initiative = initiative,
276 members_selector = initiative:get_reference_selector("supporting_members_snapshot")
277 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
278 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
279 :add_field("direct_interest_snapshot.weight")
280 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
281 :add_where("direct_supporter_snapshot.satisfied")
282 }
283 }
284 end
285 }
287 tabs[#tabs+1] = {
288 name = "supporter",
289 label = _"Potential supporter",
290 content = function()
291 execute.view{
292 module = "member",
293 view = "_list",
294 params = {
295 initiative = initiative,
296 members_selector = initiative:get_reference_selector("supporting_members_snapshot")
297 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
298 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id")
299 :add_field("direct_interest_snapshot.weight")
300 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
301 :add_where("NOT direct_supporter_snapshot.satisfied")
302 }
303 }
304 end
305 }
307 tabs[#tabs+1] = {
308 name = "initiators",
309 label = _"Initiators",
310 content = function()
311 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
312 end
313 }
315 tabs[#tabs+1] = {
316 name = "drafts",
317 label = _"Old drafts",
318 content = function()
319 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
320 end
321 }
323 tabs[#tabs+1] = {
324 name = "details",
325 label = _"Details",
326 content = function()
327 ui.form{
328 attr = { class = "vertical" },
329 record = initiative,
330 readonly = true,
331 content = function()
332 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
333 ui.field.text{
334 label = _"Created at",
335 value = tostring(initiative.created)
336 }
337 ui.field.text{
338 label = _"Created at",
339 value = format.timestamp(initiative.created)
340 }
341 ui.field.date{ label = _"Revoked at", name = "revoked" }
342 ui.field.boolean{ label = _"Admitted", name = "admitted" }
343 end
344 }
345 end
346 }
349 ui.tabs(tabs)