liquid_feedback_frontend

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

Impressum / About Us