liquid_feedback_frontend

annotate app/main/issue/_show.lua @ 862:a1ff5d08f0f4

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

Impressum / About Us