liquid_feedback_frontend
diff app/main/initiative/show.lua @ 10:72c5e0ee7c98
Version beta6
Bugfixes:
- Security fix: Every user was able to change the discussion URL of an initiative
- Creation of new issues in areas without default policies is now possible
- Members can now be sorted in different ways
- No error when trying to compare a draft with itself
- Added missing local statement to variable initialization in app/main/delegation/new.lua
- CSS flaw in initiative action bar fixed
New features:
- Possiblity to invite other users to become initiator
- Revokation of initiatives implemented
- Number of suggestions, supporters, etc. is shown on corresponding tabs of initiative view
- Members can now be sorted by account creation (default sorting is "newest first")
- Configuration option to create an automatic discussion link for all issues
- First draft of global timeline feature (not accessible via link yet)
- Custom stylesheet URL for users marked as developers
In area listing the number of closed issues is shown too
Renamed "author" field of initiative to "last author"
Removed wrongly included file app/main/member/_show_thumb.lua.orig in the distribution
Help texts updated
Bugfixes:
- Security fix: Every user was able to change the discussion URL of an initiative
- Creation of new issues in areas without default policies is now possible
- Members can now be sorted in different ways
- No error when trying to compare a draft with itself
- Added missing local statement to variable initialization in app/main/delegation/new.lua
- CSS flaw in initiative action bar fixed
New features:
- Possiblity to invite other users to become initiator
- Revokation of initiatives implemented
- Number of suggestions, supporters, etc. is shown on corresponding tabs of initiative view
- Members can now be sorted by account creation (default sorting is "newest first")
- Configuration option to create an automatic discussion link for all issues
- First draft of global timeline feature (not accessible via link yet)
- Custom stylesheet URL for users marked as developers
In area listing the number of closed issues is shown too
Renamed "author" field of initiative to "last author"
Removed wrongly included file app/main/member/_show_thumb.lua.orig in the distribution
Help texts updated
author | bsw |
---|---|
date | Sun Jan 10 12:00:00 2010 +0100 (2010-01-10) |
parents | 8d91bccab0bf |
children | 77d58efe99fd |
line diff
1.1 --- a/app/main/initiative/show.lua Mon Jan 04 12:00:00 2010 +0100 1.2 +++ b/app/main/initiative/show.lua Sun Jan 10 12:00:00 2010 +0100 1.3 @@ -18,17 +18,31 @@ 1.4 params = { issue = initiative.issue } 1.5 } 1.6 1.7 +if initiative.revoked then 1.8 + ui.container{ 1.9 + attr = { class = "revoked_info" }, 1.10 + content = function() 1.11 + slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) 1.12 + local suggested_initiative = initiative.suggested_initiative 1.13 + if suggested_initiative then 1.14 + slot.put("<br /><br />") 1.15 + slot.put(_("The initiators suggest to support the following initiative:")) 1.16 + slot.put("<br />") 1.17 + ui.link{ 1.18 + content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), 1.19 + module = "initiative", 1.20 + view = "show", 1.21 + id = suggested_initiative.id 1.22 + } 1.23 + end 1.24 + end 1.25 + } 1.26 +end 1.27 + 1.28 local initiator = Initiator:by_pk(initiative.id, app.session.member.id) 1.29 1.30 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />') 1.31 1.32 -execute.view{ 1.33 - module = "supporter", 1.34 - view = "_show_box", 1.35 - params = { initiative = initiative } 1.36 -} 1.37 - 1.38 -slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) 1.39 1.40 slot.select("actions", function() 1.41 if not initiative.issue.fully_frozen and not initiative.issue.closed then 1.42 @@ -45,48 +59,126 @@ 1.43 end 1.44 end) 1.45 1.46 +slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) 1.47 + 1.48 +slot.select("support", function() 1.49 + ui.container{ 1.50 + attr = { class = "actions" }, 1.51 + content = function() 1.52 + execute.view{ 1.53 + module = "supporter", 1.54 + view = "_show_box", 1.55 + params = { initiative = initiative } 1.56 + } 1.57 + if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then 1.58 + ui.link{ 1.59 + attr = { class = "action", style = "float: left;" }, 1.60 + content = function() 1.61 + ui.image{ static = "icons/16/script_delete.png" } 1.62 + slot.put(_"Revoke initiative") 1.63 + end, 1.64 + module = "initiative", 1.65 + view = "revoke", 1.66 + id = initiative.id 1.67 + } 1.68 + end 1.69 + end 1.70 + } 1.71 +end) 1.72 1.73 util.help("initiative.show") 1.74 1.75 +if initiator and initiator.accepted == nil then 1.76 + ui.container{ 1.77 + attr = { class = "initiator_invite_info" }, 1.78 + content = function() 1.79 + slot.put(_"You are invited to become initiator of this initiative.") 1.80 + slot.put(" ") 1.81 + ui.link{ 1.82 + content = function() 1.83 + ui.image{ static = "icons/16/tick.png" } 1.84 + slot.put(_"Accept invitation") 1.85 + end, 1.86 + module = "initiative", 1.87 + action = "accept_invitation", 1.88 + id = initiative.id, 1.89 + routing = { 1.90 + default = { 1.91 + mode = "redirect", 1.92 + module = request.get_module(), 1.93 + view = request.get_view(), 1.94 + id = param.get_id_cgi(), 1.95 + params = param.get_all_cgi() 1.96 + } 1.97 + } 1.98 + } 1.99 + slot.put(" ") 1.100 + ui.link{ 1.101 + content = function() 1.102 + ui.image{ static = "icons/16/cross.png" } 1.103 + slot.put(_"Refuse invitation") 1.104 + end, 1.105 + module = "initiative", 1.106 + action = "reject_initiator_invitation", 1.107 + params = { 1.108 + initiative_id = initiative.id, 1.109 + member_id = app.session.member.id 1.110 + }, 1.111 + routing = { 1.112 + default = { 1.113 + mode = "redirect", 1.114 + module = request.get_module(), 1.115 + view = request.get_view(), 1.116 + id = param.get_id_cgi(), 1.117 + params = param.get_all_cgi() 1.118 + } 1.119 + } 1.120 + } 1.121 + end 1.122 + } 1.123 + slot.put("<br />") 1.124 +end 1.125 1.126 -ui.container{ 1.127 - attr = { class = "vertical" }, 1.128 - content = function() 1.129 - ui.container{ 1.130 - attr = { class = "ui_field_label" }, 1.131 - content = _"Discussion URL" 1.132 - } 1.133 - ui.tag{ 1.134 - tag = "span", 1.135 - content = function() 1.136 - if initiative.discussion_url and #initiative.discussion_url > 0 then 1.137 - ui.link{ 1.138 - attr = { 1.139 - class = "actions", 1.140 - target = "_blank", 1.141 - title = initiative.discussion_url 1.142 - }, 1.143 - content = function() 1.144 - slot.put(encode.html(initiative.discussion_url)) 1.145 - end, 1.146 - external = initiative.discussion_url 1.147 - } 1.148 +if (initiative.discussion_url and #initiative.discussion_url > 0) 1.149 + or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then 1.150 + ui.container{ 1.151 + attr = { class = "vertical" }, 1.152 + content = function() 1.153 + ui.container{ 1.154 + attr = { class = "ui_field_label" }, 1.155 + content = _"Discussion with initiators" 1.156 + } 1.157 + ui.tag{ 1.158 + tag = "span", 1.159 + content = function() 1.160 + if initiative.discussion_url and #initiative.discussion_url > 0 then 1.161 + ui.link{ 1.162 + attr = { 1.163 + class = "actions", 1.164 + target = "_blank", 1.165 + title = initiative.discussion_url 1.166 + }, 1.167 + content = function() 1.168 + slot.put(encode.html(initiative.discussion_url)) 1.169 + end, 1.170 + external = initiative.discussion_url 1.171 + } 1.172 + end 1.173 + slot.put(" ") 1.174 + if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then 1.175 + ui.link{ 1.176 + attr = { class = "actions" }, 1.177 + content = _"(change URL)", 1.178 + module = "initiative", 1.179 + view = "edit", 1.180 + id = initiative.id 1.181 + } 1.182 + end 1.183 end 1.184 - slot.put(" ") 1.185 - if initiator then 1.186 - ui.link{ 1.187 - attr = { class = "actions" }, 1.188 - content = _"(change URL)", 1.189 - module = "initiative", 1.190 - view = "edit", 1.191 - id = initiative.id 1.192 - } 1.193 - end 1.194 - end 1.195 - } 1.196 - end 1.197 -} 1.198 - 1.199 + } 1.200 + end 1.201 + } 1.202 +end 1.203 1.204 1.205 ui.container{ 1.206 @@ -202,7 +294,7 @@ 1.207 name = "current_draft", 1.208 label = current_draft_name, 1.209 content = function() 1.210 - if initiator then 1.211 + if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then 1.212 ui.link{ 1.213 content = function() 1.214 ui.image{ static = "icons/16/script_add.png" } 1.215 @@ -238,9 +330,11 @@ 1.216 } 1.217 end 1.218 1.219 +local suggestion_count = initiative:get_reference_selector("suggestions"):count() 1.220 + 1.221 tabs[#tabs+1] = { 1.222 name = "suggestion", 1.223 - label = _"Suggestions", 1.224 + label = _"Suggestions" .. " (" .. tostring(suggestion_count) .. ")", 1.225 content = function() 1.226 execute.view{ 1.227 module = "suggestion", 1.228 @@ -251,7 +345,7 @@ 1.229 } 1.230 } 1.231 slot.put("<br />") 1.232 - if not initiative.issue.fully_frozen and not initiative.issue.closed then 1.233 + if not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then 1.234 ui.link{ 1.235 content = function() 1.236 ui.image{ static = "icons/16/comment_add.png" } 1.237 @@ -264,57 +358,126 @@ 1.238 end 1.239 } 1.240 1.241 +local members_selector = initiative:get_reference_selector("supporting_members_snapshot") 1.242 + :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") 1.243 + :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") 1.244 + :add_field("direct_interest_snapshot.weight") 1.245 + :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") 1.246 + :add_where("direct_supporter_snapshot.satisfied") 1.247 + 1.248 +local satisfied_supporter_count = members_selector:count() 1.249 + 1.250 tabs[#tabs+1] = { 1.251 name = "satisfied_supporter", 1.252 - label = _"Supporter", 1.253 + label = _"Supporter" .. " (" .. tostring(satisfied_supporter_count) .. ")", 1.254 + content = function() 1.255 + execute.view{ 1.256 + module = "member", 1.257 + view = "_list", 1.258 + params = { 1.259 + initiative = initiative, 1.260 + members_selector = members_selector 1.261 + } 1.262 + } 1.263 + end 1.264 +} 1.265 + 1.266 +local members_selector = initiative:get_reference_selector("supporting_members_snapshot") 1.267 + :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") 1.268 + :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") 1.269 + :add_field("direct_interest_snapshot.weight") 1.270 + :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") 1.271 + :add_where("NOT direct_supporter_snapshot.satisfied") 1.272 + 1.273 +local potential_supporter_count = members_selector:count() 1.274 + 1.275 +tabs[#tabs+1] = { 1.276 + name = "supporter", 1.277 + label = _"Potential supporter" .. " (" .. tostring(potential_supporter_count) .. ")", 1.278 content = function() 1.279 execute.view{ 1.280 module = "member", 1.281 view = "_list", 1.282 params = { 1.283 initiative = initiative, 1.284 - members_selector = initiative:get_reference_selector("supporting_members_snapshot") 1.285 - :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") 1.286 - :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") 1.287 - :add_field("direct_interest_snapshot.weight") 1.288 - :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") 1.289 - :add_where("direct_supporter_snapshot.satisfied") 1.290 + members_selector = members_selector 1.291 } 1.292 } 1.293 end 1.294 } 1.295 1.296 +local initiator_count = initiative:get_reference_selector("initiators"):add_where("accepted"):count() 1.297 + 1.298 tabs[#tabs+1] = { 1.299 - name = "supporter", 1.300 - label = _"Potential supporter", 1.301 + name = "initiators", 1.302 + label = _"Initiators" .. " (" .. tostring(initiator_count) .. ")", 1.303 content = function() 1.304 + if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then 1.305 + ui.link{ 1.306 + attr = { class = "action" }, 1.307 + content = function() 1.308 + ui.image{ static = "icons/16/user_add.png" } 1.309 + slot.put(_"Invite initiator") 1.310 + end, 1.311 + module = "initiative", 1.312 + view = "add_initiator", 1.313 + params = { initiative_id = initiative.id } 1.314 + } 1.315 + if initiator_count > 1 then 1.316 + ui.link{ 1.317 + content = function() 1.318 + ui.image{ static = "icons/16/user_delete.png" } 1.319 + slot.put(_"Remove initiator") 1.320 + end, 1.321 + module = "initiative", 1.322 + view = "remove_initiator", 1.323 + params = { initiative_id = initiative.id } 1.324 + } 1.325 + end 1.326 + end 1.327 + if initiator and initiator.accepted == false then 1.328 + ui.link{ 1.329 + content = function() 1.330 + ui.image{ static = "icons/16/user_delete.png" } 1.331 + slot.put(_"Cancel refuse of invitation") 1.332 + end, 1.333 + module = "initiative", 1.334 + action = "remove_initiator", 1.335 + params = { 1.336 + initiative_id = initiative.id, 1.337 + member_id = app.session.member.id 1.338 + }, 1.339 + routing = { 1.340 + ok = { 1.341 + mode = "redirect", 1.342 + module = "initiative", 1.343 + view = "show", 1.344 + id = initiative.id 1.345 + } 1.346 + } 1.347 + } 1.348 + end 1.349 + local members_selector = initiative:get_reference_selector("initiating_members") 1.350 + :add_field("initiator.accepted", "accepted") 1.351 + if not (initiator and initiator.accepted) then 1.352 + members_selector:add_where("accepted") 1.353 + end 1.354 execute.view{ 1.355 module = "member", 1.356 view = "_list", 1.357 params = { 1.358 - initiative = initiative, 1.359 - members_selector = initiative:get_reference_selector("supporting_members_snapshot") 1.360 - :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") 1.361 - :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") 1.362 - :add_field("direct_interest_snapshot.weight") 1.363 - :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") 1.364 - :add_where("NOT direct_supporter_snapshot.satisfied") 1.365 + members_selector = members_selector, 1.366 + initiator = initiator 1.367 } 1.368 } 1.369 end 1.370 } 1.371 1.372 -tabs[#tabs+1] = { 1.373 - name = "initiators", 1.374 - label = _"Initiators", 1.375 - content = function() 1.376 - execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } } 1.377 - end 1.378 -} 1.379 +local drafts_count = initiative:get_reference_selector("drafts"):count() 1.380 1.381 tabs[#tabs+1] = { 1.382 name = "drafts", 1.383 - label = _"Old drafts", 1.384 + label = _"Draft history" .. " (" .. tostring(drafts_count) .. ")", 1.385 content = function() 1.386 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } } 1.387 end 1.388 @@ -338,7 +501,7 @@ 1.389 label = _"Created at", 1.390 value = format.timestamp(initiative.created) 1.391 } 1.392 - ui.field.date{ label = _"Revoked at", name = "revoked" } 1.393 +-- ui.field.date{ label = _"Revoked at", name = "revoked" } 1.394 ui.field.boolean{ label = _"Admitted", name = "admitted" } 1.395 end 1.396 }