liquid_feedback_frontend

annotate app/main/lf2/initiative.lua @ 222:41bb8f0b2c9a

Fixed syntax error
author bsw
date Sun Mar 13 17:01:48 2011 +0100 (2011-03-13)
parents 73dbc9e2bfd4
children
rev   line source
bsw@211 1 slot.set_layout("lf2")
bsw@211 2
bsw@213 3 slot.put_into("leftright_pre", '<div class="sidebar_right">')
bsw@213 4 slot.put_into("leftright_post", '</div>')
bsw@213 5
bsw@211 6 local initiative = Initiative:by_id(param.get_id())
bsw@211 7
bsw@211 8 local issue = initiative.issue
bsw@213 9 issue:load("interest_for_member", { member_id = app.session.member_id }, "interest")
bsw@211 10
bsw@211 11 local supporting_members_selector = Member:new_selector()
bsw@211 12 :join("direct_supporter_snapshot", "dss", { "dss.issue_id = ? AND dss.initiative_id = ? AND dss.member_id = member.id and dss.event = (select latest_snapshot_event from issue where id = ?)", issue.id, initiative.id, issue.id })
bsw@211 13 :join("direct_interest_snapshot", "dis", { "dis.issue_id = ? AND dis.member_id = member.id and dis.event = (select latest_snapshot_event from issue where id = ?)", issue.id, issue.id })
bsw@211 14 :add_field("dis.weight", "weight")
bsw@211 15 :add_order_by("dis.weight DESC")
bsw@211 16 local supporting_members = supporting_members_selector:exec()
bsw@211 17
bsw@211 18 local voting_members_selector = Member:new_selector()
bsw@211 19 :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id })
bsw@211 20 :add_field("direct_voter.weight", "weight")
bsw@211 21 :add_order_by("direct_voter.weight DESC")
bsw@211 22 local voting_members = voting_members_selector:exec()
bsw@211 23
bsw@211 24 local alternative_initiatives = initiative.issue.initiatives
bsw@211 25 alternative_initiatives:load("initiating_members", nil, "initiating_members")
bsw@211 26
bsw@215 27 local support = Supporter:by_pk(initiative.id, app.session.member.id)
bsw@215 28
bsw@215 29 app.topnav_phase = issue.phase
bsw@217 30 app.topnav_area_id = issue.area_id
bsw@217 31 app.topnav_unit_id = issue.area.unit_id
bsw@211 32
bsw@211 33 slot.select("sidebar", function()
bsw@211 34
bsw@215 35 execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id, alternative_initiatives = alternative_initiatives } }
bsw@215 36
bsw@211 37 execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
bsw@211 38 initiative = initiative
bsw@211 39 } }
bsw@211 40
bsw@211 41 end)
bsw@211 42
bsw@211 43 local draft = initiative.current_draft
bsw@211 44
bsw@211 45 ui.box{
bsw@211 46 content = function()
bsw@211 47
bsw@217 48 ui.box_row{ class = "initiative head", content = function() ui.box_col { content = function()
bsw@211 49 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
bsw@211 50 end } end }
bsw@211 51
bsw@217 52 if initiative.issue.closed then
bsw@217 53 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@215 54 if initiative.issue.accepted then
bsw@215 55 if initiative.admitted then
bsw@215 56 if initiative.agreed then
bsw@215 57 if initiative.rank == 1 then
bsw@215 58 ui.image{ static = "lf2/icon_award_gold.png" }
bsw@215 59 slot.put(" ")
bsw@215 60 ui.tag{ content = _"Approved" }
bsw@215 61 else
bsw@215 62 ui.image{ static = "lf2/icon_award_silver.png" }
bsw@215 63 slot.put(" ")
bsw@215 64 ui.tag{ content = _("Not approved (rank #{rank})", { rank = initiative.rank }) }
bsw@215 65 end
bsw@215 66 else
bsw@215 67 ui.image{ static = "lf2/icon_cross.png" }
bsw@215 68 slot.put(" ")
bsw@217 69 ui.tag{ content = _"Initiative not approved (no majority)" }
bsw@215 70 end
bsw@217 71 slot.put(" &middot; ")
bsw@217 72 ui.tag{ class = "yes_count", content = _("#{count} Yes", { count = initiative.positive_votes }) }
bsw@217 73 slot.put(" &middot; ")
bsw@217 74 ui.tag{ class = "no_count", content = _("#{count} No", { count = initiative.negative_votes }) }
bsw@217 75 slot.put(" &middot; ")
bsw@217 76 ui.tag{ class = "abstention_count", content = _("#{count} Abstention", { count = initiative.issue.voter_count - initiative.positive_votes - initiative.negative_votes }) }
bsw@217 77
bsw@215 78 else
bsw@215 79 ui.image{ static = "lf2/icon_cross.png" }
bsw@215 80 slot.put(" ")
bsw@217 81 ui.tag{ content = _"Initiative not admitted (quorum failed)" }
bsw@215 82 end
bsw@215 83 else
bsw@215 84 ui.image{ static = "lf2/icon_cross.png" }
bsw@215 85 slot.put(" ")
bsw@217 86 ui.tag{ content = _"Issue not accepted (quorum failed)" }
bsw@215 87 end
bsw@217 88 end } end }
bsw@217 89 end
bsw@217 90
bsw@217 91 ui.box_row{ class = "", content = function() ui.box_col{ content = function()
bsw@211 92 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@215 93 if initiative.admitted and initiative.issue.ranks_available then
bsw@215 94 ui.link{ external = "#votes", text = _("#{vote_count}+#{delegated_weight} votes", { vote_count = #voting_members, delegated_weight = initiative.issue.voter_count - #voting_members }) }
bsw@217 95 slot.put(" &middot; ")
bsw@215 96 end
bsw@215 97 end
bsw@211 98 ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 }) }
bsw@211 99 slot.put(" &middot; ")
bsw@215 100 ui.link{ external = "#supporters", text = _("#{supporter_count}+#{delegated_weight} supporters", { supporter_count = #supporting_members, delegated_weight = initiative.supporter_count - #supporting_members }) }
bsw@211 101 end } end }
bsw@211 102
bsw@215 103 execute.view{ module = "lf2", view = "_initiative_support", params = {
bsw@215 104 initiative = initiative
bsw@215 105 } }
bsw@215 106
bsw@215 107 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Current draft" } end }
bsw@217 108 ui.box_row{ class = "member_content", content = function() ui.box_col{ class = "draft", content = function()
bsw@211 109 execute.view{ module = "lf2", view = "_draft", params = { draft = draft } }
bsw@211 110 end } end }
bsw@211 111
bsw@215 112 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@215 113 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Voters" } end }
bsw@211 114 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@216 115 execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members, issue_id = initiative.issue_id } }
bsw@211 116 end } end }
bsw@211 117 end
bsw@211 118
bsw@215 119 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Suggestions" } end }
bsw@211 120 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@211 121 slot.put("suggestions")
bsw@211 122 end } end }
bsw@215 123
bsw@215 124 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Supporters" } end }
bsw@211 125 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@216 126 execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members, issue_id = initiative.issue_id } }
bsw@211 127 end } end }
bsw@215 128
bsw@215 129 end }

Impressum / About Us