liquid_feedback_frontend
view app/main/initiative/list_rss.lua @ 124:f740026b1518
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
parents | 733f65c0c0a0 |
children |
line source
1 if not config.feature_rss_enabled then
2 error("feature not enabled")
3 end
5 local area_id = param.get("area_id", atom.integer)
6 local issue_id = param.get("issue_id", atom.integer)
7 local order = param.get("order") or "last_created"
9 local initiatives_selector = Initiative:new_selector()
11 local issue
12 local area
14 if issue_id then
15 issue = Issue:by_id(issue_id)
16 initiatives_selector:add_where{ "initiative.issue_id = ?", issue_id }
17 elseif area_id then
18 area = Area:by_id(area_id)
19 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id")
20 initiatives_selector:add_where{ "issue.area_id = ?", area_id }
21 end
24 if order == "last_created" then
25 initiatives_selector:add_order_by("initiative.created DESC")
26 initiatives_selector:add_field("initiative.created", "created_or_updated")
27 elseif order == "last_updated" then
28 initiatives_selector:add_field("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id)", "created_or_updated")
29 initiatives_selector:add_order_by("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id) DESC")
30 else
31 error("Invalid order")
32 end
34 initiatives_selector:add_order_by("id DESC")
36 initiatives_selector:limit(25)
38 local initiatives = initiatives_selector:exec()
40 slot.set_layout("atom")
41 request.force_absolute_baseurl()
43 ui.tag{
44 tag = "author",
45 content = function()
46 ui.tag{
47 tag = "name",
48 content = "LiquidFeedback"
49 }
50 end
51 }
53 local title
55 if issue then
56 title = "#" .. tostring(issue.id) .. " " .. issue.area.name
57 elseif area then
58 title = area.name
59 else
60 title = config.app_title
61 end
63 ui.tag{
64 tag = "title",
65 content = title
66 }
68 local subtitle
69 if order == "last_created" then
70 subtitle = "Initiatives (last created first)"
71 elseif order == "last_updated" then
72 subtitle = "Initiatives (last updated first)"
73 end
75 ui.tag{
76 tag = "subtitle",
77 content = subtitle
78 }
80 ui.tag{
81 tag = "id",
82 -- content = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
83 }
85 --[[
86 ui.tag{
87 tag = "updated",
88 content = "2003-12-14T10:20:09Z"
89 }
90 --]]
92 for i, initiative in ipairs(initiatives) do
93 ui.tag{
94 tag = "entry",
95 content = function()
96 slot.put("\n")
97 ui.tag{ tag = "category", attr = { term = encode.html(initiative.issue.area.name) } }
98 slot.put("\n")
99 ui.tag{ tag = "author", content = encode.html(initiative.current_draft.author.name) }
100 slot.put("\n")
101 ui.tag{ tag = "title", content = encode.html(initiative.shortened_name) }
102 slot.put("\n")
103 ui.tag{ tag = "link", attr = {
104 href = encode.url{
105 module = "initiative",
106 view = "show",
107 id = initiative.id
108 }
109 } }
110 slot.put("\n")
111 ui.tag{ tag = "id", content = "initiative_" .. tostring(initiative.id) }
112 slot.put("\n")
113 ui.tag{ tag = "updated", content = tostring(initiative.created_or_updated) }
114 slot.put("\n")
115 ui.tag{ tag = "content", content = encode.html(initiative.current_draft.content or "") }
116 slot.put("\n")
117 end
118 }
119 slot.put("\n")
120 end