liquid_feedback_frontend

annotate app/main/issue/_show.lua @ 664:a846889adc37

Added tag v2.beta12 for changeset 2fe57fa90c7a
author bsw
date Tue Jun 26 15:18:46 2012 +0200 (2012-06-26)
parents ea89fa21b0ab
children 93ac2eaec600
rev   line source
bsw@525 1 local issue = param.get("issue", "table")
bsw@525 2 local initiative_limit = param.get("initiative_limit", atom.integer)
bsw@525 3 local for_listing = param.get("for_listing", atom.boolean)
bsw@574 4 local for_initiative = param.get("for_initiative", "table")
bsw@574 5 local for_initiative_id = for_initiative and for_initiative.id or nil
bsw@525 6
bsw@525 7 local direct_voter
bsw@525 8 if app.session.member_id then
bsw@547 9 direct_voter = issue.member_info.direct_voted
bsw@525 10 end
bsw@525 11
bsw@525 12 local voteable = app.session.member_id and issue.state == 'voting' and
bsw@525 13 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
bsw@525 14
bsw@525 15 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
bsw@525 16
bsw@525 17
bsw@525 18 local class = "issue"
bsw@525 19 if issue.is_interested then
bsw@525 20 class = class .. " interested"
bsw@525 21 elseif issue.is_interested_by_delegation_to_member_id then
bsw@525 22 class = class .. " interested_by_delegation"
bsw@525 23 end
bsw@525 24
bsw@525 25 ui.container{ attr = { class = class }, content = function()
bsw@525 26
bsw@525 27 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
bsw@525 28
bsw@635 29 if for_listing then
bsw@635 30 ui.container{ attr = { class = "content" }, content = function()
bsw@635 31 ui.tag{ content = issue.area.unit.name }
bsw@635 32 slot.put(" · ")
bsw@635 33 ui.tag{ content = issue.area.name }
bsw@635 34 end }
bsw@635 35 end
bsw@635 36
bsw@525 37 ui.container{ attr = { class = "title" }, content = function()
bsw@525 38
bsw@525 39 ui.link{
bsw@525 40 attr = { class = "issue_id" },
bsw@525 41 text = _("#{policy_name} ##{issue_id}", {
bsw@525 42 policy_name = issue.policy.name,
bsw@525 43 issue_id = issue.id
bsw@525 44 }),
bsw@525 45 module = "issue",
bsw@525 46 view = "show",
bsw@525 47 id = issue.id
bsw@525 48 }
bsw@525 49 end }
bsw@525 50
bsw@525 51 ui.tag{
bsw@525 52 attr = { class = "content issue_policy_info" },
bsw@525 53 tag = "div",
bsw@525 54 content = function()
bsw@525 55
bsw@525 56 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
bsw@525 57
bsw@525 58 if issue.state_time_left then
bsw@525 59 slot.put(" · ")
bsw@525 60 if issue.state_time_left:sub(1,1) == "-" then
bsw@550 61 if issue.state == "accepted" then
bsw@525 62 ui.tag{ content = _("Discussion starts soon") }
bsw@525 63 elseif issue.state == "discussion" then
bsw@525 64 ui.tag{ content = _("Verification starts soon") }
bsw@525 65 elseif issue.state == "frozen" then
bsw@525 66 ui.tag{ content = _("Voting starts soon") }
bsw@525 67 elseif issue.state == "voting" then
bsw@525 68 ui.tag{ content = _("Counting starts soon") }
bsw@525 69 end
bsw@525 70 else
bsw@525 71 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
bsw@525 72 end
bsw@525 73 end
bsw@525 74
bsw@525 75 end
bsw@525 76 }
bsw@525 77
bsw@572 78 local links = {}
bsw@525 79
bsw@525 80 if voteable then
bsw@572 81 links[#links+1] ={
bsw@525 82 content = vote_link_text,
bsw@525 83 module = "vote",
bsw@525 84 view = "list",
bsw@525 85 params = { issue_id = issue.id }
bsw@525 86 }
bsw@525 87 end
bsw@525 88
bsw@525 89 if app.session.member_id then
bsw@572 90
bsw@572 91 if issue.member_info.own_participation then
bsw@572 92 if issue.closed then
bsw@572 93 links[#links+1] = { content = _"You were interested" }
bsw@572 94 else
bsw@572 95 links[#links+1] = { content = _"You are interested" }
bsw@572 96 end
bsw@572 97 end
bsw@572 98
bsw@572 99 if not issue.closed and not issue.fully_frozen then
bsw@572 100 if issue.member_info.own_participation then
bsw@572 101 links[#links+1] = {
bsw@572 102 in_brackets = true,
bsw@572 103 text = _"Withdraw",
bsw@572 104 module = "interest",
bsw@572 105 action = "update",
bsw@572 106 params = { issue_id = issue.id, delete = true },
bsw@572 107 routing = {
bsw@572 108 default = {
bsw@572 109 mode = "redirect",
bsw@572 110 module = request.get_module(),
bsw@572 111 view = request.get_view(),
bsw@572 112 id = param.get_id_cgi(),
bsw@572 113 params = param.get_all_cgi()
bsw@572 114 }
bsw@572 115 }
bsw@572 116 }
bsw@572 117 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw@572 118 links[#links+1] = {
bsw@572 119 text = _"Add my interest",
bsw@572 120 module = "interest",
bsw@572 121 action = "update",
bsw@572 122 params = { issue_id = issue.id },
bsw@572 123 routing = {
bsw@572 124 default = {
bsw@572 125 mode = "redirect",
bsw@572 126 module = request.get_module(),
bsw@572 127 view = request.get_view(),
bsw@572 128 id = param.get_id_cgi(),
bsw@572 129 params = param.get_all_cgi()
bsw@572 130 }
bsw@572 131 }
bsw@572 132 }
bsw@572 133 end
bsw@572 134 end
bsw@525 135 end
bsw@525 136
bsw@573 137 if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw@547 138 if issue.member_info.own_delegation_scope ~= "issue" then
bsw@574 139 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
bsw@529 140 else
bsw@574 141 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
bsw@529 142 end
bsw@529 143 end
bsw@529 144
bsw@525 145 if config.issue_discussion_url_func then
bsw@525 146 local url = config.issue_discussion_url_func(issue)
bsw@572 147 links[#links+1] = {
bsw@525 148 attr = { target = "_blank" },
bsw@525 149 external = url,
bsw@525 150 content = _"Discussion on issue"
bsw@525 151 }
bsw@525 152 end
bsw@525 153
bsw@525 154 if config.etherpad and app.session.member then
bsw@572 155 links[#links+1] = {
bsw@525 156 attr = { target = "_blank" },
bsw@525 157 external = issue.etherpad_url,
bsw@525 158 content = _"Issue pad"
bsw@525 159 }
bsw@525 160 end
bsw@525 161
bsw@525 162
bsw@525 163 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw@525 164 if not issue.fully_frozen and not issue.closed then
bsw@572 165 links[#links+1] = {
bsw@525 166 attr = { class = "action" },
bsw@525 167 text = _"Create alternative initiative",
bsw@525 168 module = "initiative",
bsw@525 169 view = "new",
bsw@525 170 params = { issue_id = issue.id }
bsw@525 171 }
bsw@525 172 end
bsw@525 173 end
bsw@525 174
bsw@572 175 ui.container{ attr = { class = "content actions" }, content = function()
bsw@572 176 for i, link in ipairs(links) do
bsw@572 177 if link.in_brackets then
bsw@572 178 slot.put(" (")
bsw@572 179 elseif i > 1 then
bsw@572 180 slot.put(" · ")
bsw@572 181 end
bsw@582 182 if link.module or link.external then
bsw@572 183 ui.link(link)
bsw@572 184 else
bsw@572 185 ui.tag(link)
bsw@572 186 end
bsw@572 187 if link.in_brackets then
bsw@572 188 slot.put(")")
bsw@572 189 end
bsw@572 190 end
bsw@525 191 end }
bsw@525 192
bsw@525 193 if not for_listing then
bsw@525 194
bsw@525 195 if voteable then
bsw@525 196 ui.container{
bsw@525 197 attr = { class = "voting_active_info" },
bsw@525 198 content = function()
bsw@525 199 slot.put(_"Voting for this issue is currently running!")
bsw@525 200 slot.put(" ")
bsw@525 201 if app.session.member_id then
bsw@525 202 ui.link{
bsw@525 203 content = vote_link_text,
bsw@525 204 module = "vote",
bsw@525 205 view = "list",
bsw@525 206 params = { issue_id = issue.id }
bsw@525 207 }
bsw@525 208 end
bsw@525 209 end
bsw@525 210 }
bsw@525 211 end
bsw@525 212
bsw@527 213 if issue.state == "cancelled" then
bsw@527 214 local policy = issue.policy
bsw@527 215 ui.container{
bsw@527 216 attr = { class = "not_admitted_info" },
bsw@527 217 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
bsw@527 218 }
bsw@527 219 end
bsw@527 220
bsw@525 221 end
bsw@525 222
bsw@642 223 ui.container{ attr = { class = "initiative_list content" }, content = function()
bsw@525 224
bsw@525 225 local initiatives_selector = issue:get_reference_selector("initiatives")
bsw@525 226 local highlight_string = param.get("highlight_string")
bsw@525 227 if highlight_string then
bsw@525 228 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
bsw@525 229 end
bsw@525 230 execute.view{
bsw@525 231 module = "initiative",
bsw@525 232 view = "_list",
bsw@525 233 params = {
bsw@525 234 issue = issue,
bsw@525 235 initiatives_selector = initiatives_selector,
bsw@525 236 highlight_string = highlight_string,
bsw@525 237 no_sort = true,
bsw@551 238 limit = 5,
bsw@525 239 for_member = for_member
bsw@525 240 }
bsw@525 241 }
bsw@525 242 end }
bsw@525 243 end }
bsw@525 244

Impressum / About Us