liquid_feedback_frontend
annotate app/main/initiative/show.lua @ 5:afd9f769c7ae
Version beta1
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
| author | bsw/jbe |
|---|---|
| date | Fri Dec 25 12:00:00 2009 +0100 (2009-12-25) |
| parents | 80c215dbf076 |
| children | 8d91bccab0bf |
| rev | line source |
|---|---|
| bsw/jbe@0 | 1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() |
| bsw/jbe@0 | 2 |
| bsw/jbe@5 | 3 slot.select("actions", function() |
| bsw/jbe@5 | 4 ui.link{ |
| bsw/jbe@5 | 5 content = function() |
| bsw/jbe@5 | 6 ui.image{ static = "icons/16/script.png" } |
| bsw/jbe@5 | 7 slot.put(_"Show all initiatives") |
| bsw/jbe@5 | 8 end, |
| bsw/jbe@5 | 9 module = "issue", |
| bsw/jbe@5 | 10 view = "show", |
| bsw/jbe@5 | 11 id = initiative.issue.id |
| bsw/jbe@5 | 12 } |
| bsw/jbe@5 | 13 end) |
| bsw/jbe@4 | 14 |
| bsw/jbe@4 | 15 execute.view{ |
| bsw/jbe@4 | 16 module = "issue", |
| bsw/jbe@4 | 17 view = "_show_head", |
| bsw/jbe@4 | 18 params = { issue = initiative.issue } |
| bsw/jbe@4 | 19 } |
| bsw/jbe@4 | 20 |
| bsw/jbe@4 | 21 local initiator = Initiator:by_pk(initiative.id, app.session.member.id) |
| bsw/jbe@4 | 22 |
| bsw@3 | 23 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />') |
| bsw/jbe@0 | 24 |
| bsw/jbe@0 | 25 execute.view{ |
| bsw/jbe@0 | 26 module = "supporter", |
| bsw/jbe@0 | 27 view = "_show_box", |
| bsw/jbe@0 | 28 params = { initiative = initiative } |
| bsw/jbe@0 | 29 } |
| bsw/jbe@0 | 30 |
| bsw/jbe@4 | 31 slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) |
| bsw/jbe@0 | 32 |
| bsw/jbe@0 | 33 slot.select("actions", function() |
| bsw/jbe@4 | 34 if not initiative.issue.fully_frozen and not initiative.issue.closed then |
| bsw@2 | 35 ui.link{ |
| bsw@3 | 36 attr = { class = "action" }, |
| bsw@3 | 37 content = function() |
| bsw@3 | 38 ui.image{ static = "icons/16/script_add.png" } |
| bsw/jbe@4 | 39 slot.put(_"Create alternative initiative") |
| bsw@3 | 40 end, |
| bsw@3 | 41 module = "initiative", |
| bsw@3 | 42 view = "new", |
| bsw@3 | 43 params = { issue_id = initiative.issue.id } |
| bsw@3 | 44 } |
| bsw@3 | 45 end |
| bsw/jbe@4 | 46 end) |
| bsw/jbe@4 | 47 |
| bsw/jbe@4 | 48 |
| bsw/jbe@4 | 49 util.help("initiative.show") |
| bsw/jbe@4 | 50 |
| bsw/jbe@4 | 51 |
| bsw/jbe@4 | 52 ui.container{ |
| bsw/jbe@4 | 53 attr = { class = "vertical" }, |
| bsw/jbe@4 | 54 content = function() |
| bsw/jbe@4 | 55 ui.container{ |
| bsw/jbe@4 | 56 attr = { class = "ui_field_label" }, |
| bsw/jbe@4 | 57 content = _"Discussion URL" |
| bsw/jbe@4 | 58 } |
| bsw/jbe@4 | 59 ui.tag{ |
| bsw/jbe@4 | 60 tag = "span", |
| bsw@3 | 61 content = function() |
| bsw/jbe@4 | 62 if initiative.discussion_url and #initiative.discussion_url > 0 then |
| bsw/jbe@4 | 63 ui.link{ |
| bsw/jbe@4 | 64 attr = { |
| bsw/jbe@4 | 65 class = "actions", |
| bsw/jbe@5 | 66 target = "_blank", |
| bsw/jbe@4 | 67 title = initiative.discussion_url |
| bsw/jbe@4 | 68 }, |
| bsw/jbe@4 | 69 content = function() |
| bsw/jbe@4 | 70 slot.put(encode.html(initiative.discussion_url)) |
| bsw/jbe@4 | 71 end, |
| bsw/jbe@4 | 72 external = initiative.discussion_url |
| bsw/jbe@4 | 73 } |
| bsw/jbe@4 | 74 end |
| bsw/jbe@4 | 75 slot.put(" ") |
| bsw/jbe@4 | 76 if initiator then |
| bsw/jbe@4 | 77 ui.link{ |
| bsw/jbe@4 | 78 attr = { class = "actions" }, |
| bsw/jbe@4 | 79 content = _"(change URL)", |
| bsw/jbe@4 | 80 module = "initiative", |
| bsw/jbe@4 | 81 view = "edit", |
| bsw/jbe@4 | 82 id = initiative.id |
| bsw/jbe@4 | 83 } |
| bsw/jbe@4 | 84 end |
| bsw/jbe@4 | 85 end |
| bsw@3 | 86 } |
| bsw@3 | 87 end |
| bsw/jbe@4 | 88 } |
| bsw/jbe@4 | 89 |
| bsw/jbe@0 | 90 |
| bsw/jbe@0 | 91 |
| bsw/jbe@0 | 92 ui.container{ |
| bsw/jbe@0 | 93 attr = { id = "add_suggestion_form", class = "hidden_inline_form" }, |
| bsw/jbe@0 | 94 content = function() |
| bsw/jbe@0 | 95 |
| bsw/jbe@0 | 96 ui.link{ |
| bsw/jbe@0 | 97 content = _"Close", |
| bsw/jbe@0 | 98 attr = { |
| bsw/jbe@0 | 99 onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)", |
| bsw/jbe@0 | 100 style = "float: right;" |
| bsw/jbe@0 | 101 } |
| bsw/jbe@0 | 102 } |
| bsw/jbe@0 | 103 |
| bsw/jbe@0 | 104 ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" } |
| bsw/jbe@0 | 105 |
| bsw/jbe@0 | 106 |
| bsw/jbe@0 | 107 ui.form{ |
| bsw/jbe@0 | 108 module = "suggestion", |
| bsw/jbe@0 | 109 action = "add", |
| bsw/jbe@0 | 110 params = { initiative_id = initiative.id }, |
| bsw/jbe@0 | 111 routing = { |
| bsw/jbe@0 | 112 default = { |
| bsw/jbe@0 | 113 mode = "redirect", |
| bsw/jbe@0 | 114 module = "initiative", |
| bsw/jbe@0 | 115 view = "show", |
| bsw/jbe@0 | 116 id = initiative.id, |
| bsw/jbe@0 | 117 params = { tab = "suggestion" } |
| bsw/jbe@0 | 118 } |
| bsw/jbe@0 | 119 }, |
| bsw/jbe@0 | 120 attr = { class = "vertical" }, |
| bsw/jbe@0 | 121 content = function() |
| bsw/jbe@4 | 122 local supported = Supporter:by_pk(initiative.id, app.session.member.id) and true or false |
| bsw/jbe@4 | 123 if not supported then |
| bsw/jbe@4 | 124 ui.field.text{ |
| bsw/jbe@4 | 125 attr = { class = "warning" }, |
| bsw/jbe@4 | 126 value = _"You are currently not supporting this initiative. By adding suggestions to this initiative you will automatically become a potential supporter." |
| bsw/jbe@4 | 127 } |
| bsw/jbe@4 | 128 end |
| bsw/jbe@4 | 129 ui.field.text{ label = _"Title (80 chars max)", name = "name" } |
| bsw/jbe@0 | 130 ui.field.text{ label = _"Description", name = "description", multiline = true } |
| bsw/jbe@0 | 131 ui.field.select{ |
| bsw/jbe@0 | 132 label = _"Degree", |
| bsw/jbe@0 | 133 name = "degree", |
| bsw/jbe@0 | 134 foreign_records = { |
| bsw/jbe@0 | 135 { id = 1, name = _"should"}, |
| bsw/jbe@0 | 136 { id = 2, name = _"must"}, |
| bsw/jbe@0 | 137 }, |
| bsw/jbe@0 | 138 foreign_id = "id", |
| bsw/jbe@0 | 139 foreign_name = "name" |
| bsw/jbe@0 | 140 } |
| bsw/jbe@0 | 141 ui.submit{ text = _"Commit suggestion" } |
| bsw/jbe@0 | 142 end |
| bsw/jbe@0 | 143 } |
| bsw/jbe@0 | 144 end |
| bsw/jbe@0 | 145 } |
| bsw/jbe@0 | 146 |
| bsw@2 | 147 local supporter = app.session.member:get_reference_selector("supporters") |
| bsw@2 | 148 :add_where{ "initiative_id = ?", initiative.id } |
| bsw@2 | 149 :optional_object_mode() |
| bsw@2 | 150 :exec() |
| bsw@2 | 151 |
| bsw@2 | 152 if supporter then |
| bsw@2 | 153 local old_draft_id = supporter.draft_id |
| bsw@2 | 154 local new_draft_id = initiative.current_draft.id |
| bsw@2 | 155 if old_draft_id ~= new_draft_id then |
| bsw@2 | 156 ui.container{ |
| bsw@2 | 157 attr = { class = "draft_updated_info" }, |
| bsw@2 | 158 content = function() |
| bsw@2 | 159 slot.put("The draft of this initiative has been updated!") |
| bsw@2 | 160 slot.put(" ") |
| bsw@2 | 161 ui.link{ |
| bsw@2 | 162 content = _"Show diff", |
| bsw@2 | 163 module = "draft", |
| bsw@2 | 164 view = "diff", |
| bsw@2 | 165 params = { |
| bsw@2 | 166 old_draft_id = old_draft_id, |
| bsw@2 | 167 new_draft_id = new_draft_id |
| bsw@2 | 168 } |
| bsw@2 | 169 } |
| bsw@2 | 170 slot.put(" ") |
| bsw@2 | 171 ui.link{ |
| bsw@2 | 172 content = _"Refresh support to current draft", |
| bsw@2 | 173 module = "initiative", |
| bsw@2 | 174 action = "add_support", |
| bsw@2 | 175 id = initiative.id, |
| bsw@2 | 176 routing = { |
| bsw@2 | 177 default = { |
| bsw@2 | 178 mode = "redirect", |
| bsw@2 | 179 module = "initiative", |
| bsw@2 | 180 view = "show", |
| bsw@2 | 181 id = initiative.id |
| bsw@2 | 182 } |
| bsw@2 | 183 } |
| bsw@2 | 184 } |
| bsw@2 | 185 end |
| bsw@2 | 186 } |
| bsw@2 | 187 end |
| bsw@2 | 188 end |
| bsw/jbe@0 | 189 |
| bsw/jbe@4 | 190 |
| bsw/jbe@0 | 191 ui.tabs{ |
| bsw/jbe@0 | 192 { |
| bsw/jbe@0 | 193 name = "current_draft", |
| bsw/jbe@0 | 194 label = _"Current draft", |
| bsw/jbe@0 | 195 content = function() |
| bsw/jbe@4 | 196 if initiator then |
| bsw/jbe@4 | 197 ui.link{ |
| bsw/jbe@4 | 198 content = function() |
| bsw/jbe@4 | 199 ui.image{ static = "icons/16/script_add.png" } |
| bsw/jbe@4 | 200 slot.put(_"Edit draft") |
| bsw/jbe@4 | 201 end, |
| bsw/jbe@4 | 202 module = "draft", |
| bsw/jbe@4 | 203 view = "new", |
| bsw/jbe@4 | 204 params = { initiative_id = initiative.id } |
| bsw/jbe@4 | 205 } |
| bsw/jbe@4 | 206 end |
| bsw/jbe@0 | 207 execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } } |
| bsw/jbe@0 | 208 end |
| bsw/jbe@0 | 209 }, |
| bsw/jbe@0 | 210 { |
| bsw/jbe@0 | 211 name = "suggestion", |
| bsw/jbe@0 | 212 label = _"Suggestions", |
| bsw/jbe@0 | 213 content = function() |
| bsw/jbe@4 | 214 execute.view{ |
| bsw/jbe@4 | 215 module = "suggestion", |
| bsw/jbe@4 | 216 view = "_list", |
| bsw/jbe@4 | 217 params = { |
| bsw/jbe@4 | 218 initiative = initiative, |
| bsw/jbe@4 | 219 suggestions_selector = initiative:get_reference_selector("suggestions") |
| bsw/jbe@4 | 220 } |
| bsw/jbe@4 | 221 } |
| bsw/jbe@0 | 222 slot.put("<br />") |
| bsw/jbe@5 | 223 if not initiative.issue.fully_frozen and not initiative.issue.closed then |
| bsw/jbe@0 | 224 ui.link{ |
| bsw/jbe@0 | 225 content = function() |
| bsw/jbe@0 | 226 ui.image{ static = "icons/16/comment_add.png" } |
| bsw/jbe@0 | 227 slot.put(_"Add new suggestion") |
| bsw/jbe@0 | 228 end, |
| bsw/jbe@0 | 229 attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" }, |
| bsw/jbe@0 | 230 static = "#" |
| bsw/jbe@0 | 231 } |
| bsw/jbe@0 | 232 end |
| bsw/jbe@0 | 233 end |
| bsw/jbe@0 | 234 }, |
| bsw/jbe@0 | 235 { |
| bsw/jbe@5 | 236 name = "satisfied_supporter", |
| bsw/jbe@0 | 237 label = _"Supporter", |
| bsw/jbe@0 | 238 content = function() |
| bsw@3 | 239 execute.view{ |
| bsw@3 | 240 module = "member", |
| bsw@3 | 241 view = "_list", |
| bsw@3 | 242 params = { |
| bsw@3 | 243 initiative = initiative, |
| bsw@3 | 244 members_selector = initiative:get_reference_selector("supporting_members_snapshot") |
| bsw@3 | 245 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") |
| bsw/jbe@4 | 246 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") |
| bsw/jbe@4 | 247 :add_field("direct_interest_snapshot.weight") |
| bsw@3 | 248 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") |
| bsw/jbe@5 | 249 :add_where("direct_supporter_snapshot.satisfied") |
| bsw/jbe@5 | 250 } |
| bsw/jbe@5 | 251 } |
| bsw/jbe@5 | 252 end |
| bsw/jbe@5 | 253 }, |
| bsw/jbe@5 | 254 { |
| bsw/jbe@5 | 255 name = "supporter", |
| bsw/jbe@5 | 256 label = _"Potential supporter", |
| bsw/jbe@5 | 257 content = function() |
| bsw/jbe@5 | 258 execute.view{ |
| bsw/jbe@5 | 259 module = "member", |
| bsw/jbe@5 | 260 view = "_list", |
| bsw/jbe@5 | 261 params = { |
| bsw/jbe@5 | 262 initiative = initiative, |
| bsw/jbe@5 | 263 members_selector = initiative:get_reference_selector("supporting_members_snapshot") |
| bsw/jbe@5 | 264 :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") |
| bsw/jbe@5 | 265 :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") |
| bsw/jbe@5 | 266 :add_field("direct_interest_snapshot.weight") |
| bsw/jbe@5 | 267 :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") |
| bsw/jbe@5 | 268 :add_where("NOT direct_supporter_snapshot.satisfied") |
| bsw@3 | 269 } |
| bsw@3 | 270 } |
| bsw/jbe@0 | 271 end |
| bsw/jbe@0 | 272 }, |
| bsw/jbe@0 | 273 { |
| bsw/jbe@0 | 274 name = "initiators", |
| bsw/jbe@0 | 275 label = _"Initiators", |
| bsw/jbe@0 | 276 content = function() |
| bsw/jbe@0 | 277 execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } } |
| bsw/jbe@0 | 278 end |
| bsw/jbe@0 | 279 }, |
| bsw/jbe@0 | 280 { |
| bsw/jbe@0 | 281 name = "drafts", |
| bsw/jbe@0 | 282 label = _"Old drafts", |
| bsw/jbe@0 | 283 content = function() |
| bsw/jbe@0 | 284 execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } } |
| bsw/jbe@0 | 285 end |
| bsw/jbe@0 | 286 }, |
| bsw@2 | 287 { |
| bsw@2 | 288 name = "details", |
| bsw@2 | 289 label = _"Details", |
| bsw@2 | 290 content = function() |
| bsw@2 | 291 ui.form{ |
| bsw@2 | 292 attr = { class = "vertical" }, |
| bsw@2 | 293 record = initiative, |
| bsw@2 | 294 readonly = true, |
| bsw@2 | 295 content = function() |
| bsw@2 | 296 ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name } |
| bsw@2 | 297 ui.field.text{ |
| bsw@2 | 298 label = _"Created at", |
| bsw@2 | 299 value = tostring(initiative.created) |
| bsw@2 | 300 } |
| bsw@2 | 301 ui.field.text{ |
| bsw@2 | 302 label = _"Created at", |
| bsw@2 | 303 value = format.timestamp(initiative.created) |
| bsw@2 | 304 } |
| bsw@2 | 305 ui.field.date{ label = _"Revoked at", name = "revoked" } |
| bsw@2 | 306 ui.field.boolean{ label = _"Admitted", name = "admitted" } |
| bsw@2 | 307 end |
| bsw@2 | 308 } |
| bsw@2 | 309 end |
| bsw@2 | 310 }, |
| bsw/jbe@0 | 311 } |
| bsw/jbe@0 | 312 |
| bsw/jbe@0 | 313 |