bsw/jbe@19: local initiative = param.get("initiative", "table") bsw/jbe@19: local initiator = param.get("initiator", "table") bsw/jbe@19: bsw@272: local initiators_members_selector = initiative:get_reference_selector("initiating_members") bsw@272: :add_field("initiator.accepted", "accepted") bsw@280: :add_order_by("member.name") bsw@280: if initiator and initiator.accepted then bsw@280: initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") bsw@280: else bsw@272: initiators_members_selector:add_where("initiator.accepted") bsw@272: end bsw@272: bsw@272: local initiators = initiators_members_selector:exec() bsw@272: bsw@274: bsw@274: local initiatives_selector = initiative.issue:get_reference_selector("initiatives") bsw@274: slot.select("initiatives_list", function() bsw@274: execute.view{ bsw@274: module = "initiative", bsw@274: view = "_list", bsw@274: params = { bsw@274: issue = initiative.issue, bsw@274: initiatives_selector = initiatives_selector, bsw@274: no_sort = true, highlight_initiative = initiative, limit = 3 bsw@274: } bsw@274: } bsw@274: end) bsw@274: bsw@272: slot.select("initiative_head", function() bsw@272: bsw@272: ui.container{ bsw@272: attr = { class = "initiative_name" }, bsw@272: content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) bsw@272: } bsw@286: bsw@313: if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then bsw@313: ui.tag{ bsw@313: attr = { class = "initiator_names" }, bsw@313: content = function() bsw@313: for i, initiator in ipairs(initiators) do bsw@313: slot.put(" ") bsw@458: if app.session.member_id then bsw@458: ui.link{ bsw@458: content = function () bsw@458: execute.view{ bsw@458: module = "member_image", bsw@458: view = "_show", bsw@458: params = { bsw@458: member = initiator, bsw@458: image_type = "avatar", bsw@458: show_dummy = true, bsw@458: class = "micro_avatar", bsw@458: popup_text = text bsw@458: } bsw@313: } bsw@458: end, bsw@458: module = "member", view = "show", id = initiator.id bsw@458: } bsw@458: slot.put(" ") bsw@458: end bsw@313: ui.link{ bsw@313: text = initiator.name, bsw@313: module = "member", view = "show", id = initiator.id bsw@313: } bsw@313: if not initiator.accepted then bsw@313: ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" } bsw@313: end bsw@272: end bsw@272: end bsw@313: } bsw@313: end bsw@272: bsw@313: if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then bsw@272: slot.put(" · ") bsw@272: ui.link{ bsw@313: attr = { class = "action" }, bsw@272: content = function() bsw@313: slot.put(_"Invite initiator") bsw@272: end, bsw@272: module = "initiative", bsw@313: view = "add_initiator", bsw@272: params = { initiative_id = initiative.id } bsw@272: } bsw@313: if #initiators > 1 then bsw@313: slot.put(" · ") bsw@313: ui.link{ bsw@313: content = function() bsw@313: slot.put(_"Remove initiator") bsw@313: end, bsw@313: module = "initiative", bsw@313: view = "remove_initiator", bsw@313: params = { initiative_id = initiative.id } bsw@313: } bsw@313: end bsw@313: end bsw@313: if initiator and initiator.accepted == false then bsw@313: slot.put(" · ") bsw@313: ui.link{ bsw@313: text = _"Cancel refuse of invitation", bsw@313: module = "initiative", bsw@313: action = "remove_initiator", bsw@313: params = { bsw@313: initiative_id = initiative.id, bsw@313: member_id = app.session.member.id bsw@313: }, bsw@313: routing = { bsw@313: ok = { bsw@313: mode = "redirect", bsw@313: module = "initiative", bsw@313: view = "show", bsw@313: id = initiative.id bsw@313: } bsw@313: } bsw@313: } bsw@313: end bsw@313: if app.session.member_id then bsw@313: execute.view{ bsw@313: module = "supporter", bsw@313: view = "_show_box", bsw@313: params = { bsw@313: initiative = initiative bsw@313: } bsw@313: } bsw@272: end bsw@313: bsw@313: end ) bsw@313: bsw@313: bsw/jbe@19: util.help("initiative.show") bsw/jbe@19: bsw@272: bsw/jbe@19: if initiative.issue.ranks_available and initiative.admitted then bsw@336: local class = initiative.winner and "admitted_info" or "not_admitted_info" bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = class }, bsw/jbe@19: content = function() bsw/jbe@19: local max_value = initiative.issue.voter_count bsw/jbe@19: slot.put(" ") bsw/jbe@19: local positive_votes = initiative.positive_votes bsw/jbe@19: local negative_votes = initiative.negative_votes jorges@104: local sum_votes = initiative.positive_votes + initiative.negative_votes poelzi@167: local function perc(votes, sum) poelzi@167: if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end poelzi@167: return "" poelzi@167: end poelzi@167: slot.put(_"Yes" .. ": " .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "") bsw/jbe@19: slot.put(" · ") bsw/jbe@19: slot.put(_"Abstention" .. ": " .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "") bsw/jbe@19: slot.put(" · ") poelzi@167: slot.put(_"No" .. ": " .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "") bsw/jbe@19: slot.put(" · ") bsw/jbe@19: slot.put("") bsw@335: if initiative.winner then bsw/jbe@19: slot.put(_"Approved") bsw/jbe@19: elseif initiative.rank then bsw/jbe@19: slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) bsw@24: else bsw@24: slot.put(_"Not approved") bsw/jbe@19: end bsw/jbe@19: slot.put("") bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: bsw/jbe@19: if initiative.admitted == false then bsw/jbe@19: local policy = initiative.issue.policy bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "not_admitted_info" }, bsw/jbe@19: 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: } bsw/jbe@19: end bsw/jbe@19: bsw@278: if initiative.issue.state == "cancelled" then bsw/jbe@19: local policy = initiative.issue.policy bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "not_admitted_info" }, bsw/jbe@19: 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: } bsw/jbe@19: end bsw/jbe@19: bsw/jbe@19: if initiative.revoked then bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "revoked_info" }, bsw/jbe@19: content = function() bsw/jbe@19: slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) bsw/jbe@19: local suggested_initiative = initiative.suggested_initiative bsw/jbe@19: if suggested_initiative then bsw/jbe@19: slot.put("

") bsw/jbe@19: slot.put(_("The initiators suggest to support the following initiative:")) bsw/jbe@19: slot.put(" ") bsw/jbe@19: ui.link{ bsw/jbe@19: content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show", bsw/jbe@19: id = suggested_initiative.id bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: bsw@41: if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "initiator_invite_info" }, bsw/jbe@19: content = function() bsw/jbe@19: slot.put(_"You are invited to become initiator of this initiative.") bsw/jbe@19: slot.put(" ") bsw/jbe@19: ui.link{ bsw/jbe@19: image = { static = "icons/16/tick.png" }, bsw/jbe@19: text = _"Accept invitation", bsw/jbe@19: module = "initiative", bsw/jbe@19: action = "accept_invitation", bsw/jbe@19: id = initiative.id, bsw/jbe@19: routing = { bsw/jbe@19: default = { bsw/jbe@19: mode = "redirect", bsw/jbe@19: module = request.get_module(), bsw/jbe@19: view = request.get_view(), bsw/jbe@19: id = param.get_id_cgi(), bsw/jbe@19: params = param.get_all_cgi() bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: ui.link{ bsw/jbe@19: image = { static = "icons/16/cross.png" }, bsw/jbe@19: text = _"Refuse invitation", bsw/jbe@19: module = "initiative", bsw/jbe@19: action = "reject_initiator_invitation", bsw/jbe@19: params = { bsw/jbe@19: initiative_id = initiative.id, bsw/jbe@19: member_id = app.session.member.id bsw/jbe@19: }, bsw/jbe@19: routing = { bsw/jbe@19: default = { bsw/jbe@19: mode = "redirect", bsw/jbe@19: module = request.get_module(), bsw/jbe@19: view = request.get_view(), bsw/jbe@19: id = param.get_id_cgi(), bsw/jbe@19: params = param.get_all_cgi() bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: slot.put("
") bsw/jbe@19: end bsw/jbe@19: bsw/jbe@19: bsw@51: local supporter bsw@51: bsw@51: if app.session.member_id then bsw@51: supporter = app.session.member:get_reference_selector("supporters") bsw@51: :add_where{ "initiative_id = ?", initiative.id } bsw@51: :optional_object_mode() bsw@51: :exec() bsw@51: end bsw/jbe@19: bsw/jbe@19: if supporter and not initiative.issue.closed then bsw/jbe@19: local old_draft_id = supporter.draft_id bsw/jbe@19: local new_draft_id = initiative.current_draft.id bsw/jbe@19: if old_draft_id ~= new_draft_id then bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "draft_updated_info" }, bsw/jbe@19: content = function() bsw/jbe@19: slot.put(_"The draft of this initiative has been updated!") bsw/jbe@19: slot.put(" ") bsw/jbe@19: ui.link{ bsw/jbe@19: content = _"Show diff", bsw/jbe@19: module = "draft", bsw/jbe@19: view = "diff", bsw/jbe@19: params = { bsw/jbe@19: old_draft_id = old_draft_id, bsw/jbe@19: new_draft_id = new_draft_id bsw/jbe@19: } bsw/jbe@19: } bsw@75: if not initiative.revoked then bsw@75: slot.put(" ") bsw@75: ui.link{ bsw@75: text = _"Refresh support to current draft", bsw@75: module = "initiative", bsw@75: action = "add_support", bsw@75: id = initiative.id, bsw@75: routing = { bsw@75: default = { bsw@75: mode = "redirect", bsw@75: module = "initiative", bsw@75: view = "show", bsw@75: id = initiative.id bsw@75: } bsw/jbe@19: } bsw/jbe@19: } bsw@75: end bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: end bsw/jbe@19: bsw/jbe@19: execute.view{ bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show_tab", bsw/jbe@19: params = { bsw/jbe@19: initiative = initiative, bsw/jbe@19: initiator = initiator bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: bsw@280: if initiative.issue.snapshot then bsw@431: slot.put("
") bsw@280: ui.field.timestamp{ label = _"Last snapshot:", value = initiative.issue.snapshot } bsw@280: end bsw@280: bsw@280: bsw@286: