liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 1220:af42478acf74

Avoid executing commands after error in lf4rcs.commit(...)
author jbe
date Tue Dec 01 02:10:04 2015 +0100 (2015-12-01)
parents 7e48d429389f
children 32cc544d5a5b
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw@1045 2 local for_event = param.get("for_event", atom.boolean)
bsw@1045 3
bsw@1045 4 local issue = initiative.issue
bsw/jbe@19 5
bsw@715 6 local class = "initiative"
bsw/jbe@19 7
bsw@1045 8 if initiative.rank == 1 then
bsw@1045 9 class = class .. " rank1"
bsw@715 10 end
bsw@715 11
bsw@1045 12 if initiative.revoked then
bsw@1045 13 class = class .. " revoked"
bsw@898 14 end
bsw@898 15
bsw@1045 16 ui.container{
bsw@1045 17 attr = { class = class },
bsw@1045 18 content = function ()
bsw@1045 19 if initiative.rank ~= 1 and not for_event then
bsw@1045 20 execute.view {
bsw@1045 21 module = "initiative", view = "_bargraph", params = {
bsw@1045 22 initiative = initiative,
bsw@1045 23 battled_initiative = issue.initiatives[1]
bsw@373 24 }
bsw/jbe@19 25 }
bsw@1045 26 slot.put(" ")
bsw/jbe@19 27 end
bsw@1045 28 ui.tag {
bsw@1045 29 attr = { class = "initiative_name" },
bsw@1045 30 content = function()
bsw@1045 31 ui.link {
bsw@1045 32 text = initiative.display_name,
bsw@1045 33 module = "initiative", view = "show", id = initiative.id
bsw@551 34 }
bsw@1045 35 slot.put(" ")
bsw@1045 36 if initiative.vote_grade ~= nil then
bsw@1045 37 if initiative.vote_grade > 0 then
bsw@1045 38 local text = _"voted yes"
bsw@1045 39 ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" }
bsw@1045 40 elseif initiative.vote_grade == 0 then
bsw@1045 41 elseif initiative.vote_grade < 0 then
bsw@1045 42 local text = _"voted no"
bsw@1045 43 ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/voted_no.png" }
bsw@862 44 end
bsw@1045 45 elseif app.session.member then
bsw@1045 46 if initiative.member_info.supported then
bsw@1045 47 if initiative.member_info.satisfied then
bsw@1045 48 local text = _"supporter"
bsw@1045 49 ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_satisfied.png" }
bsw@1045 50 else
bsw@1045 51 local text = _"supporter with restricting suggestions"
bsw@1045 52 ui.image { attr = { class = "icon16", title = text, alt = text }, static = "icons/32/support_unsatisfied.png" }
bsw@1045 53 end
bsw@862 54 end
bsw@556 55 end
bsw@551 56 end
bsw@1045 57 }
bsw@1045 58
bsw@556 59 end
bsw@1045 60 }
bsw@1045 61
bsw@1045 62 if initiative.rank == 1
bsw@1045 63 and issue.voter_count
bsw@1045 64 and initiative.positive_votes ~= nil
bsw@1045 65 and initiative.negative_votes ~= nil
bsw@1045 66 and not for_event
bsw@1045 67 then
bsw@1045 68 local result = ""
bsw@1045 69 if initiative.eligible then
bsw@1045 70 result = _("Reached #{sign}#{num}/#{den}", {
bsw@1045 71 sign = issue.policy.direct_majority_strict and ">" or "≥",
bsw@1045 72 num = issue.policy.direct_majority_num,
bsw@1045 73 den = issue.policy.direct_majority_den
bsw@1045 74 })
bsw@1045 75 else
bsw@1045 76 result = _("Failed #{sign}#{num}/#{den}", {
bsw@1045 77 sign = issue.policy.direct_majority_strict and ">" or "≥",
bsw@1045 78 num = issue.policy.direct_majority_num,
bsw@1045 79 den = issue.policy.direct_majority_den
bsw@1045 80 })
bsw@1045 81 end
bsw@1045 82 local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes
bsw@1045 83
bsw@1045 84 local result_text
bsw@1045 85
bsw@1045 86 if issue.voter_count > 0 then
bsw@1045 87 result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", {
bsw@1045 88 result = result,
bsw@1045 89 yes_count = initiative.positive_votes,
bsw@1210 90 yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count),
bsw@1045 91 neutral_count = neutral_count,
bsw@1210 92 neutral_percent = format.percent_floor(neutral_count, issue.voter_count),
bsw@1045 93 no_count = initiative.negative_votes,
bsw@1210 94 no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count)
bsw@1045 95 })
bsw@1045 96 else
bsw@1045 97 result_text = _("#{result}: No votes (0)", { result = result })
bsw@1045 98 end
bsw@1045 99
bsw@1045 100 ui.container { attr = { class = "result" }, content = result_text }
bsw@373 101
bsw@1045 102 end
bsw@1045 103

Impressum / About Us