| rev | 
   line source | 
| 
bsw/jbe@19
 | 
     1 local initiative = param.get("initiative", "table")
 | 
| 
bsw/jbe@19
 | 
     2 local initiator = param.get("initiator", "table")
 | 
| 
bsw/jbe@19
 | 
     3 
 | 
| 
bsw@272
 | 
     4 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
 | 
| 
bsw@272
 | 
     5   :add_field("initiator.accepted", "accepted")
 | 
| 
bsw@272
 | 
     6 
 | 
| 
bsw@272
 | 
     7 if not (initiator and initiator.accepted) then
 | 
| 
bsw@272
 | 
     8   initiators_members_selector:add_where("initiator.accepted")
 | 
| 
bsw@272
 | 
     9 end
 | 
| 
bsw@272
 | 
    10 
 | 
| 
bsw@272
 | 
    11 local initiators = initiators_members_selector:exec()
 | 
| 
bsw@272
 | 
    12 
 | 
| 
bsw@274
 | 
    13 
 | 
| 
bsw@274
 | 
    14 local initiatives_selector = initiative.issue:get_reference_selector("initiatives")
 | 
| 
bsw@274
 | 
    15 slot.select("initiatives_list", function()
 | 
| 
bsw@274
 | 
    16   execute.view{
 | 
| 
bsw@274
 | 
    17     module = "initiative",
 | 
| 
bsw@274
 | 
    18     view = "_list",
 | 
| 
bsw@274
 | 
    19     params = {
 | 
| 
bsw@274
 | 
    20       issue = initiative.issue,
 | 
| 
bsw@274
 | 
    21       initiatives_selector = initiatives_selector,
 | 
| 
bsw@274
 | 
    22       no_sort = true, highlight_initiative = initiative, limit = 3
 | 
| 
bsw@274
 | 
    23     }
 | 
| 
bsw@274
 | 
    24   }
 | 
| 
bsw@274
 | 
    25 end)
 | 
| 
bsw@274
 | 
    26 
 | 
| 
bsw@272
 | 
    27 slot.select("initiative_head", function()
 | 
| 
bsw@272
 | 
    28 
 | 
| 
bsw@272
 | 
    29   ui.container{
 | 
| 
bsw@272
 | 
    30     attr = { class = "initiative_name" },
 | 
| 
bsw@272
 | 
    31     content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
 | 
| 
bsw@272
 | 
    32   }
 | 
| 
bsw@276
 | 
    33   if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then
 | 
| 
bsw@276
 | 
    34     ui.tag{
 | 
| 
bsw@276
 | 
    35       attr = { class = "initiator_names" },
 | 
| 
bsw@276
 | 
    36       content = function()
 | 
| 
bsw@276
 | 
    37         ui.tag{ content = _"by" }
 | 
| 
bsw@276
 | 
    38         slot.put(" ")
 | 
| 
bsw@276
 | 
    39         for i, initiator in ipairs(initiators) do
 | 
| 
bsw@276
 | 
    40           if i == #initiators and i > 1 then
 | 
| 
bsw@276
 | 
    41             slot.put(" ", _"and", " ")
 | 
| 
bsw@276
 | 
    42           elseif i > 1 then
 | 
| 
bsw@276
 | 
    43             slot.put(", ")
 | 
| 
bsw@276
 | 
    44           end
 | 
| 
bsw@276
 | 
    45           ui.link{
 | 
| 
bsw@276
 | 
    46             text = initiator.name,
 | 
| 
bsw@276
 | 
    47             module = "member", view = "show", id = initiator.id
 | 
| 
bsw@276
 | 
    48           }
 | 
| 
bsw@272
 | 
    49         end
 | 
| 
bsw@272
 | 
    50       end
 | 
| 
bsw@276
 | 
    51     }
 | 
| 
bsw@276
 | 
    52   end
 | 
| 
bsw@272
 | 
    53 
 | 
| 
bsw@272
 | 
    54   if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
 | 
| 
bsw@272
 | 
    55     slot.put(" · ")
 | 
| 
bsw@272
 | 
    56     ui.link{
 | 
| 
bsw@272
 | 
    57       attr = { class = "action" },
 | 
| 
bsw@272
 | 
    58       content = function()
 | 
| 
bsw@272
 | 
    59         slot.put(_"Invite initiator")
 | 
| 
bsw@272
 | 
    60       end,
 | 
| 
bsw@272
 | 
    61       module = "initiative",
 | 
| 
bsw@272
 | 
    62       view = "add_initiator",
 | 
| 
bsw@272
 | 
    63       params = { initiative_id = initiative.id }
 | 
| 
bsw@272
 | 
    64     }
 | 
| 
bsw@272
 | 
    65     if #initiators > 1 then
 | 
| 
bsw@272
 | 
    66       slot.put(" · ")
 | 
| 
bsw@272
 | 
    67       ui.link{
 | 
| 
bsw@272
 | 
    68         content = function()
 | 
| 
bsw@272
 | 
    69           slot.put(_"Remove initiator")
 | 
| 
bsw@272
 | 
    70         end,
 | 
| 
bsw@272
 | 
    71         module = "initiative",
 | 
| 
bsw@272
 | 
    72         view = "remove_initiator",
 | 
| 
bsw@272
 | 
    73         params = { initiative_id = initiative.id }
 | 
| 
bsw@272
 | 
    74       }
 | 
| 
bsw@272
 | 
    75     end
 | 
| 
bsw@272
 | 
    76   end
 | 
| 
bsw@272
 | 
    77   if initiator and initiator.accepted == false then
 | 
| 
bsw@272
 | 
    78       slot.put(" · ")
 | 
| 
bsw@272
 | 
    79       ui.link{
 | 
| 
bsw@272
 | 
    80         text   = _"Cancel refuse of invitation",
 | 
| 
bsw@272
 | 
    81         module = "initiative",
 | 
| 
bsw@272
 | 
    82         action = "remove_initiator",
 | 
| 
bsw@272
 | 
    83         params = {
 | 
| 
bsw@272
 | 
    84           initiative_id = initiative.id,
 | 
| 
bsw@272
 | 
    85           member_id = app.session.member.id
 | 
| 
bsw@272
 | 
    86         },
 | 
| 
bsw@272
 | 
    87         routing = {
 | 
| 
bsw@272
 | 
    88           ok = {
 | 
| 
bsw@272
 | 
    89             mode = "redirect",
 | 
| 
bsw@272
 | 
    90             module = "initiative",
 | 
| 
bsw@272
 | 
    91             view = "show",
 | 
| 
bsw@272
 | 
    92             id = initiative.id
 | 
| 
bsw@272
 | 
    93           }
 | 
| 
bsw@272
 | 
    94         }
 | 
| 
bsw@272
 | 
    95       }
 | 
| 
bsw@272
 | 
    96   end
 | 
| 
bsw@272
 | 
    97 
 | 
| 
bsw@272
 | 
    98   
 | 
| 
bsw@272
 | 
    99 end )
 | 
| 
bsw@272
 | 
   100   
 | 
| 
bsw/jbe@19
 | 
   101 util.help("initiative.show")
 | 
| 
bsw/jbe@19
 | 
   102 
 | 
| 
bsw@272
 | 
   103 
 | 
| 
bsw/jbe@19
 | 
   104 if initiative.issue.ranks_available and initiative.admitted then
 | 
| 
bsw/jbe@19
 | 
   105   local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
 | 
| 
bsw/jbe@19
 | 
   106   ui.container{
 | 
| 
bsw/jbe@19
 | 
   107     attr = { class = class },
 | 
| 
bsw/jbe@19
 | 
   108     content = function()
 | 
| 
bsw/jbe@19
 | 
   109       local max_value = initiative.issue.voter_count
 | 
| 
bsw/jbe@19
 | 
   110       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   111       local positive_votes = initiative.positive_votes
 | 
| 
bsw/jbe@19
 | 
   112       local negative_votes = initiative.negative_votes
 | 
| 
jorges@104
 | 
   113       local sum_votes = initiative.positive_votes + initiative.negative_votes
 | 
| 
poelzi@167
 | 
   114       local function perc(votes, sum)
 | 
| 
poelzi@167
 | 
   115         if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
 | 
| 
poelzi@167
 | 
   116         return ""
 | 
| 
poelzi@167
 | 
   117       end
 | 
| 
poelzi@167
 | 
   118       slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
 | 
| 
bsw/jbe@19
 | 
   119       slot.put(" · ")
 | 
| 
bsw/jbe@19
 | 
   120       slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes)  .. "</b>")
 | 
| 
bsw/jbe@19
 | 
   121       slot.put(" · ")
 | 
| 
poelzi@167
 | 
   122       slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
 | 
| 
bsw/jbe@19
 | 
   123       slot.put(" · ")
 | 
| 
bsw/jbe@19
 | 
   124       slot.put("<b>")
 | 
| 
bsw/jbe@19
 | 
   125       if initiative.rank == 1 then
 | 
| 
bsw/jbe@19
 | 
   126         slot.put(_"Approved")
 | 
| 
bsw/jbe@19
 | 
   127       elseif initiative.rank then
 | 
| 
bsw/jbe@19
 | 
   128         slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
 | 
| 
bsw@24
 | 
   129       else
 | 
| 
bsw@24
 | 
   130         slot.put(_"Not approved")
 | 
| 
bsw/jbe@19
 | 
   131       end
 | 
| 
bsw/jbe@19
 | 
   132       slot.put("</b>")
 | 
| 
bsw/jbe@19
 | 
   133     end
 | 
| 
bsw/jbe@19
 | 
   134   }
 | 
| 
bsw/jbe@19
 | 
   135 end
 | 
| 
bsw/jbe@19
 | 
   136 
 | 
| 
bsw/jbe@19
 | 
   137 if initiative.admitted == false then
 | 
| 
bsw/jbe@19
 | 
   138   local policy = initiative.issue.policy
 | 
| 
bsw/jbe@19
 | 
   139   ui.container{
 | 
| 
bsw/jbe@19
 | 
   140     attr = { class = "not_admitted_info" },
 | 
| 
bsw/jbe@19
 | 
   141     content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
 | 
| 
bsw/jbe@19
 | 
   142   }
 | 
| 
bsw/jbe@19
 | 
   143 end
 | 
| 
bsw/jbe@19
 | 
   144 
 | 
| 
bsw/jbe@19
 | 
   145 local web20 = config.user_tab_mode == "accordeon"
 | 
| 
bsw/jbe@19
 | 
   146   or config.user_tab_mode == "accordeon_first_expanded"
 | 
| 
bsw/jbe@19
 | 
   147   or config.user_tab_mode == "accordeon_all_expanded"
 | 
| 
bsw/jbe@19
 | 
   148 
 | 
| 
bsw/jbe@19
 | 
   149 if not web20 and initiative.issue.state == "cancelled" then
 | 
| 
bsw/jbe@19
 | 
   150   local policy = initiative.issue.policy
 | 
| 
bsw/jbe@19
 | 
   151   ui.container{
 | 
| 
bsw/jbe@19
 | 
   152     attr = { class = "not_admitted_info" },
 | 
| 
bsw/jbe@19
 | 
   153     content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
 | 
| 
bsw/jbe@19
 | 
   154   }
 | 
| 
bsw/jbe@19
 | 
   155 end
 | 
| 
bsw/jbe@19
 | 
   156 
 | 
| 
bsw/jbe@19
 | 
   157 if initiative.revoked then
 | 
| 
bsw/jbe@19
 | 
   158   ui.container{
 | 
| 
bsw/jbe@19
 | 
   159     attr = { class = "revoked_info" },
 | 
| 
bsw/jbe@19
 | 
   160     content = function()
 | 
| 
bsw/jbe@19
 | 
   161       slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
 | 
| 
bsw/jbe@19
 | 
   162       local suggested_initiative = initiative.suggested_initiative
 | 
| 
bsw/jbe@19
 | 
   163       if suggested_initiative then
 | 
| 
bsw/jbe@19
 | 
   164         slot.put("<br /><br />")
 | 
| 
bsw/jbe@19
 | 
   165         slot.put(_("The initiators suggest to support the following initiative:"))
 | 
| 
bsw/jbe@19
 | 
   166         slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   167         ui.link{
 | 
| 
bsw/jbe@19
 | 
   168           content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
 | 
| 
bsw/jbe@19
 | 
   169           module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   170           view = "show",
 | 
| 
bsw/jbe@19
 | 
   171           id = suggested_initiative.id
 | 
| 
bsw/jbe@19
 | 
   172         }
 | 
| 
bsw/jbe@19
 | 
   173       end
 | 
| 
bsw/jbe@19
 | 
   174     end
 | 
| 
bsw/jbe@19
 | 
   175   }
 | 
| 
bsw/jbe@19
 | 
   176 end
 | 
| 
bsw/jbe@19
 | 
   177 
 | 
| 
bsw@41
 | 
   178 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
 | 
| 
bsw/jbe@19
 | 
   179   ui.container{
 | 
| 
bsw/jbe@19
 | 
   180     attr = { class = "initiator_invite_info" },
 | 
| 
bsw/jbe@19
 | 
   181     content = function()
 | 
| 
bsw/jbe@19
 | 
   182       slot.put(_"You are invited to become initiator of this initiative.")
 | 
| 
bsw/jbe@19
 | 
   183       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   184       ui.link{
 | 
| 
bsw/jbe@19
 | 
   185         image  = { static = "icons/16/tick.png" },
 | 
| 
bsw/jbe@19
 | 
   186         text   = _"Accept invitation",
 | 
| 
bsw/jbe@19
 | 
   187         module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   188         action = "accept_invitation",
 | 
| 
bsw/jbe@19
 | 
   189         id     = initiative.id,
 | 
| 
bsw/jbe@19
 | 
   190         routing = {
 | 
| 
bsw/jbe@19
 | 
   191           default = {
 | 
| 
bsw/jbe@19
 | 
   192             mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
   193             module = request.get_module(),
 | 
| 
bsw/jbe@19
 | 
   194             view = request.get_view(),
 | 
| 
bsw/jbe@19
 | 
   195             id = param.get_id_cgi(),
 | 
| 
bsw/jbe@19
 | 
   196             params = param.get_all_cgi()
 | 
| 
bsw/jbe@19
 | 
   197           }
 | 
| 
bsw/jbe@19
 | 
   198         }
 | 
| 
bsw/jbe@19
 | 
   199       }
 | 
| 
bsw/jbe@19
 | 
   200       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   201       ui.link{
 | 
| 
bsw/jbe@19
 | 
   202         image  = { static = "icons/16/cross.png" },
 | 
| 
bsw/jbe@19
 | 
   203         text   = _"Refuse invitation",
 | 
| 
bsw/jbe@19
 | 
   204         module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   205         action = "reject_initiator_invitation",
 | 
| 
bsw/jbe@19
 | 
   206         params = {
 | 
| 
bsw/jbe@19
 | 
   207           initiative_id = initiative.id,
 | 
| 
bsw/jbe@19
 | 
   208           member_id = app.session.member.id
 | 
| 
bsw/jbe@19
 | 
   209         },
 | 
| 
bsw/jbe@19
 | 
   210         routing = {
 | 
| 
bsw/jbe@19
 | 
   211           default = {
 | 
| 
bsw/jbe@19
 | 
   212             mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
   213             module = request.get_module(),
 | 
| 
bsw/jbe@19
 | 
   214             view = request.get_view(),
 | 
| 
bsw/jbe@19
 | 
   215             id = param.get_id_cgi(),
 | 
| 
bsw/jbe@19
 | 
   216             params = param.get_all_cgi()
 | 
| 
bsw/jbe@19
 | 
   217           }
 | 
| 
bsw/jbe@19
 | 
   218         }
 | 
| 
bsw/jbe@19
 | 
   219       }
 | 
| 
bsw/jbe@19
 | 
   220     end
 | 
| 
bsw/jbe@19
 | 
   221   }
 | 
| 
bsw/jbe@19
 | 
   222   slot.put("<br />")
 | 
| 
bsw/jbe@19
 | 
   223 end
 | 
| 
bsw/jbe@19
 | 
   224 
 | 
| 
bsw/jbe@19
 | 
   225 
 | 
| 
bsw@51
 | 
   226 local supporter
 | 
| 
bsw@51
 | 
   227 
 | 
| 
bsw@51
 | 
   228 if app.session.member_id then
 | 
| 
bsw@51
 | 
   229   supporter = app.session.member:get_reference_selector("supporters")
 | 
| 
bsw@51
 | 
   230     :add_where{ "initiative_id = ?", initiative.id }
 | 
| 
bsw@51
 | 
   231     :optional_object_mode()
 | 
| 
bsw@51
 | 
   232     :exec()
 | 
| 
bsw@51
 | 
   233 end
 | 
| 
bsw/jbe@19
 | 
   234 
 | 
| 
bsw/jbe@19
 | 
   235 if supporter and not initiative.issue.closed then
 | 
| 
bsw/jbe@19
 | 
   236   local old_draft_id = supporter.draft_id
 | 
| 
bsw/jbe@19
 | 
   237   local new_draft_id = initiative.current_draft.id
 | 
| 
bsw/jbe@19
 | 
   238   if old_draft_id ~= new_draft_id then
 | 
| 
bsw/jbe@19
 | 
   239     ui.container{
 | 
| 
bsw/jbe@19
 | 
   240       attr = { class = "draft_updated_info" },
 | 
| 
bsw/jbe@19
 | 
   241       content = function()
 | 
| 
bsw/jbe@19
 | 
   242         slot.put(_"The draft of this initiative has been updated!")
 | 
| 
bsw/jbe@19
 | 
   243         slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   244         ui.link{
 | 
| 
bsw/jbe@19
 | 
   245           content = _"Show diff",
 | 
| 
bsw/jbe@19
 | 
   246           module = "draft",
 | 
| 
bsw/jbe@19
 | 
   247           view = "diff",
 | 
| 
bsw/jbe@19
 | 
   248           params = {
 | 
| 
bsw/jbe@19
 | 
   249             old_draft_id = old_draft_id,
 | 
| 
bsw/jbe@19
 | 
   250             new_draft_id = new_draft_id
 | 
| 
bsw/jbe@19
 | 
   251           }
 | 
| 
bsw/jbe@19
 | 
   252         }
 | 
| 
bsw@75
 | 
   253         if not initiative.revoked then
 | 
| 
bsw@75
 | 
   254           slot.put(" ")
 | 
| 
bsw@75
 | 
   255           ui.link{
 | 
| 
bsw@75
 | 
   256             text   = _"Refresh support to current draft",
 | 
| 
bsw@75
 | 
   257             module = "initiative",
 | 
| 
bsw@75
 | 
   258             action = "add_support",
 | 
| 
bsw@75
 | 
   259             id     = initiative.id,
 | 
| 
bsw@75
 | 
   260             routing = {
 | 
| 
bsw@75
 | 
   261               default = {
 | 
| 
bsw@75
 | 
   262                 mode = "redirect",
 | 
| 
bsw@75
 | 
   263                 module = "initiative",
 | 
| 
bsw@75
 | 
   264                 view = "show",
 | 
| 
bsw@75
 | 
   265                 id = initiative.id
 | 
| 
bsw@75
 | 
   266               }
 | 
| 
bsw/jbe@19
 | 
   267             }
 | 
| 
bsw/jbe@19
 | 
   268           }
 | 
| 
bsw@75
 | 
   269         end
 | 
| 
bsw/jbe@19
 | 
   270       end
 | 
| 
bsw/jbe@19
 | 
   271     }
 | 
| 
bsw/jbe@19
 | 
   272   end
 | 
| 
bsw/jbe@19
 | 
   273 end
 | 
| 
bsw/jbe@19
 | 
   274 
 | 
| 
bsw/jbe@19
 | 
   275 
 | 
| 
bsw@51
 | 
   276 if app.session.member_id then
 | 
| 
bsw@51
 | 
   277   ui.container{
 | 
| 
bsw@51
 | 
   278     attr = {
 | 
| 
bsw@51
 | 
   279       id = "initiative_" .. tostring(initiative.id) .. "_support"
 | 
| 
bsw@51
 | 
   280     },
 | 
| 
bsw@51
 | 
   281     content = function()
 | 
| 
bsw@51
 | 
   282       execute.view{
 | 
| 
bsw@51
 | 
   283         module = "initiative",
 | 
| 
bsw@51
 | 
   284         view = "show_support",
 | 
| 
bsw@51
 | 
   285         params = {
 | 
| 
bsw@51
 | 
   286           initiative = initiative
 | 
| 
bsw@51
 | 
   287         }
 | 
| 
bsw/jbe@19
 | 
   288       }
 | 
| 
bsw@51
 | 
   289     end
 | 
| 
bsw@51
 | 
   290   }
 | 
| 
bsw@51
 | 
   291 end
 | 
| 
bsw/jbe@19
 | 
   292 
 | 
| 
bsw/jbe@19
 | 
   293 
 | 
| 
bsw/jbe@19
 | 
   294 execute.view{
 | 
| 
bsw/jbe@19
 | 
   295   module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   296   view = "show_tab",
 | 
| 
bsw/jbe@19
 | 
   297   params = {
 | 
| 
bsw/jbe@19
 | 
   298     initiative = initiative,
 | 
| 
bsw/jbe@19
 | 
   299     initiator = initiator
 | 
| 
bsw/jbe@19
 | 
   300   }
 | 
| 
bsw/jbe@19
 | 
   301 }
 | 
| 
bsw/jbe@19
 | 
   302 
 |