bsw/jbe@19: local initiative = param.get("initiative", "table")
bsw/jbe@19: 
bsw/jbe@19: if initiative.revoked then
bsw/jbe@19:   slot.put(_"Not voted (revoked from initiator)")
bsw/jbe@19: elseif initiative.admitted == false then
bsw/jbe@19:   slot.put(_"Not voted (not admitted)")
bsw/jbe@19: else
bsw/jbe@19: 
bsw@31:   execute.view{
bsw@31:     module = "initiative",
bsw@31:     view = "_battles",
bsw@31:     params = { initiative = initiative }
bsw@31:   }
bsw/jbe@19: 
bsw@286:   slot.put("
")
bsw@286:   
bsw/jbe@19:   ui.container{
bsw/jbe@19:     attr = { class = "heading" },
bsw/jbe@19:     content = _"Member voting"
bsw/jbe@19:   }
bsw/jbe@19: 
bsw/jbe@19:   execute.view{
bsw/jbe@19:     module = "member",
bsw/jbe@19:     view = "_list",
bsw/jbe@19:     params = {
bsw/jbe@19:       initiative = initiative,
bsw@190:       for_votes = true,
bsw/jbe@19:       members_selector =  initiative.issue:get_reference_selector("direct_voters")
bsw/jbe@19:         :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id })
bsw/jbe@19:         :add_field("direct_voter.weight as voter_weight")
bsw/jbe@19:         :add_field("coalesce(vote.grade, 0) as grade")
bsw@190:         :join("initiative", nil, "initiative.id = vote.initiative_id")
bsw@190:         :join("issue", nil, "issue.id = initiative.issue_id")
bsw/jbe@19:     }
bsw/jbe@19:   }
bsw/jbe@19: 
bsw@286:   slot.put("
")
bsw@286:   
bsw@286:   ui.container{
bsw@286:     attr = { class = "heading" },
bsw@286:     content = _"Voting details"
bsw@286:   }
bsw@286:   
bsw@286:   ui.form{
bsw@286:     attr = { class = "vertical" },
bsw@286:     content = function()
bsw@286:  
bsw@286:     ui.field.boolean{ label = _"Direct majority", value = initiative.direct_majority }
bsw@286:     ui.field.boolean{ label = _"Indirect majority", value = initiative.indirect_majority }
bsw@286:     ui.field.text{ label = _"Schulze rank", value = tostring(initiative.schulze_rank) .. " (" .. _("Status quo: #{rank}", { rank = initiative.issue.status_quo_schulze_rank }) .. ")" }
bsw@286:     local texts = {}
bsw@286:     if initiative.reverse_beat_path then
bsw@286:       texts[#texts+1] = _"reverse beat path to status quo (including ties)"
bsw@286:     end
bsw@286:     if initiative.multistage_majority then
bsw@286:       texts[#texts+1] = _"possibly instable result caused by multistage majority"
bsw@286:     end
bsw@286:     if #texts == 0 then
bsw@286:      texts[#texts+1] = _"none"
bsw@286:     end
bsw@286:     ui.field.text{
bsw@286:       label = _"Other failures",
bsw@286:       value = table.concat(texts, ", ")
bsw@286:     }
bsw@286:     ui.field.boolean{ label = _"Eligible as winner", value = initiative.eligible }
bsw@286:   end
bsw@286: }
bsw@286: 
bsw@286: 
bsw/jbe@19: end