liquid_feedback_frontend

annotate app/main/initiative/_show.lua @ 290:24f8920e05f1

Removed author links from voting ballot to make grabbing initiatives easier
author bsw
date Sat Feb 25 12:48:49 2012 +0100 (2012-02-25)
parents c587d8762e62
children 56dc44366c38
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw/jbe@19 2 local initiator = param.get("initiator", "table")
bsw/jbe@19 3
bsw@272 4 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
bsw@272 5 :add_field("initiator.accepted", "accepted")
bsw@280 6 :add_order_by("member.name")
bsw@280 7 if initiator and initiator.accepted then
bsw@280 8 initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
bsw@280 9 else
bsw@272 10 initiators_members_selector:add_where("initiator.accepted")
bsw@272 11 end
bsw@272 12
bsw@272 13 local initiators = initiators_members_selector:exec()
bsw@272 14
bsw@274 15
bsw@274 16 local initiatives_selector = initiative.issue:get_reference_selector("initiatives")
bsw@274 17 slot.select("initiatives_list", function()
bsw@274 18 execute.view{
bsw@274 19 module = "initiative",
bsw@274 20 view = "_list",
bsw@274 21 params = {
bsw@274 22 issue = initiative.issue,
bsw@274 23 initiatives_selector = initiatives_selector,
bsw@274 24 no_sort = true, highlight_initiative = initiative, limit = 3
bsw@274 25 }
bsw@274 26 }
bsw@274 27 end)
bsw@274 28
bsw@272 29 slot.select("initiative_head", function()
bsw@272 30
bsw@272 31 ui.container{
bsw@272 32 attr = { class = "initiative_name" },
bsw@272 33 content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
bsw@272 34 }
bsw@286 35 end )
bsw@286 36
bsw@286 37 if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then
bsw@286 38 ui.tag{
bsw@286 39 attr = { class = "initiator_names" },
bsw@286 40 content = function()
bsw@286 41 for i, initiator in ipairs(initiators) do
bsw@286 42 slot.put(" ")
bsw@286 43 ui.link{
bsw@286 44 content = function ()
bsw@286 45 execute.view{
bsw@286 46 module = "member_image",
bsw@286 47 view = "_show",
bsw@286 48 params = {
bsw@286 49 member = initiator,
bsw@286 50 image_type = "avatar",
bsw@286 51 show_dummy = true,
bsw@286 52 class = "micro_avatar",
bsw@286 53 popup_text = text
bsw@280 54 }
bsw@286 55 }
bsw@286 56 end,
bsw@286 57 module = "member", view = "show", id = initiator.id
bsw@286 58 }
bsw@286 59 slot.put(" ")
bsw@286 60 ui.link{
bsw@286 61 text = initiator.name,
bsw@286 62 module = "member", view = "show", id = initiator.id
bsw@286 63 }
bsw@286 64 if not initiator.accepted then
bsw@286 65 ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" }
bsw@272 66 end
bsw@272 67 end
bsw@286 68 end
bsw@286 69 }
bsw@286 70 end
bsw@272 71
bsw@286 72 if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@286 73 slot.put(" · ")
bsw@286 74 ui.link{
bsw@286 75 attr = { class = "action" },
bsw@286 76 content = function()
bsw@286 77 slot.put(_"Invite initiator")
bsw@286 78 end,
bsw@286 79 module = "initiative",
bsw@286 80 view = "add_initiator",
bsw@286 81 params = { initiative_id = initiative.id }
bsw@286 82 }
bsw@286 83 if #initiators > 1 then
bsw@272 84 slot.put(" · ")
bsw@272 85 ui.link{
bsw@272 86 content = function()
bsw@286 87 slot.put(_"Remove initiator")
bsw@272 88 end,
bsw@272 89 module = "initiative",
bsw@286 90 view = "remove_initiator",
bsw@272 91 params = { initiative_id = initiative.id }
bsw@272 92 }
bsw@272 93 end
bsw@286 94 end
bsw@286 95 if initiator and initiator.accepted == false then
bsw@286 96 slot.put(" · ")
bsw@286 97 ui.link{
bsw@286 98 text = _"Cancel refuse of invitation",
bsw@286 99 module = "initiative",
bsw@286 100 action = "remove_initiator",
bsw@286 101 params = {
bsw@286 102 initiative_id = initiative.id,
bsw@286 103 member_id = app.session.member.id
bsw@286 104 },
bsw@286 105 routing = {
bsw@286 106 ok = {
bsw@286 107 mode = "redirect",
bsw@286 108 module = "initiative",
bsw@286 109 view = "show",
bsw@286 110 id = initiative.id
bsw@272 111 }
bsw@272 112 }
bsw@286 113 }
bsw@286 114 end
bsw@272 115
bsw/jbe@19 116 util.help("initiative.show")
bsw/jbe@19 117
bsw@272 118
bsw/jbe@19 119 if initiative.issue.ranks_available and initiative.admitted then
bsw/jbe@19 120 local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
bsw/jbe@19 121 ui.container{
bsw/jbe@19 122 attr = { class = class },
bsw/jbe@19 123 content = function()
bsw/jbe@19 124 local max_value = initiative.issue.voter_count
bsw/jbe@19 125 slot.put(" ")
bsw/jbe@19 126 local positive_votes = initiative.positive_votes
bsw/jbe@19 127 local negative_votes = initiative.negative_votes
jorges@104 128 local sum_votes = initiative.positive_votes + initiative.negative_votes
poelzi@167 129 local function perc(votes, sum)
poelzi@167 130 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
poelzi@167 131 return ""
poelzi@167 132 end
poelzi@167 133 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
bsw/jbe@19 134 slot.put(" &middot; ")
bsw/jbe@19 135 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
bsw/jbe@19 136 slot.put(" &middot; ")
poelzi@167 137 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
bsw/jbe@19 138 slot.put(" &middot; ")
bsw/jbe@19 139 slot.put("<b>")
bsw/jbe@19 140 if initiative.rank == 1 then
bsw/jbe@19 141 slot.put(_"Approved")
bsw/jbe@19 142 elseif initiative.rank then
bsw/jbe@19 143 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
bsw@24 144 else
bsw@24 145 slot.put(_"Not approved")
bsw/jbe@19 146 end
bsw/jbe@19 147 slot.put("</b>")
bsw/jbe@19 148 end
bsw/jbe@19 149 }
bsw/jbe@19 150 end
bsw/jbe@19 151
bsw/jbe@19 152 if initiative.admitted == false then
bsw/jbe@19 153 local policy = initiative.issue.policy
bsw/jbe@19 154 ui.container{
bsw/jbe@19 155 attr = { class = "not_admitted_info" },
bsw/jbe@19 156 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
bsw/jbe@19 157 }
bsw/jbe@19 158 end
bsw/jbe@19 159
bsw@278 160 if initiative.issue.state == "cancelled" then
bsw/jbe@19 161 local policy = initiative.issue.policy
bsw/jbe@19 162 ui.container{
bsw/jbe@19 163 attr = { class = "not_admitted_info" },
bsw/jbe@19 164 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
bsw/jbe@19 165 }
bsw/jbe@19 166 end
bsw/jbe@19 167
bsw/jbe@19 168 if initiative.revoked then
bsw/jbe@19 169 ui.container{
bsw/jbe@19 170 attr = { class = "revoked_info" },
bsw/jbe@19 171 content = function()
bsw/jbe@19 172 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
bsw/jbe@19 173 local suggested_initiative = initiative.suggested_initiative
bsw/jbe@19 174 if suggested_initiative then
bsw/jbe@19 175 slot.put("<br /><br />")
bsw/jbe@19 176 slot.put(_("The initiators suggest to support the following initiative:"))
bsw/jbe@19 177 slot.put(" ")
bsw/jbe@19 178 ui.link{
bsw/jbe@19 179 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
bsw/jbe@19 180 module = "initiative",
bsw/jbe@19 181 view = "show",
bsw/jbe@19 182 id = suggested_initiative.id
bsw/jbe@19 183 }
bsw/jbe@19 184 end
bsw/jbe@19 185 end
bsw/jbe@19 186 }
bsw/jbe@19 187 end
bsw/jbe@19 188
bsw@41 189 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
bsw/jbe@19 190 ui.container{
bsw/jbe@19 191 attr = { class = "initiator_invite_info" },
bsw/jbe@19 192 content = function()
bsw/jbe@19 193 slot.put(_"You are invited to become initiator of this initiative.")
bsw/jbe@19 194 slot.put(" ")
bsw/jbe@19 195 ui.link{
bsw/jbe@19 196 image = { static = "icons/16/tick.png" },
bsw/jbe@19 197 text = _"Accept invitation",
bsw/jbe@19 198 module = "initiative",
bsw/jbe@19 199 action = "accept_invitation",
bsw/jbe@19 200 id = initiative.id,
bsw/jbe@19 201 routing = {
bsw/jbe@19 202 default = {
bsw/jbe@19 203 mode = "redirect",
bsw/jbe@19 204 module = request.get_module(),
bsw/jbe@19 205 view = request.get_view(),
bsw/jbe@19 206 id = param.get_id_cgi(),
bsw/jbe@19 207 params = param.get_all_cgi()
bsw/jbe@19 208 }
bsw/jbe@19 209 }
bsw/jbe@19 210 }
bsw/jbe@19 211 slot.put(" ")
bsw/jbe@19 212 ui.link{
bsw/jbe@19 213 image = { static = "icons/16/cross.png" },
bsw/jbe@19 214 text = _"Refuse invitation",
bsw/jbe@19 215 module = "initiative",
bsw/jbe@19 216 action = "reject_initiator_invitation",
bsw/jbe@19 217 params = {
bsw/jbe@19 218 initiative_id = initiative.id,
bsw/jbe@19 219 member_id = app.session.member.id
bsw/jbe@19 220 },
bsw/jbe@19 221 routing = {
bsw/jbe@19 222 default = {
bsw/jbe@19 223 mode = "redirect",
bsw/jbe@19 224 module = request.get_module(),
bsw/jbe@19 225 view = request.get_view(),
bsw/jbe@19 226 id = param.get_id_cgi(),
bsw/jbe@19 227 params = param.get_all_cgi()
bsw/jbe@19 228 }
bsw/jbe@19 229 }
bsw/jbe@19 230 }
bsw/jbe@19 231 end
bsw/jbe@19 232 }
bsw/jbe@19 233 slot.put("<br />")
bsw/jbe@19 234 end
bsw/jbe@19 235
bsw/jbe@19 236
bsw@280 237 if app.session.member_id then
bsw@280 238 execute.view{
bsw@280 239 module = "supporter",
bsw@280 240 view = "_show_box",
bsw@280 241 params = {
bsw@280 242 initiative = initiative
bsw@280 243 }
bsw@280 244 }
bsw@280 245 end
bsw@280 246
bsw@51 247 local supporter
bsw@51 248
bsw@51 249 if app.session.member_id then
bsw@51 250 supporter = app.session.member:get_reference_selector("supporters")
bsw@51 251 :add_where{ "initiative_id = ?", initiative.id }
bsw@51 252 :optional_object_mode()
bsw@51 253 :exec()
bsw@51 254 end
bsw/jbe@19 255
bsw/jbe@19 256 if supporter and not initiative.issue.closed then
bsw/jbe@19 257 local old_draft_id = supporter.draft_id
bsw/jbe@19 258 local new_draft_id = initiative.current_draft.id
bsw/jbe@19 259 if old_draft_id ~= new_draft_id then
bsw/jbe@19 260 ui.container{
bsw/jbe@19 261 attr = { class = "draft_updated_info" },
bsw/jbe@19 262 content = function()
bsw/jbe@19 263 slot.put(_"The draft of this initiative has been updated!")
bsw/jbe@19 264 slot.put(" ")
bsw/jbe@19 265 ui.link{
bsw/jbe@19 266 content = _"Show diff",
bsw/jbe@19 267 module = "draft",
bsw/jbe@19 268 view = "diff",
bsw/jbe@19 269 params = {
bsw/jbe@19 270 old_draft_id = old_draft_id,
bsw/jbe@19 271 new_draft_id = new_draft_id
bsw/jbe@19 272 }
bsw/jbe@19 273 }
bsw@75 274 if not initiative.revoked then
bsw@75 275 slot.put(" ")
bsw@75 276 ui.link{
bsw@75 277 text = _"Refresh support to current draft",
bsw@75 278 module = "initiative",
bsw@75 279 action = "add_support",
bsw@75 280 id = initiative.id,
bsw@75 281 routing = {
bsw@75 282 default = {
bsw@75 283 mode = "redirect",
bsw@75 284 module = "initiative",
bsw@75 285 view = "show",
bsw@75 286 id = initiative.id
bsw@75 287 }
bsw/jbe@19 288 }
bsw/jbe@19 289 }
bsw@75 290 end
bsw/jbe@19 291 end
bsw/jbe@19 292 }
bsw/jbe@19 293 end
bsw/jbe@19 294 end
bsw/jbe@19 295
bsw/jbe@19 296 execute.view{
bsw/jbe@19 297 module = "initiative",
bsw/jbe@19 298 view = "show_tab",
bsw/jbe@19 299 params = {
bsw/jbe@19 300 initiative = initiative,
bsw/jbe@19 301 initiator = initiator
bsw/jbe@19 302 }
bsw/jbe@19 303 }
bsw/jbe@19 304
bsw@280 305 if initiative.issue.snapshot then
bsw@280 306 ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot }
bsw@280 307 end
bsw@280 308
bsw@280 309
bsw@286 310

Impressum / About Us