bsw@527: local initiative = Initiative:by_id(param.get_id()) bsw@716: initiative:load_everything_for_member_id(app.session.member_id) bsw/jbe@0: bsw@548: local issue = initiative.issue bsw@548: bsw@548: if app.session.member_id then bsw@548: issue:load_everything_for_member_id(app.session.member_id) bsw@548: end bsw@548: jorges@103: app.html_title.title = initiative.name jorges@103: app.html_title.subtitle = _("Initiative ##{id}", { id = initiative.id }) jorges@103: bsw@526: slot.select("head", function() bsw@526: execute.view{ bsw@527: module = "issue", view = "_head", bsw@548: params = { issue = issue, initiative = initiative } bsw@526: } bsw@526: end) bsw@526: bsw@718: local initiators_members_selector = initiative:get_reference_selector("initiating_members") bsw@718: :add_field("initiator.accepted", "accepted") bsw@718: :add_order_by("member.name") bsw@718: if initiator and initiator.accepted then bsw@718: initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") bsw@718: else bsw@718: initiators_members_selector:add_where("initiator.accepted") bsw@718: end bsw@718: bsw@718: local initiators = initiators_members_selector:exec() bsw@718: bsw@718: bsw@718: local initiatives_selector = initiative.issue:get_reference_selector("initiatives") bsw@718: slot.select("head", function() bsw@718: execute.view{ bsw@718: module = "issue", bsw@718: view = "_show", bsw@718: params = { bsw@718: issue = initiative.issue, bsw@718: initiative_limit = 3, bsw@718: for_initiative = initiative bsw@718: } bsw@718: } bsw@718: end) bsw@718: bsw@718: util.help("initiative.show") bsw@718: bsw@718: ui.container{ attr = { class = "initiative_head" }, content = function() bsw@718: bsw@718: ui.container{ bsw@718: attr = { class = "title" }, bsw@718: content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) bsw@718: } bsw@718: bsw@718: ui.container{ attr = { class = "content" }, content = function() bsw@718: if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then bsw@718: ui.tag{ bsw@718: attr = { class = "initiator_names" }, bsw@718: content = function() bsw@718: for i, initiator in ipairs(initiators) do bsw@718: slot.put(" ") bsw@718: if app.session.member_id or config.public_access == "full" then bsw@718: ui.link{ bsw@718: content = function () bsw@718: execute.view{ bsw@718: module = "member_image", bsw@718: view = "_show", bsw@718: params = { bsw@718: member = initiator, bsw@718: image_type = "avatar", bsw@718: show_dummy = true, bsw@718: class = "micro_avatar", bsw@718: popup_text = text bsw@718: } bsw@718: } bsw@718: end, bsw@718: module = "member", view = "show", id = initiator.id bsw@718: } bsw@718: slot.put(" ") bsw@718: end bsw@718: ui.link{ bsw@718: text = initiator.name, bsw@718: module = "member", view = "show", id = initiator.id bsw@718: } bsw@718: if not initiator.accepted then bsw@718: ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" } bsw@718: end bsw@718: end bsw@718: end bsw@718: } bsw@718: end bsw@718: bsw@718: if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then bsw@718: slot.put(" · ") bsw@718: ui.link{ bsw@718: attr = { class = "action" }, bsw@718: content = function() bsw@718: slot.put(_"Invite initiator") bsw@718: end, bsw@718: module = "initiative", bsw@718: view = "add_initiator", bsw@718: params = { initiative_id = initiative.id } bsw@718: } bsw@718: if #initiators > 1 then bsw@718: slot.put(" · ") bsw@718: ui.link{ bsw@718: content = function() bsw@718: slot.put(_"Remove initiator") bsw@718: end, bsw@718: module = "initiative", bsw@718: view = "remove_initiator", bsw@718: params = { initiative_id = initiative.id } bsw@718: } bsw@718: end bsw@718: end bsw@718: if initiator and initiator.accepted == false then bsw@718: slot.put(" · ") bsw@718: ui.link{ bsw@718: text = _"Cancel refuse of invitation", bsw@718: module = "initiative", bsw@718: action = "remove_initiator", bsw@718: params = { bsw@718: initiative_id = initiative.id, bsw@718: member_id = app.session.member.id bsw@718: }, bsw@718: routing = { bsw@718: ok = { bsw@718: mode = "redirect", bsw@718: module = "initiative", bsw@718: view = "show", bsw@718: id = initiative.id bsw@718: } bsw@718: } bsw@718: } bsw@718: end bsw@718: end } bsw@718: ui.container{ attr = { class = "content" }, content = function() bsw@718: if app.session.member_id then bsw@718: execute.view{ bsw@718: module = "supporter", bsw@718: view = "_show_box", bsw@718: params = { bsw@718: initiative = initiative bsw@718: } bsw@718: } bsw@718: end bsw@718: bsw@718: end } bsw@718: bsw@718: bsw@718: -- voting results bsw@718: if initiative.issue.ranks_available and initiative.admitted then bsw@718: local class = initiative.winner and "admitted_info" or "not_admitted_info" bsw@718: ui.container{ bsw@718: attr = { class = class }, bsw@718: content = function() bsw@718: local max_value = initiative.issue.voter_count bsw@718: slot.put(" ") bsw@718: local positive_votes = initiative.positive_votes bsw@718: local negative_votes = initiative.negative_votes bsw@718: local sum_votes = initiative.positive_votes + initiative.negative_votes bsw@718: local function perc(votes, sum) bsw@718: if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end bsw@718: return "" bsw@718: end bsw@718: slot.put(_"Yes" .. ": " .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "") bsw@718: slot.put(" · ") bsw@718: slot.put(_"Abstention" .. ": " .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "") bsw@718: slot.put(" · ") bsw@718: slot.put(_"No" .. ": " .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "") bsw@718: slot.put(" · ") bsw@718: slot.put("") bsw@718: if initiative.winner then bsw@718: slot.put(_"Approved") bsw@718: elseif initiative.rank then bsw@718: slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) bsw@718: else bsw@718: slot.put(_"Not approved") bsw@718: end bsw@718: slot.put("") bsw@718: end bsw@718: } bsw@718: end bsw@718: bsw@718: ui.container{ attr = { class = "content" }, content = function() bsw@718: execute.view{ bsw@718: module = "initiative", bsw@718: view = "_battles", bsw@718: params = { initiative = initiative } bsw@718: } bsw@718: end } bsw@718: bsw@718: -- initiative not admitted info bsw@718: if initiative.admitted == false then bsw@718: local policy = initiative.issue.policy bsw@718: ui.container{ bsw@718: attr = { class = "not_admitted_info" }, bsw@718: 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@718: } bsw@718: end bsw@718: bsw@718: -- initiative revoked info bsw@718: if initiative.revoked then bsw@718: ui.container{ bsw@718: attr = { class = "revoked_info" }, bsw@718: content = function() bsw@718: slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) bsw@718: local suggested_initiative = initiative.suggested_initiative bsw@718: if suggested_initiative then bsw@718: slot.put("

") bsw@718: slot.put(_("The initiators suggest to support the following initiative:")) bsw@718: slot.put(" ") bsw@718: ui.link{ bsw@718: content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), bsw@718: module = "initiative", bsw@718: view = "show", bsw@718: id = suggested_initiative.id bsw@718: } bsw@718: end bsw@718: end bsw@718: } bsw@718: end bsw@718: bsw@718: bsw@718: -- invited as initiator bsw@718: if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then bsw@718: ui.container{ bsw@718: attr = { class = "initiator_invite_info" }, bsw@718: content = function() bsw@718: slot.put(_"You are invited to become initiator of this initiative.") bsw@718: slot.put(" ") bsw@718: ui.link{ bsw@718: image = { static = "icons/16/tick.png" }, bsw@718: text = _"Accept invitation", bsw@718: module = "initiative", bsw@718: action = "accept_invitation", bsw@718: id = initiative.id, bsw@718: routing = { bsw@718: default = { bsw@718: mode = "redirect", bsw@718: module = request.get_module(), bsw@718: view = request.get_view(), bsw@718: id = param.get_id_cgi(), bsw@718: params = param.get_all_cgi() bsw@718: } bsw@718: } bsw@718: } bsw@718: slot.put(" ") bsw@718: ui.link{ bsw@718: image = { static = "icons/16/cross.png" }, bsw@718: text = _"Refuse invitation", bsw@718: module = "initiative", bsw@718: action = "reject_initiator_invitation", bsw@718: params = { bsw@718: initiative_id = initiative.id, bsw@718: member_id = app.session.member.id bsw@718: }, bsw@718: routing = { bsw@718: default = { bsw@718: mode = "redirect", bsw@718: module = request.get_module(), bsw@718: view = request.get_view(), bsw@718: id = param.get_id_cgi(), bsw@718: params = param.get_all_cgi() bsw@718: } bsw@718: } bsw@718: } bsw@718: end bsw@718: } bsw@718: end bsw@718: bsw@718: -- draft updated bsw@718: local supporter bsw@718: bsw@718: if app.session.member_id then bsw@718: supporter = app.session.member:get_reference_selector("supporters") bsw@718: :add_where{ "initiative_id = ?", initiative.id } bsw@718: :optional_object_mode() bsw@718: :exec() bsw@718: end bsw@718: bsw@718: if supporter and not initiative.issue.closed then bsw@718: local old_draft_id = supporter.draft_id bsw@718: local new_draft_id = initiative.current_draft.id bsw@718: if old_draft_id ~= new_draft_id then bsw@718: ui.container{ bsw@718: attr = { class = "draft_updated_info" }, bsw@718: content = function() bsw@718: slot.put(_"The draft of this initiative has been updated!") bsw@718: slot.put(" ") bsw@718: ui.link{ bsw@718: content = _"Show diff", bsw@718: module = "draft", bsw@718: view = "diff", bsw@718: params = { bsw@718: old_draft_id = old_draft_id, bsw@718: new_draft_id = new_draft_id bsw@718: } bsw@718: } bsw@718: if not initiative.revoked then bsw@718: slot.put(" ") bsw@718: ui.link{ bsw@718: text = _"Refresh support to current draft", bsw@718: module = "initiative", bsw@718: action = "add_support", bsw@718: id = initiative.id, bsw@718: routing = { bsw@718: default = { bsw@718: mode = "redirect", bsw@718: module = "initiative", bsw@718: view = "show", bsw@718: id = initiative.id bsw@718: } bsw@718: } bsw@718: } bsw@718: end bsw@718: end bsw@718: } bsw@718: end bsw@718: end bsw@718: bsw@718: bsw@718: execute.view{ bsw@718: module = "draft", bsw@718: view = "_show", bsw@718: params = { bsw@718: draft = initiative.current_draft bsw@718: } bsw@718: } bsw@718: bsw@718: end } bsw@718: bsw@718: execute.view{ bsw@718: module = "suggestion", bsw@718: view = "_list", bsw@718: params = { bsw@718: initiative = initiative, bsw@718: suggestions_selector = initiative:get_reference_selector("suggestions"), bsw@718: tab_id = param.get("tab_id") bsw@718: } bsw@718: } bsw@718: bsw@718: bsw@718: if config.public_access == "full" or app.session.member_id then bsw@718: if initiative.issue.ranks_available then bsw@718: local members_selector = initiative.issue:get_reference_selector("direct_voters") bsw@718: :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id }) bsw@718: :add_field("direct_voter.weight as voter_weight") bsw@718: :add_field("coalesce(vote.grade, 0) as grade") bsw@718: :left_join("initiative", nil, "initiative.id = vote.initiative_id") bsw@718: :left_join("issue", nil, "issue.id = initiative.issue_id") bsw@720: bsw@720: ui.anchor{ name = "voter", attr = { class = "heading" }, content = _"Member voter" } bsw@718: bsw@718: execute.view{ bsw@718: module = "member", bsw@718: view = "_list", bsw@718: params = { bsw@718: initiative = initiative, bsw@718: for_votes = true, bsw@720: members_selector = members_selector, bsw@720: paginator_name = "voter" bsw@718: } bsw@718: } bsw@718: end bsw@718: bsw@718: local members_selector = initiative:get_reference_selector("supporting_members_snapshot") bsw@718: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") bsw@718: :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") bsw@718: :add_field("direct_interest_snapshot.weight") bsw@718: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") bsw@718: :add_where("direct_supporter_snapshot.satisfied") bsw@718: :add_field("direct_supporter_snapshot.informed", "is_informed") bsw@718: bsw@718: if members_selector:count() > 0 then bsw@718: if issue.fully_frozen then bsw@720: ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters (before begin of voting)" } bsw@718: else bsw@720: ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters" } bsw@718: end bsw@718: bsw@718: execute.view{ bsw@718: module = "member", bsw@718: view = "_list", bsw@718: params = { bsw@718: initiative = initiative, bsw@720: members_selector = members_selector, bsw@720: paginator_name = "supporters" bsw@718: } bsw@718: } bsw@718: else bsw@718: if issue.fully_frozen then bsw@720: ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters (before begin of voting)" } bsw@718: else bsw@720: ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters" } bsw@718: end bsw@718: slot.put("
") bsw@718: end bsw@718: bsw@718: local members_selector = initiative:get_reference_selector("supporting_members_snapshot") bsw@718: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") bsw@718: :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") bsw@718: :add_field("direct_interest_snapshot.weight") bsw@718: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") bsw@718: :add_where("NOT direct_supporter_snapshot.satisfied") bsw@718: :add_field("direct_supporter_snapshot.informed", "is_informed") bsw@718: bsw@718: if members_selector:count() > 0 then bsw@718: if issue.fully_frozen then bsw@720: ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters (before begin of voting)" } bsw@718: else bsw@720: ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters" } bsw@718: end bsw@718: bsw@718: execute.view{ bsw@718: module = "member", bsw@718: view = "_list", bsw@718: params = { bsw@718: initiative = initiative, bsw@720: members_selector = members_selector, bsw@720: paginator_name = "potential_supporters" bsw@718: } bsw@718: } bsw@718: else bsw@718: if issue.fully_frozen then bsw@720: ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters (before begin of voting)" } bsw@718: else bsw@720: ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters" } bsw@718: end bsw@718: slot.put("
") bsw@718: end bsw@718: bsw@720: ui.container{ attr = { class = "heading" }, content = _"Details" } bsw@718: execute.view { bsw@718: module = "initiative", bsw@718: view = "_details", bsw@718: params = { bsw@718: initiative = initiative, bsw@718: members_selector = members_selector bsw@718: } bsw@718: } bsw@718: bsw@718: end