| 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/jbe@19
 | 
     4 util.help("initiative.show")
 | 
| 
bsw/jbe@19
 | 
     5 
 | 
| 
bsw/jbe@19
 | 
     6 if initiative.issue.ranks_available and initiative.admitted then
 | 
| 
bsw/jbe@19
 | 
     7   local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
 | 
| 
bsw/jbe@19
 | 
     8   ui.container{
 | 
| 
bsw/jbe@19
 | 
     9     attr = { class = class },
 | 
| 
bsw/jbe@19
 | 
    10     content = function()
 | 
| 
bsw/jbe@19
 | 
    11       local max_value = initiative.issue.voter_count
 | 
| 
bsw/jbe@19
 | 
    12       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
    13       local positive_votes = initiative.positive_votes
 | 
| 
bsw/jbe@19
 | 
    14       local negative_votes = initiative.negative_votes
 | 
| 
jorges@104
 | 
    15       local sum_votes = initiative.positive_votes + initiative.negative_votes
 | 
| 
jorges@104
 | 
    16       slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. " (" .. string.format("%.f", positive_votes * 100 / sum_votes ) .. "%)" .. "</b>")
 | 
| 
bsw/jbe@19
 | 
    17       slot.put(" · ")
 | 
| 
bsw/jbe@19
 | 
    18       slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes)  .. "</b>")
 | 
| 
bsw/jbe@19
 | 
    19       slot.put(" · ")
 | 
| 
jorges@104
 | 
    20       slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. " (" .. string.format( "%.f", negative_votes * 100 / sum_votes ) .. "%)" .. "</b>")
 | 
| 
bsw/jbe@19
 | 
    21       slot.put(" · ")
 | 
| 
bsw/jbe@19
 | 
    22       slot.put("<b>")
 | 
| 
bsw/jbe@19
 | 
    23       if initiative.rank == 1 then
 | 
| 
bsw/jbe@19
 | 
    24         slot.put(_"Approved")
 | 
| 
bsw/jbe@19
 | 
    25       elseif initiative.rank then
 | 
| 
bsw/jbe@19
 | 
    26         slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
 | 
| 
bsw@24
 | 
    27       else
 | 
| 
bsw@24
 | 
    28         slot.put(_"Not approved")
 | 
| 
bsw/jbe@19
 | 
    29       end
 | 
| 
bsw/jbe@19
 | 
    30       slot.put("</b>")
 | 
| 
bsw/jbe@19
 | 
    31     end
 | 
| 
bsw/jbe@19
 | 
    32   }
 | 
| 
bsw/jbe@19
 | 
    33 end
 | 
| 
bsw/jbe@19
 | 
    34 
 | 
| 
bsw/jbe@19
 | 
    35 if initiative.admitted == false then
 | 
| 
bsw/jbe@19
 | 
    36   local policy = initiative.issue.policy
 | 
| 
bsw/jbe@19
 | 
    37   ui.container{
 | 
| 
bsw/jbe@19
 | 
    38     attr = { class = "not_admitted_info" },
 | 
| 
bsw/jbe@19
 | 
    39     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
 | 
    40   }
 | 
| 
bsw/jbe@19
 | 
    41 end
 | 
| 
bsw/jbe@19
 | 
    42 
 | 
| 
bsw/jbe@19
 | 
    43 local web20 = config.user_tab_mode == "accordeon"
 | 
| 
bsw/jbe@19
 | 
    44   or config.user_tab_mode == "accordeon_first_expanded"
 | 
| 
bsw/jbe@19
 | 
    45   or config.user_tab_mode == "accordeon_all_expanded"
 | 
| 
bsw/jbe@19
 | 
    46 
 | 
| 
bsw/jbe@19
 | 
    47 if not web20 and initiative.issue.state == "cancelled" then
 | 
| 
bsw/jbe@19
 | 
    48   local policy = initiative.issue.policy
 | 
| 
bsw/jbe@19
 | 
    49   ui.container{
 | 
| 
bsw/jbe@19
 | 
    50     attr = { class = "not_admitted_info" },
 | 
| 
bsw/jbe@19
 | 
    51     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
 | 
    52   }
 | 
| 
bsw/jbe@19
 | 
    53 end
 | 
| 
bsw/jbe@19
 | 
    54 
 | 
| 
bsw/jbe@19
 | 
    55 if initiative.revoked then
 | 
| 
bsw/jbe@19
 | 
    56   ui.container{
 | 
| 
bsw/jbe@19
 | 
    57     attr = { class = "revoked_info" },
 | 
| 
bsw/jbe@19
 | 
    58     content = function()
 | 
| 
bsw/jbe@19
 | 
    59       slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
 | 
| 
bsw/jbe@19
 | 
    60       local suggested_initiative = initiative.suggested_initiative
 | 
| 
bsw/jbe@19
 | 
    61       if suggested_initiative then
 | 
| 
bsw/jbe@19
 | 
    62         slot.put("<br /><br />")
 | 
| 
bsw/jbe@19
 | 
    63         slot.put(_("The initiators suggest to support the following initiative:"))
 | 
| 
bsw/jbe@19
 | 
    64         slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
    65         ui.link{
 | 
| 
bsw/jbe@19
 | 
    66           content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
 | 
| 
bsw/jbe@19
 | 
    67           module = "initiative",
 | 
| 
bsw/jbe@19
 | 
    68           view = "show",
 | 
| 
bsw/jbe@19
 | 
    69           id = suggested_initiative.id
 | 
| 
bsw/jbe@19
 | 
    70         }
 | 
| 
bsw/jbe@19
 | 
    71       end
 | 
| 
bsw/jbe@19
 | 
    72     end
 | 
| 
bsw/jbe@19
 | 
    73   }
 | 
| 
bsw/jbe@19
 | 
    74 end
 | 
| 
bsw/jbe@19
 | 
    75 
 | 
| 
bsw@41
 | 
    76 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
 | 
| 
bsw/jbe@19
 | 
    77   ui.container{
 | 
| 
bsw/jbe@19
 | 
    78     attr = { class = "initiator_invite_info" },
 | 
| 
bsw/jbe@19
 | 
    79     content = function()
 | 
| 
bsw/jbe@19
 | 
    80       slot.put(_"You are invited to become initiator of this initiative.")
 | 
| 
bsw/jbe@19
 | 
    81       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
    82       ui.link{
 | 
| 
bsw/jbe@19
 | 
    83         image  = { static = "icons/16/tick.png" },
 | 
| 
bsw/jbe@19
 | 
    84         text   = _"Accept invitation",
 | 
| 
bsw/jbe@19
 | 
    85         module = "initiative",
 | 
| 
bsw/jbe@19
 | 
    86         action = "accept_invitation",
 | 
| 
bsw/jbe@19
 | 
    87         id     = initiative.id,
 | 
| 
bsw/jbe@19
 | 
    88         routing = {
 | 
| 
bsw/jbe@19
 | 
    89           default = {
 | 
| 
bsw/jbe@19
 | 
    90             mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
    91             module = request.get_module(),
 | 
| 
bsw/jbe@19
 | 
    92             view = request.get_view(),
 | 
| 
bsw/jbe@19
 | 
    93             id = param.get_id_cgi(),
 | 
| 
bsw/jbe@19
 | 
    94             params = param.get_all_cgi()
 | 
| 
bsw/jbe@19
 | 
    95           }
 | 
| 
bsw/jbe@19
 | 
    96         }
 | 
| 
bsw/jbe@19
 | 
    97       }
 | 
| 
bsw/jbe@19
 | 
    98       slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
    99       ui.link{
 | 
| 
bsw/jbe@19
 | 
   100         image  = { static = "icons/16/cross.png" },
 | 
| 
bsw/jbe@19
 | 
   101         text   = _"Refuse invitation",
 | 
| 
bsw/jbe@19
 | 
   102         module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   103         action = "reject_initiator_invitation",
 | 
| 
bsw/jbe@19
 | 
   104         params = {
 | 
| 
bsw/jbe@19
 | 
   105           initiative_id = initiative.id,
 | 
| 
bsw/jbe@19
 | 
   106           member_id = app.session.member.id
 | 
| 
bsw/jbe@19
 | 
   107         },
 | 
| 
bsw/jbe@19
 | 
   108         routing = {
 | 
| 
bsw/jbe@19
 | 
   109           default = {
 | 
| 
bsw/jbe@19
 | 
   110             mode = "redirect",
 | 
| 
bsw/jbe@19
 | 
   111             module = request.get_module(),
 | 
| 
bsw/jbe@19
 | 
   112             view = request.get_view(),
 | 
| 
bsw/jbe@19
 | 
   113             id = param.get_id_cgi(),
 | 
| 
bsw/jbe@19
 | 
   114             params = param.get_all_cgi()
 | 
| 
bsw/jbe@19
 | 
   115           }
 | 
| 
bsw/jbe@19
 | 
   116         }
 | 
| 
bsw/jbe@19
 | 
   117       }
 | 
| 
bsw/jbe@19
 | 
   118     end
 | 
| 
bsw/jbe@19
 | 
   119   }
 | 
| 
bsw/jbe@19
 | 
   120   slot.put("<br />")
 | 
| 
bsw/jbe@19
 | 
   121 end
 | 
| 
bsw/jbe@19
 | 
   122 
 | 
| 
bsw/jbe@19
 | 
   123 
 | 
| 
bsw@51
 | 
   124 local supporter
 | 
| 
bsw@51
 | 
   125 
 | 
| 
bsw@51
 | 
   126 if app.session.member_id then
 | 
| 
bsw@51
 | 
   127   supporter = app.session.member:get_reference_selector("supporters")
 | 
| 
bsw@51
 | 
   128     :add_where{ "initiative_id = ?", initiative.id }
 | 
| 
bsw@51
 | 
   129     :optional_object_mode()
 | 
| 
bsw@51
 | 
   130     :exec()
 | 
| 
bsw@51
 | 
   131 end
 | 
| 
bsw/jbe@19
 | 
   132 
 | 
| 
bsw/jbe@19
 | 
   133 if supporter and not initiative.issue.closed then
 | 
| 
bsw/jbe@19
 | 
   134   local old_draft_id = supporter.draft_id
 | 
| 
bsw/jbe@19
 | 
   135   local new_draft_id = initiative.current_draft.id
 | 
| 
bsw/jbe@19
 | 
   136   if old_draft_id ~= new_draft_id then
 | 
| 
bsw/jbe@19
 | 
   137     ui.container{
 | 
| 
bsw/jbe@19
 | 
   138       attr = { class = "draft_updated_info" },
 | 
| 
bsw/jbe@19
 | 
   139       content = function()
 | 
| 
bsw/jbe@19
 | 
   140         slot.put(_"The draft of this initiative has been updated!")
 | 
| 
bsw/jbe@19
 | 
   141         slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   142         ui.link{
 | 
| 
bsw/jbe@19
 | 
   143           content = _"Show diff",
 | 
| 
bsw/jbe@19
 | 
   144           module = "draft",
 | 
| 
bsw/jbe@19
 | 
   145           view = "diff",
 | 
| 
bsw/jbe@19
 | 
   146           params = {
 | 
| 
bsw/jbe@19
 | 
   147             old_draft_id = old_draft_id,
 | 
| 
bsw/jbe@19
 | 
   148             new_draft_id = new_draft_id
 | 
| 
bsw/jbe@19
 | 
   149           }
 | 
| 
bsw/jbe@19
 | 
   150         }
 | 
| 
bsw@75
 | 
   151         if not initiative.revoked then
 | 
| 
bsw@75
 | 
   152           slot.put(" ")
 | 
| 
bsw@75
 | 
   153           ui.link{
 | 
| 
bsw@75
 | 
   154             text   = _"Refresh support to current draft",
 | 
| 
bsw@75
 | 
   155             module = "initiative",
 | 
| 
bsw@75
 | 
   156             action = "add_support",
 | 
| 
bsw@75
 | 
   157             id     = initiative.id,
 | 
| 
bsw@75
 | 
   158             routing = {
 | 
| 
bsw@75
 | 
   159               default = {
 | 
| 
bsw@75
 | 
   160                 mode = "redirect",
 | 
| 
bsw@75
 | 
   161                 module = "initiative",
 | 
| 
bsw@75
 | 
   162                 view = "show",
 | 
| 
bsw@75
 | 
   163                 id = initiative.id
 | 
| 
bsw@75
 | 
   164               }
 | 
| 
bsw/jbe@19
 | 
   165             }
 | 
| 
bsw/jbe@19
 | 
   166           }
 | 
| 
bsw@75
 | 
   167         end
 | 
| 
bsw/jbe@19
 | 
   168       end
 | 
| 
bsw/jbe@19
 | 
   169     }
 | 
| 
bsw/jbe@19
 | 
   170   end
 | 
| 
bsw/jbe@19
 | 
   171 end
 | 
| 
bsw/jbe@19
 | 
   172 
 | 
| 
bsw/jbe@19
 | 
   173 
 | 
| 
bsw@51
 | 
   174 if app.session.member_id then
 | 
| 
bsw@51
 | 
   175   ui.container{
 | 
| 
bsw@51
 | 
   176     attr = {
 | 
| 
bsw@51
 | 
   177       id = "initiative_" .. tostring(initiative.id) .. "_support"
 | 
| 
bsw@51
 | 
   178     },
 | 
| 
bsw@51
 | 
   179     content = function()
 | 
| 
bsw@51
 | 
   180       execute.view{
 | 
| 
bsw@51
 | 
   181         module = "initiative",
 | 
| 
bsw@51
 | 
   182         view = "show_support",
 | 
| 
bsw@51
 | 
   183         params = {
 | 
| 
bsw@51
 | 
   184           initiative = initiative
 | 
| 
bsw@51
 | 
   185         }
 | 
| 
bsw/jbe@19
 | 
   186       }
 | 
| 
bsw@51
 | 
   187     end
 | 
| 
bsw@51
 | 
   188   }
 | 
| 
bsw@51
 | 
   189 end
 | 
| 
bsw/jbe@19
 | 
   190 
 | 
| 
bsw/jbe@19
 | 
   191 if (initiative.discussion_url and #initiative.discussion_url > 0)
 | 
| 
bsw/jbe@19
 | 
   192   or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
 | 
| 
bsw/jbe@19
 | 
   193   ui.container{
 | 
| 
bsw/jbe@19
 | 
   194     attr = { class = "vertical" },
 | 
| 
bsw/jbe@19
 | 
   195     content = function()
 | 
| 
bsw/jbe@19
 | 
   196       ui.container{
 | 
| 
bsw/jbe@19
 | 
   197         attr = { class = "ui_field_label" },
 | 
| 
bsw/jbe@19
 | 
   198         content = _"Discussion with initiators"
 | 
| 
bsw/jbe@19
 | 
   199       }
 | 
| 
bsw/jbe@19
 | 
   200       ui.tag{
 | 
| 
bsw/jbe@19
 | 
   201         tag = "span",
 | 
| 
bsw/jbe@19
 | 
   202         content = function()
 | 
| 
bsw/jbe@19
 | 
   203           if initiative.discussion_url:find("^https?://") then
 | 
| 
bsw/jbe@19
 | 
   204             if initiative.discussion_url and #initiative.discussion_url > 0 then
 | 
| 
bsw/jbe@19
 | 
   205               ui.link{
 | 
| 
bsw/jbe@19
 | 
   206                 attr = {
 | 
| 
bsw/jbe@19
 | 
   207                   class = "actions",
 | 
| 
bsw/jbe@19
 | 
   208                   target = "_blank",
 | 
| 
bsw/jbe@19
 | 
   209                   title = initiative.discussion_url
 | 
| 
bsw/jbe@19
 | 
   210                 },
 | 
| 
bsw/jbe@19
 | 
   211                 content = function()
 | 
| 
bsw/jbe@19
 | 
   212                   slot.put(encode.html(initiative.discussion_url))
 | 
| 
bsw/jbe@19
 | 
   213                 end,
 | 
| 
bsw/jbe@19
 | 
   214                 external = initiative.discussion_url
 | 
| 
bsw/jbe@19
 | 
   215               }
 | 
| 
bsw/jbe@19
 | 
   216             end
 | 
| 
bsw/jbe@19
 | 
   217           else
 | 
| 
bsw/jbe@19
 | 
   218             slot.put(encode.html(initiative.discussion_url))
 | 
| 
bsw/jbe@19
 | 
   219           end
 | 
| 
bsw/jbe@19
 | 
   220           slot.put(" ")
 | 
| 
bsw/jbe@19
 | 
   221           if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
 | 
| 
bsw/jbe@19
 | 
   222             ui.link{
 | 
| 
bsw/jbe@19
 | 
   223               attr   = { class = "actions" },
 | 
| 
bsw/jbe@19
 | 
   224               text   = _"(change URL)",
 | 
| 
bsw/jbe@19
 | 
   225               module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   226               view   = "edit",
 | 
| 
bsw/jbe@19
 | 
   227               id     = initiative.id
 | 
| 
bsw/jbe@19
 | 
   228             }
 | 
| 
bsw/jbe@19
 | 
   229           end
 | 
| 
bsw/jbe@19
 | 
   230         end
 | 
| 
bsw/jbe@19
 | 
   231       }
 | 
| 
bsw/jbe@19
 | 
   232     end
 | 
| 
bsw/jbe@19
 | 
   233   }
 | 
| 
bsw/jbe@19
 | 
   234 end
 | 
| 
bsw/jbe@19
 | 
   235 
 | 
| 
bsw/jbe@19
 | 
   236 
 | 
| 
bsw/jbe@19
 | 
   237 
 | 
| 
bsw/jbe@19
 | 
   238 execute.view{
 | 
| 
bsw/jbe@19
 | 
   239   module = "initiative",
 | 
| 
bsw/jbe@19
 | 
   240   view = "show_tab",
 | 
| 
bsw/jbe@19
 | 
   241   params = {
 | 
| 
bsw/jbe@19
 | 
   242     initiative = initiative,
 | 
| 
bsw/jbe@19
 | 
   243     initiator = initiator
 | 
| 
bsw/jbe@19
 | 
   244   }
 | 
| 
bsw/jbe@19
 | 
   245 }
 | 
| 
bsw/jbe@19
 | 
   246 
 |