rev |
line source |
bsw@851
|
1 --local global = param.get("global", atom.boolean)
|
bsw@414
|
2 local for_member = param.get("for_member", "table")
|
bsw@414
|
3 local for_unit = param.get("for_unit", "table")
|
bsw@414
|
4 local for_area = param.get("for_area", "table")
|
bsw@422
|
5 local event_max_id = param.get_all_cgi()["event_max_id"]
|
bsw@414
|
6 local event_selector = Event:new_selector()
|
bsw@414
|
7 :add_order_by("event.id DESC")
|
bsw@414
|
8 :limit(25)
|
bsw@414
|
9 :join("issue", nil, "issue.id = event.issue_id")
|
bsw@437
|
10 :add_field("now()::date - event.occurrence::date", "time_ago")
|
bsw@437
|
11
|
bsw@422
|
12 if event_max_id then
|
bsw@422
|
13 event_selector:add_where{ "event.id < ?", event_max_id }
|
bsw@422
|
14 end
|
bsw@422
|
15
|
bsw@414
|
16 if for_member then
|
bsw@414
|
17 event_selector:add_where{ "event.member_id = ?", for_member.id }
|
bsw@414
|
18 elseif for_unit then
|
bsw@414
|
19 event_selector:join("area", nil, "area.id = issue.area_id")
|
bsw@414
|
20 event_selector:add_where{ "area.unit_id = ?", for_unit.id }
|
bsw@414
|
21 elseif for_area then
|
bsw@414
|
22 event_selector:add_where{ "issue.area_id = ?", for_area.id }
|
bsw@851
|
23 --elseif not global then
|
bsw@851
|
24 -- event_selector:join("event_seen_by_member", nil, { "event_seen_by_member.id = event.id AND event_seen_by_member.seen_by_member_id = ?", app.session.member_id })
|
bsw@414
|
25 end
|
bsw@414
|
26
|
bsw@414
|
27 if app.session.member_id then
|
bsw@414
|
28 event_selector
|
bsw@414
|
29 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id } )
|
bsw@414
|
30 :add_field("(_interest.member_id NOTNULL)", "is_interested")
|
bsw@414
|
31 :left_join("delegating_interest_snapshot", "_delegating_interest", { "_delegating_interest.issue_id = issue.id AND _delegating_interest.member_id = ? AND _delegating_interest.event = issue.latest_snapshot_event", app.session.member.id } )
|
bsw@414
|
32 :add_field("_delegating_interest.delegate_member_ids[1]", "is_interested_by_delegation_to_member_id")
|
bsw@414
|
33 :add_field("_delegating_interest.delegate_member_ids[array_upper(_delegating_interest.delegate_member_ids, 1)]", "is_interested_via_member_id")
|
bsw@414
|
34 :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length")
|
bsw@414
|
35 end
|
bsw@414
|
36
|
bsw@851
|
37 local filters = execute.load_chunk{module="issue", chunk="_filters.lua", params = {
|
bsw@851
|
38 for_events = true,
|
bsw@851
|
39 member = app.session.member, for_member = for_member, state = for_state, for_unit = for_unit and true or false, for_area = for_area and true or false
|
bsw@851
|
40 }}
|
bsw@414
|
41
|
bsw@851
|
42 filters.opened = true
|
bsw@851
|
43 filters.selector = event_selector
|
bsw@851
|
44
|
bsw@851
|
45 filters.content = function()
|
bsw@851
|
46
|
bsw@596
|
47
|
bsw@851
|
48 local last_event_id
|
bsw@851
|
49
|
bsw@851
|
50 local events = event_selector:exec()
|
bsw@712
|
51
|
bsw@851
|
52 local issues = events:load("issue")
|
bsw@851
|
53 issues:load_everything_for_member_id(app.session.member_id)
|
bsw@851
|
54
|
bsw@851
|
55 events:load("initiative")
|
bsw@851
|
56 events:load("suggestion")
|
bsw@851
|
57 events:load("member")
|
bsw@712
|
58
|
bsw@712
|
59
|
bsw@851
|
60 ui.container{ attr = { class = "issues events" }, content = function()
|
bsw@414
|
61
|
bsw@851
|
62 local last_event_date
|
bsw@851
|
63 for i, event in ipairs(events) do
|
bsw@851
|
64 last_event_id = event.id
|
bsw@414
|
65
|
bsw@851
|
66 ui.container{ attr = { class = "event_info" }, content = function()
|
bsw@851
|
67 local event_name = event.event_name
|
bsw@851
|
68 local event_image
|
bsw@851
|
69 if event.event == "issue_state_changed" then
|
bsw@851
|
70 if event.state == "discussion" then
|
bsw@851
|
71 event_name = _"Discussion started"
|
bsw@851
|
72 event_image = "comments.png"
|
bsw@851
|
73 elseif event.state == "verification" then
|
bsw@851
|
74 event_name = _"Verification started"
|
bsw@851
|
75 event_image = "lock.png"
|
bsw@851
|
76 elseif event.state == "voting" then
|
bsw@851
|
77 event_name = _"Voting started"
|
bsw@851
|
78 event_image = "email_open.png"
|
bsw@851
|
79 elseif event.state == "finished_with_winner" then
|
bsw@851
|
80 event_name = event.state_name
|
bsw@851
|
81 event_image = "award_star_gold_2.png"
|
bsw@851
|
82 elseif event.state == "finished_without_winner" then
|
bsw@851
|
83 event_name = event.state_name
|
bsw@851
|
84 event_image = "cross.png"
|
bsw@851
|
85 else
|
bsw@851
|
86 event_name = event.state_name
|
bsw@851
|
87 end
|
bsw@851
|
88 if event_image then
|
bsw@851
|
89 ui.image{ static = "icons/16/" .. event_image }
|
bsw@851
|
90 slot.put(" ")
|
bsw@851
|
91 end
|
bsw@619
|
92 end
|
bsw@851
|
93 local days_ago_text
|
bsw@851
|
94 if event.time_ago == 0 then
|
bsw@851
|
95 days_ago_text = _("Today at #{time}", { time = format.time(event.occurrence) })
|
bsw@851
|
96 elseif event.time_ago == 1 then
|
bsw@851
|
97 days_ago_text = _("Yesterday at #{time}", { time = format.time(event.occurrence) })
|
bsw@851
|
98 else
|
bsw@939
|
99 days_ago_text = _("#{date} at #{time}", { date = format.date(event.occurrence.date), time = format.time(event.occurrence, { hide_seconds = true }) })
|
bsw@851
|
100 end
|
bsw@851
|
101 ui.tag{ attr = { class = "event_name" }, content = event_name }
|
bsw@688
|
102 slot.put("<br />")
|
bsw@851
|
103 ui.tag{ content = days_ago_text }
|
bsw@851
|
104 --[[ if event.time_ago > 1 then
|
bsw@851
|
105 slot.put("<br />(")
|
bsw@851
|
106 ui.tag{ content = _("#{count} days ago", { count = event.time_ago }) }
|
bsw@851
|
107 slot.put(")")
|
bsw@851
|
108 end
|
bsw@851
|
109 --]]
|
bsw@851
|
110 if app.session:has_access("authors_pseudonymous") and event.member_id then
|
bsw@851
|
111 slot.put("<br />")
|
bsw@851
|
112 slot.put("<br />")
|
bsw@851
|
113 if app.session.member_id then
|
bsw@851
|
114 ui.link{
|
bsw@851
|
115 content = function()
|
bsw@851
|
116 execute.view{
|
bsw@851
|
117 module = "member_image",
|
bsw@851
|
118 view = "_show",
|
bsw@851
|
119 params = {
|
bsw@851
|
120 member = event.member,
|
bsw@851
|
121 image_type = "avatar",
|
bsw@851
|
122 show_dummy = true,
|
bsw@851
|
123 class = "micro_avatar",
|
bsw@851
|
124 popup_text = text
|
bsw@851
|
125 }
|
bsw@851
|
126 }
|
bsw@851
|
127 end,
|
bsw@851
|
128 module = "member", view = "show", id = event.member_id
|
bsw@851
|
129 }
|
bsw@851
|
130 slot.put(" ")
|
bsw@851
|
131 end
|
bsw@688
|
132 ui.link{
|
bsw@851
|
133 text = event.member.name,
|
bsw@688
|
134 module = "member", view = "show", id = event.member_id
|
bsw@688
|
135 }
|
bsw@414
|
136 end
|
bsw@414
|
137 end }
|
bsw@414
|
138
|
bsw@851
|
139 ui.container{ attr = { class = "issue" }, content = function()
|
bsw@851
|
140
|
bsw@862
|
141 execute.view{ module = "delegation", view = "_info", params = { issue = event.issue, member = for_member } }
|
bsw@851
|
142
|
bsw@851
|
143 ui.container{ attr = { class = "content" }, content = function()
|
bsw@851
|
144 ui.link{
|
bsw@851
|
145 module = "unit", view = "show", id = event.issue.area.unit_id,
|
bsw@851
|
146 attr = { class = "unit_link" }, text = event.issue.area.unit.name
|
bsw@851
|
147 }
|
bsw@851
|
148 slot.put(" ")
|
bsw@851
|
149 ui.link{
|
bsw@851
|
150 module = "area", view = "show", id = event.issue.area_id,
|
bsw@851
|
151 attr = { class = "area_link" }, text = event.issue.area.name
|
bsw@851
|
152 }
|
bsw@851
|
153 end }
|
bsw@851
|
154
|
bsw@851
|
155 ui.container{ attr = { class = "title" }, content = function()
|
bsw@725
|
156 ui.link{
|
bsw@851
|
157 attr = { class = "issue_id" },
|
bsw@851
|
158 text = _("#{policy} ##{id}", { policy = event.issue.policy.name, id = event.issue_id }),
|
bsw@851
|
159 module = "issue",
|
bsw@851
|
160 view = "show",
|
bsw@851
|
161 id = event.issue_id
|
bsw@725
|
162 }
|
bsw@851
|
163 end }
|
bsw@851
|
164
|
bsw@851
|
165 ui.container{ attr = { class = "initiative_list" }, content = function()
|
bsw@851
|
166 if not event.initiative_id then
|
bsw@851
|
167 local initiatives_selector = Initiative:new_selector()
|
bsw@851
|
168 :add_where{ "initiative.issue_id = ?", event.issue_id }
|
bsw@962
|
169 :add_order_by("initiative.admitted DESC, initiative.rank, initiative.harmonic_weight DESC NULLS LAST, id")
|
bsw@851
|
170 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@851
|
171 issue = event.issue,
|
bsw@851
|
172 initiatives_selector = initiatives_selector,
|
bsw@851
|
173 no_sort = true,
|
bsw@862
|
174 limit = 5,
|
bsw@862
|
175 for_member = for_member
|
bsw@851
|
176 } }
|
bsw@851
|
177 else
|
bsw@851
|
178 local initiatives_selector = Initiative:new_selector()
|
bsw@851
|
179 :add_where{ "initiative.id = ?", event.initiative_id }
|
bsw@851
|
180 execute.view{ module = "initiative", view = "_list", params = {
|
bsw@851
|
181 initiatives_selector = initiatives_selector,
|
bsw@851
|
182 no_sort = true,
|
bsw@862
|
183 hide_more_initiatives = true,
|
bsw@862
|
184 for_member = for_member
|
bsw@851
|
185 } }
|
bsw@851
|
186 end
|
bsw@851
|
187 end }
|
bsw@851
|
188
|
bsw@851
|
189 ui.container{ attr = { class = "content suggestion" }, content = function()
|
bsw@851
|
190 if event.suggestion_id then
|
bsw@851
|
191 ui.link{
|
bsw@851
|
192 text = event.suggestion.name,
|
bsw@851
|
193 module = "suggestion", view = "show", id = event.suggestion_id
|
bsw@851
|
194 }
|
bsw@851
|
195 end
|
bsw@851
|
196 end }
|
bsw@725
|
197 end }
|
bsw@851
|
198 end
|
bsw@851
|
199
|
bsw@851
|
200 end }
|
bsw@851
|
201
|
bsw@851
|
202 slot.put("<br />")
|
bsw@851
|
203
|
bsw@851
|
204 if #events > 0 then
|
bsw@851
|
205 ui.link{
|
bsw@851
|
206 attr = { class = "more_events_links" },
|
bsw@851
|
207 text = _"Show older events",
|
bsw@851
|
208 module = request.get_module(),
|
bsw@851
|
209 view = request.get_view(),
|
bsw@851
|
210 id = for_unit and for_unit.id or for_area and for_area.id,
|
bsw@851
|
211 params = {
|
bsw@851
|
212 tab = param.get_all_cgi()["tab"],
|
bsw@851
|
213 events = param.get_all_cgi()["events"],
|
bsw@851
|
214 event_max_id = last_event_id
|
bsw@851
|
215 }
|
bsw@851
|
216 }
|
bsw@851
|
217 else
|
bsw@851
|
218 ui.tag{ content = _"No more events available" }
|
bsw@422
|
219 end
|
bsw@414
|
220
|
bsw@851
|
221 slot.put("<br />")
|
bsw@851
|
222 slot.put("<br />")
|
bsw@596
|
223
|
bsw@596
|
224 end
|
bsw@456
|
225
|
bsw@851
|
226
|
bsw@957
|
227 ui.filters(filters)
|