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