rev |
line source |
bsw@278
|
1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
|
bsw/jbe@0
|
2
|
bsw@278
|
3 -- TODO performance
|
bsw@278
|
4 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
|
bsw/jbe@19
|
5
|
bsw@525
|
6 local initiative = param.get("initiative", "table")
|
bsw@525
|
7 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
|
bsw@278
|
8
|
bsw@525
|
9 local partial = {
|
bsw@525
|
10 routing = {
|
bsw@525
|
11 default = {
|
bsw@525
|
12 mode = "redirect",
|
bsw@525
|
13 module = "initiative",
|
bsw@525
|
14 view = "show_support",
|
bsw@525
|
15 id = initiative.id
|
bsw@525
|
16 }
|
bsw@525
|
17 }
|
bsw@525
|
18 }
|
bsw/jbe@0
|
19
|
bsw@525
|
20 local routing = {
|
bsw@525
|
21 default = {
|
bsw@525
|
22 mode = "redirect",
|
bsw@525
|
23 module = request.get_module(),
|
bsw@525
|
24 view = request.get_view(),
|
bsw@525
|
25 id = param.get_id_cgi(),
|
bsw@525
|
26 params = param.get_all_cgi()
|
bsw@525
|
27 }
|
bsw@525
|
28 }
|
bsw/jbe@19
|
29
|
bsw@525
|
30 if not initiative.issue.fully_frozen and not initiative.issue.closed then
|
bsw@525
|
31 if supporter then
|
bsw@525
|
32 if not supporter:has_critical_opinion() then
|
bsw@525
|
33 ui.tag{ content = function()
|
bsw@525
|
34 ui.image{
|
bsw@525
|
35 static = "icons/16/thumb_up_green.png"
|
bsw@525
|
36 }
|
bsw@525
|
37 slot.put(_"Your are supporter")
|
bsw@525
|
38 end }
|
bsw@525
|
39 else
|
bsw@525
|
40 ui.tag{ attr = { class = "potential_supporter" }, content = function()
|
bsw@525
|
41 ui.image{
|
bsw@525
|
42 static = "icons/16/thumb_up.png"
|
bsw@525
|
43 }
|
bsw@525
|
44 slot.put(_"Your are potential supporter")
|
bsw@525
|
45 end }
|
bsw@525
|
46 end
|
bsw@525
|
47 slot.put(" (")
|
bsw@525
|
48 ui.link{
|
bsw@525
|
49 text = _"Withdraw",
|
bsw@525
|
50 module = "initiative",
|
bsw@525
|
51 action = "remove_support",
|
bsw@525
|
52 id = initiative.id,
|
bsw@525
|
53 routing = routing,
|
bsw@525
|
54 partial = partial
|
bsw@525
|
55 }
|
bsw@525
|
56 slot.put(") ")
|
bsw@525
|
57 elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
|
bsw@525
|
58 local params = param.get_all_cgi()
|
bsw@525
|
59 params.dyn = nil
|
bsw@525
|
60 ui.link{
|
bsw@525
|
61 text = _"Support this initiative",
|
bsw@525
|
62 module = "initiative",
|
bsw@525
|
63 action = "add_support",
|
bsw@525
|
64 id = initiative.id,
|
bsw@525
|
65 routing = routing,
|
bsw@525
|
66 partial = partial
|
bsw@525
|
67 }
|
bsw@525
|
68 slot.put(" ")
|
bsw@525
|
69 end
|
bsw@525
|
70 end
|
bsw@278
|
71
|
bsw@525
|
72 if app.session.member_id
|
bsw@525
|
73 and not initiative.issue.half_frozen
|
bsw@525
|
74 and not initiative.issue.closed
|
bsw@525
|
75 and not initiative.revoked
|
bsw@525
|
76 and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
|
bsw@525
|
77 then
|
bsw@525
|
78 ui.link{
|
bsw@525
|
79 content = function()
|
bsw@525
|
80 slot.put(_"Add suggestion")
|
bsw@525
|
81 end,
|
bsw@525
|
82 module = "suggestion",
|
bsw@525
|
83 view = "new",
|
bsw@525
|
84 params = {
|
bsw@525
|
85 initiative_id = initiative.id
|
bsw@525
|
86 }
|
bsw@525
|
87 }
|
bsw@525
|
88 slot.put(" ")
|
bsw@525
|
89 end
|
bsw@278
|
90
|
bsw@525
|
91 if (initiative.discussion_url and #initiative.discussion_url > 0) then
|
bsw@525
|
92 if initiative.discussion_url:find("^https?://") then
|
bsw@525
|
93 if initiative.discussion_url and #initiative.discussion_url > 0 then
|
bsw@525
|
94 ui.link{
|
bsw@525
|
95 attr = {
|
bsw@525
|
96 target = "_blank",
|
bsw@525
|
97 title = _"Discussion with initiators"
|
bsw@525
|
98 },
|
bsw@525
|
99 text = _"Discuss with initiators",
|
bsw@525
|
100 external = initiative.discussion_url
|
bsw@525
|
101 }
|
bsw@525
|
102 slot.put(" ")
|
bsw@525
|
103 end
|
bsw@525
|
104 else
|
bsw@525
|
105 slot.put(encode.html(initiative.discussion_url))
|
bsw@525
|
106 end
|
bsw@525
|
107 end
|
bsw@525
|
108 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@525
|
109 ui.link{
|
bsw@525
|
110 image = { static = "icons/16/comments.png" },
|
bsw@525
|
111 text = _"change discussion URL",
|
bsw@525
|
112 module = "initiative",
|
bsw@525
|
113 view = "edit",
|
bsw@525
|
114 id = initiative.id
|
bsw@525
|
115 }
|
bsw@525
|
116 slot.put(" ")
|
bsw@525
|
117 end
|
bsw@525
|
118 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@525
|
119 ui.link{
|
bsw@525
|
120 content = function()
|
bsw@525
|
121 ui.image{ static = "icons/16/script_add.png" }
|
bsw@525
|
122 slot.put(_"Edit draft")
|
bsw@525
|
123 end,
|
bsw@525
|
124 module = "draft",
|
bsw@525
|
125 view = "new",
|
bsw@525
|
126 params = { initiative_id = initiative.id }
|
bsw@525
|
127 }
|
bsw@525
|
128 slot.put(" ")
|
bsw@525
|
129 end
|
bsw@280
|
130
|
bsw@525
|
131 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@525
|
132 ui.link{
|
bsw@525
|
133 content = function()
|
bsw@525
|
134 ui.image{ static = "icons/16/script_delete.png" }
|
bsw@525
|
135 slot.put(_"Revoke initiative")
|
bsw@525
|
136 end,
|
bsw@525
|
137 module = "initiative",
|
bsw@525
|
138 view = "revoke",
|
bsw@525
|
139 id = initiative.id
|
bsw@525
|
140 }
|
bsw@525
|
141 slot.put(" ")
|
bsw@525
|
142 end
|
bsw@525
|
143
|
bsw@525
|
144 if not initiative.issue.closed then
|
bsw@525
|
145 local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
|
bsw@525
|
146 if ignored_initiative then
|
bsw@525
|
147 ui.tag{
|
bsw@525
|
148 content = _"You have ignored this initiative"
|
bsw/jbe@19
|
149 }
|
bsw@525
|
150 ui.link{
|
bsw@525
|
151 text = _"Stop ignoring initiative",
|
bsw@525
|
152 module = "initiative",
|
bsw@525
|
153 action = "update_ignore",
|
bsw@525
|
154 id = initiative.id,
|
bsw@525
|
155 params = { delete = true },
|
bsw@525
|
156 routing = {
|
bsw@525
|
157 default = {
|
bsw@525
|
158 mode = "redirect",
|
bsw@525
|
159 module = request.get_module(),
|
bsw@525
|
160 view = request.get_view(),
|
bsw@525
|
161 id = param.get_id_cgi(),
|
bsw@525
|
162 params = param.get_all_cgi()
|
bsw@525
|
163 }
|
bsw@525
|
164 }
|
bsw@525
|
165 }
|
bsw@525
|
166 else
|
bsw@525
|
167 ui.link{
|
bsw@525
|
168 text = _"Ignore initiative",
|
bsw@525
|
169 module = "initiative",
|
bsw@525
|
170 action = "update_ignore",
|
bsw@525
|
171 id = initiative.id,
|
bsw@525
|
172 routing = {
|
bsw@525
|
173 default = {
|
bsw@525
|
174 mode = "redirect",
|
bsw@525
|
175 module = request.get_module(),
|
bsw@525
|
176 view = request.get_view(),
|
bsw@525
|
177 id = param.get_id_cgi(),
|
bsw@525
|
178 params = param.get_all_cgi()
|
bsw@525
|
179 }
|
bsw@525
|
180 }
|
bsw@525
|
181 }
|
bsw@10
|
182 end
|
bsw@525
|
183 end
|