| rev | 
   line source | 
| 
bsw@1045
 | 
     1 local initiative = param.get("initiative", "table")
 | 
| 
bsw@1045
 | 
     2 
 | 
| 
bsw@1045
 | 
     3 
 | 
| 
bsw@1045
 | 
     4 -- voting results
 | 
| 
bsw@1045
 | 
     5 if initiative.issue.fully_frozen and initiative.issue.closed and initiative.admitted
 | 
| 
bsw@1045
 | 
     6   and initiative.issue.voter_count then
 | 
| 
bsw@1045
 | 
     7   local class = initiative.winner and "sectionRow admitted_info" or "sectionRow not_admitted_info"
 | 
| 
bsw@1045
 | 
     8   ui.container{
 | 
| 
bsw@1045
 | 
     9     attr = { class = class },
 | 
| 
bsw@1045
 | 
    10     content = function()
 | 
| 
bsw@1045
 | 
    11       local max_value = initiative.issue.voter_count
 | 
| 
bsw@1045
 | 
    12       local positive_votes = initiative.positive_votes
 | 
| 
bsw@1045
 | 
    13       local negative_votes = initiative.negative_votes
 | 
| 
bsw@1045
 | 
    14       local abstention_votes = max_value - 
 | 
| 
bsw@1045
 | 
    15               negative_votes - 
 | 
| 
bsw@1045
 | 
    16               positive_votes
 | 
| 
bsw@1045
 | 
    17       local head_text
 | 
| 
bsw/jbe@1309
 | 
    18 
 | 
| 
bsw/jbe@1309
 | 
    19       util.initiative_pie( initiative )
 | 
| 
bsw/jbe@1309
 | 
    20       
 | 
| 
bsw@1045
 | 
    21       if initiative.winner then
 | 
| 
bsw@1045
 | 
    22         head_text = _"Approved"
 | 
| 
bsw@1045
 | 
    23       elseif initiative.rank then
 | 
| 
bsw@1045
 | 
    24         head_text = _("Rejected (rank #{rank})", { rank = initiative.rank })
 | 
| 
bsw@1045
 | 
    25       else
 | 
| 
bsw@1045
 | 
    26         head_text = _"Rejected"
 | 
| 
bsw@1045
 | 
    27       end
 | 
| 
bsw@1045
 | 
    28 
 | 
| 
bsw@1045
 | 
    29       ui.heading { level = 1, content = head_text }
 | 
| 
bsw@1045
 | 
    30       
 | 
| 
bsw@1045
 | 
    31       ui.tag { tag = "table", content = function ()
 | 
| 
bsw@1045
 | 
    32         ui.tag { tag = "tr", attr = { class = "yes" }, content = function ()
 | 
| 
bsw@1045
 | 
    33           ui.tag { tag = "td", content = 
 | 
| 
bsw@1045
 | 
    34             tostring(positive_votes) 
 | 
| 
bsw@1045
 | 
    35           }
 | 
| 
bsw@1045
 | 
    36           ui.tag { tag = "th", content = _"Yes" }
 | 
| 
bsw@1045
 | 
    37           ui.tag { tag = "td", content = 
 | 
| 
bsw@1210
 | 
    38             format.percent_floor(positive_votes, max_value) 
 | 
| 
bsw@1045
 | 
    39           }
 | 
| 
bsw@1045
 | 
    40           ui.tag { tag = "th", content = _"Yes" }
 | 
| 
bsw@1045
 | 
    41         end }
 | 
| 
bsw/jbe@1309
 | 
    42         ui.tag { tag = "tr", attr = { class = "no" }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
    43           ui.tag { tag = "td", content = 
 | 
| 
bsw/jbe@1309
 | 
    44             tostring(negative_votes)
 | 
| 
bsw/jbe@1309
 | 
    45           }
 | 
| 
bsw/jbe@1309
 | 
    46           ui.tag { tag = "th", content = _"No" }
 | 
| 
bsw/jbe@1309
 | 
    47           ui.tag { tag = "td", content =
 | 
| 
bsw/jbe@1309
 | 
    48             format.percent_floor(negative_votes, max_value) 
 | 
| 
bsw/jbe@1309
 | 
    49           }
 | 
| 
bsw/jbe@1309
 | 
    50           ui.tag { tag = "th", content = _"No" }
 | 
| 
bsw/jbe@1309
 | 
    51         end }
 | 
| 
bsw@1045
 | 
    52         ui.tag { tag = "tr", attr = { class = "abstention" }, content = function ()
 | 
| 
bsw@1045
 | 
    53           ui.tag { tag = "td", content = 
 | 
| 
bsw@1045
 | 
    54             tostring(abstention_votes)
 | 
| 
bsw@1045
 | 
    55           }
 | 
| 
bsw@1045
 | 
    56           ui.tag { tag = "th", content = _"Abstention" }
 | 
| 
bsw@1045
 | 
    57           ui.tag { tag = "td", content =
 | 
| 
bsw@1210
 | 
    58             format.percent_floor(abstention_votes, max_value) 
 | 
| 
bsw@1045
 | 
    59           }
 | 
| 
bsw@1045
 | 
    60           ui.tag { tag = "th", content = _"Abstention" }
 | 
| 
bsw@1045
 | 
    61         end }
 | 
| 
bsw@1045
 | 
    62       end }
 | 
| 
bsw@1045
 | 
    63     end
 | 
| 
bsw@1045
 | 
    64   }
 | 
| 
bsw@1045
 | 
    65 end
 | 
| 
bsw@1045
 | 
    66   
 | 
| 
bsw@1045
 | 
    67 -- initiative not admitted info
 | 
| 
bsw@1045
 | 
    68 if initiative.admitted == false then
 | 
| 
bsw@1045
 | 
    69   local policy = initiative.issue.policy
 | 
| 
bsw@1045
 | 
    70   ui.container{
 | 
| 
bsw@1045
 | 
    71     attr = { class = "sectionRow not_admitted_info" },
 | 
| 
bsw@1045
 | 
    72     content = function ()
 | 
| 
bsw@1045
 | 
    73       ui.heading { level = 1, content = _"Initiative not admitted" }
 | 
| 
bsw@1482
 | 
    74       local num = policy.initiative_quorum_num                                                                                                        
 | 
| 
bsw@1482
 | 
    75       local den = policy.initiative_quorum_den                                                                                                        
 | 
| 
bsw@1482
 | 
    76       local quorums = {}                                                                                                                              
 | 
| 
bsw@1482
 | 
    77       if num and num > 0 and den == 100 or den == 10 then                                                                                             
 | 
| 
bsw@1482
 | 
    78         table.insert(quorums, _("#{percentage}%", { percentage = num * 100 / den }))                                                                  
 | 
| 
bsw@1482
 | 
    79       elseif num and num > 0 and den and den > 0 then                                                                                                 
 | 
| 
bsw@1482
 | 
    80         table.insert(quorums, num .. "/" .. den)                                                                                                      
 | 
| 
bsw@1482
 | 
    81       end                                                                                                                                             
 | 
| 
bsw@1482
 | 
    82       if policy.initiative_quorum then                                                                                                                
 | 
| 
bsw@1482
 | 
    83         table.insert(quorums, policy.initiative_quorum)                                                                                               
 | 
| 
bsw@1482
 | 
    84       end                                                                                                                                             
 | 
| 
bsw@1482
 | 
    85       local quorum = table.concat(quorums, " / ")                                                                                                     
 | 
| 
bsw@1482
 | 
    86                                                                                                                                                       
 | 
| 
bsw@1482
 | 
    87       ui.container { content = _("This initiative has not been admitted! It failed the 2nd quorum of #{quorum}.", { quorum = quorum } ) }             
 | 
| 
bsw@1045
 | 
    88     end
 | 
| 
bsw@1045
 | 
    89   }
 | 
| 
bsw@1045
 | 
    90 end
 | 
| 
bsw@1045
 | 
    91 
 | 
| 
bsw@1045
 | 
    92 -- initiative revoked info
 | 
| 
bsw@1045
 | 
    93 if initiative.revoked then
 | 
| 
bsw@1045
 | 
    94   ui.container{
 | 
| 
bsw@1045
 | 
    95     attr = { class = "sectionRow revoked_info" },
 | 
| 
bsw@1045
 | 
    96     content = function()
 | 
| 
bsw@1045
 | 
    97       ui.heading { level = 1, content = _"Initiative revoked" }
 | 
| 
bsw@1045
 | 
    98       slot.put(_("This initiative has been revoked at #{revoked} by:", {
 | 
| 
bsw@1045
 | 
    99         revoked = format.timestamp(initiative.revoked)
 | 
| 
bsw@1045
 | 
   100       }))
 | 
| 
bsw@1045
 | 
   101       slot.put(" ")
 | 
| 
bsw@1053
 | 
   102       if app.session:has_access("authors_pseudonymous") then
 | 
| 
bsw@1053
 | 
   103         ui.link{
 | 
| 
bsw@1053
 | 
   104           module = "member", view = "show", id = initiative.revoked_by_member_id,
 | 
| 
bsw@1053
 | 
   105           content = initiative.revoked_by_member.name
 | 
| 
bsw@1053
 | 
   106         }
 | 
| 
bsw@1053
 | 
   107       else
 | 
| 
bsw@1055
 | 
   108         ui.tag{ content = _"[Not public]" }
 | 
| 
bsw@1053
 | 
   109       end
 | 
| 
bsw@1045
 | 
   110       local suggested_initiative = initiative.suggested_initiative
 | 
| 
bsw@1045
 | 
   111       if suggested_initiative then
 | 
| 
bsw@1045
 | 
   112         slot.put("<br /><br />")
 | 
| 
bsw@1045
 | 
   113         slot.put(_("The initiators suggest to support the following initiative:"))
 | 
| 
bsw@1045
 | 
   114         slot.put("<br />")
 | 
| 
bsw@1045
 | 
   115         ui.link{
 | 
| 
bsw@1045
 | 
   116           content = suggested_initiative.display_name,
 | 
| 
bsw@1045
 | 
   117           module = "initiative",
 | 
| 
bsw@1045
 | 
   118           view = "show",
 | 
| 
bsw@1045
 | 
   119           id = suggested_initiative.id
 | 
| 
bsw@1045
 | 
   120         }
 | 
| 
bsw@1045
 | 
   121       end
 | 
| 
bsw@1045
 | 
   122     end
 | 
| 
bsw@1045
 | 
   123   }
 | 
| 
bsw@1045
 | 
   124 end
 | 
| 
bsw/jbe@1309
 | 
   125  
 |