# HG changeset patch # User bsw # Date 1340884362 -7200 # Node ID 344e5fdce8c9b9a3e2be5db904f264db61729297 # Parent 20395309378a55519fc6360e2a52a1dc45719864 Fixed public search, made draft history available again diff -r 20395309378a -r 344e5fdce8c9 app/main/_filter/21_auth.lua --- a/app/main/_filter/21_auth.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/_filter/21_auth.lua Thu Jun 28 13:52:42 2012 +0200 @@ -1,33 +1,40 @@ +local module = request.get_module() +local view = request.get_view() +local action = request.get_action() + local auth_needed = not ( - request.get_module() == 'index' + module == 'index' and ( - request.get_view() == "index" - or request.get_view() == "login" - or request.get_action() == "login" - or request.get_view() == "register" - or request.get_action() == "register" - or request.get_view() == "about" - or request.get_view() == "reset_password" - or request.get_action() == "reset_password" - or request.get_view() == "confirm_notify_email" - or request.get_action() == "confirm_notify_email" - or request.get_view() == "menu" - or request.get_action() == "set_lang" + view == "index" + or view == "login" + or action == "login" + or view == "register" + or action == "register" + or view == "about" + or view == "reset_password" + or action == "reset_password" + or view == "confirm_notify_email" + or action == "confirm_notify_email" + or view == "menu" + or action == "set_lang" ) - or request.get_module() == "openid" + or module == "openid" ) if config.public_access then if - request.get_module() == "area" and request.get_view() == "show" - or request.get_module() == "unit" and request.get_view() == "show" - or request.get_module() == "policy" and request.get_view() == "show" - or request.get_module() == "policy" and request.get_view() == "list" - or request.get_module() == "issue" and request.get_view() == "show" - or request.get_module() == "initiative" and request.get_view() == "show" - or request.get_module() == "suggestion" and request.get_view() == "show" - or request.get_module() == "draft" and request.get_view() == "diff" + module == "area" and view == "show" + or module == "unit" and view == "show" + or module == "policy" and view == "show" + or module == "policy" and view == "list" + or module == "issue" and view == "show" + or module == "initiative" and view == "show" + or module == "suggestion" and view == "show" + or module == "draft" and view == "diff" + or module == "draft" and view == "show" + or module == "draft" and view == "list" + or module == "index" and view == "search" then auth_needed = false end @@ -35,19 +42,19 @@ end if config.public_access == "full" then - if request.get_module() == "member_image" and request.get_view() == "show" - or request.get_module() == "vote" and request.get_view() == "show_incoming" - or request.get_module() == "interest" and request.get_view() == "show_incoming" - or request.get_module() == "supporter" and request.get_view() == "show_incoming" then + if module == "member_image" and view == "show" + or module == "vote" and view == "show_incoming" + or module == "interest" and view == "show_incoming" + or module == "supporter" and view == "show_incoming" then auth_needed = false end end -if request.get_module() == "sitemap" then +if module == "sitemap" then auth_needed = false end -if config.public_access and not app.session.member_id and auth_needed and request.get_module() == "index" and request.get_view() == "index" then +if config.public_access and not app.session.member_id and auth_needed and module == "index" and view == "index" then if config.single_unit_id then request.redirect{ module = "unit", view = "show", id = config.single_unit_id } else @@ -65,8 +72,8 @@ trace.debug("Not authenticated yet.") request.redirect{ module = 'index', view = 'login', params = { - redirect_module = request.get_module(), - redirect_view = request.get_view(), + redirect_module = module, + redirect_view = view, redirect_id = param.get_id() } } diff -r 20395309378a -r 344e5fdce8c9 app/main/draft/list.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/draft/list.lua Thu Jun 28 13:52:42 2012 +0200 @@ -0,0 +1,61 @@ +local initiative = Initiative:by_id(param.get("initiative_id", atom.number)) + +execute.view{ + module = "initiative", view = "_show", params = { + initiative = initiative, show_as_head = true + } +} + +ui.link{ + text = _"Back to initiative", + module = "initiative", view = "show", id = initiative.id +} + +slot.put("
") +slot.put("
") + +ui.form{ + method = "get", + module = "draft", + view = "diff", + content = function() + ui.list{ + records = initiative.drafts, + columns = { + { + label = _"Created at", + content = function(record) + ui.field.text{ readonly = true, value = format.timestamp(record.created) } + end + }, + { + label = _"Author", + content = function(record) + if record.author then + return record.author:ui_field_text() + end + end + }, + { + content = function(record) + ui.link{ + attr = { class = "action" }, + text = _"Show", + module = "draft", + view = "show", + id = record.id + } + end + }, + { + label = _"Compare", + content = function(record) + slot.put('') + slot.put('') + end + } + } + } + ui.submit{ text = _"Compare" } + end +} diff -r 20395309378a -r 344e5fdce8c9 app/main/event/_list.lua --- a/app/main/event/_list.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/event/_list.lua Thu Jun 28 13:52:42 2012 +0200 @@ -151,15 +151,6 @@ } end } - if event.suggestion_id then - ui.container{ attr = { class = "suggestion" }, content = function() - ui.link{ - text = event.suggestion.name, - module = "suggestion", view = "show", id = event.suggestion_id - } - end } - end - ui.container{ attr = { class = "initiative_list" }, content = function() if not event.initiative_id then local initiatives_selector = Initiative:new_selector() @@ -169,7 +160,7 @@ issue = event.issue, initiatives_selector = initiatives_selector, no_sort = true, - limit = 3 + limit = 5 } } else local initiatives_selector = Initiative:new_selector() @@ -178,23 +169,20 @@ issue = event.issue, initiatives_selector = initiatives_selector, no_sort = true, - limit = 1 + limit = 1, + hide_more_initiatives = true } } end end } - --[[ - if event.initiative_id then - ui.container{ attr = { class = "initiative_id" }, content = event.initiative_id } - end - if event.draft_id then - ui.container{ attr = { class = "draft_id" }, content = event.draft_id } - end - if event.suggestion_id then - ui.container{ attr = { class = "suggestion_id" }, content = event.suggestion_id } - end ---]] - + ui.container{ attr = { class = "content suggestion" }, content = function() + if event.suggestion_id then + ui.link{ + text = event.suggestion.name, + module = "suggestion", view = "show", id = event.suggestion_id + } + end + end } end } end diff -r 20395309378a -r 344e5fdce8c9 app/main/index/search.lua --- a/app/main/index/search.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/index/search.lua Thu Jun 28 13:52:42 2012 +0200 @@ -14,18 +14,21 @@ } }, attr = { class = "vertical" }, content = function() - ui.field.select{ - label = _"Search context", - name = "search_for", - value = search_for, - foreign_records = { - { id = "global", name = _"Global search" }, - { id = "member", name = _"Search for members" }, - { id = "issue", name = _"Search for issues" } - }, - foreign_id = "id", - foreign_name = "name", - } + + if app.session.member_id or config.public_access == "full" then + ui.field.select{ + label = _"Search context", + name = "search_for", + value = search_for, + foreign_records = { + { id = "global", name = _"Global search" }, + { id = "member", name = _"Search for members" }, + { id = "issue", name = _"Search for issues" } + }, + foreign_id = "id", + foreign_name = "name", + } + end ui.field.text{ label = _"Search term (only complete words)", name = "search", value = search_string } ui.submit{ value = _"Start search" } end @@ -35,15 +38,17 @@ if search_string then - if search_for == "global" or search_for == "member" then - local members_selector = Member:get_search_selector(search_string) - execute.view{ - module = "member", - view = "_list", - params = { members_selector = members_selector }, - } + if app.session.member_id or config.public_access == "full" then + if search_for == "global" or search_for == "member" then + local members_selector = Member:get_search_selector(search_string) + execute.view{ + module = "member", + view = "_list", + params = { members_selector = members_selector }, + } + end end - + if search_for == "global" or search_for == "issue" then local issues_selector = Issue:get_search_selector(search_string) execute.view{ diff -r 20395309378a -r 344e5fdce8c9 app/main/initiative/_list.lua --- a/app/main/initiative/_list.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/initiative/_list.lua Thu Jun 28 13:52:42 2012 +0200 @@ -14,6 +14,7 @@ local for_member = param.get("for_member", "table") or app.session.member local limit = param.get("limit", atom.number) +local hide_more_initiatives = param.get("hide_more_initiatives", atom.boolean) local more_initiatives_count if limit then @@ -60,7 +61,7 @@ } end -if more_initiatives_count and more_initiatives_count > 0 then +if not hide_more_initiatives and more_initiatives_count and more_initiatives_count > 0 then local text if more_initiatives_count == 1 then text = _("and one more initiative") diff -r 20395309378a -r 344e5fdce8c9 app/main/initiative/_show.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/initiative/_show.lua Thu Jun 28 13:52:42 2012 +0200 @@ -0,0 +1,525 @@ +local initiative = param.get("initiative", "table") + +local show_as_head = param.get("show_as_head", atom.boolean) + +initiative:load_everything_for_member_id(app.session.member_id) + +local issue = initiative.issue + +-- TODO performance +local initiator +if app.session.member_id then + initiator = Initiator:by_pk(initiative.id, app.session.member.id) +end + +if app.session.member_id then + issue:load_everything_for_member_id(app.session.member_id) +end + +app.html_title.title = initiative.name +app.html_title.subtitle = _("Initiative ##{id}", { id = initiative.id }) + +slot.select("head", function() + execute.view{ + module = "issue", view = "_head", + params = { issue = issue, initiative = initiative } + } +end) + +local initiators_members_selector = initiative:get_reference_selector("initiating_members") + :add_field("initiator.accepted", "accepted") + :add_order_by("member.name") +if initiator and initiator.accepted then + initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") +else + initiators_members_selector:add_where("initiator.accepted") +end + +local initiators = initiators_members_selector:exec() + + +local initiatives_selector = initiative.issue:get_reference_selector("initiatives") +slot.select("head", function() + execute.view{ + module = "issue", + view = "_show", + params = { + issue = initiative.issue, + initiative_limit = 3, + for_initiative = initiative + } + } +end) + +util.help("initiative.show") + +ui.container{ attr = { class = "initiative_head" }, content = function() + + local text = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) + if show_as_head then + ui.link{ + attr = { class = "title" }, text = text, + module = "initiative", view = "show", id = initiative.id + } + else + ui.container{ attr = { class = "title" }, content = text } + end + ui.container{ attr = { class = "content" }, content = function() + if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then + ui.tag{ + attr = { class = "initiator_names" }, + content = function() + for i, initiator in ipairs(initiators) do + slot.put(" ") + if app.session.member_id or config.public_access == "full" then + ui.link{ + content = function () + execute.view{ + module = "member_image", + view = "_show", + params = { + member = initiator, + image_type = "avatar", + show_dummy = true, + class = "micro_avatar", + popup_text = text + } + } + end, + module = "member", view = "show", id = initiator.id + } + slot.put(" ") + end + ui.link{ + text = initiator.name, + module = "member", view = "show", id = initiator.id + } + if not initiator.accepted then + ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" } + end + end + if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then + slot.put(" · ") + ui.link{ + attr = { class = "action" }, + content = function() + slot.put(_"Invite initiator") + end, + module = "initiative", + view = "add_initiator", + params = { initiative_id = initiative.id } + } + if #initiators > 1 then + slot.put(" · ") + ui.link{ + content = function() + slot.put(_"Remove initiator") + end, + module = "initiative", + view = "remove_initiator", + params = { initiative_id = initiative.id } + } + end + end + if initiator and initiator.accepted == false then + slot.put(" · ") + ui.link{ + text = _"Cancel refuse of invitation", + module = "initiative", + action = "remove_initiator", + params = { + initiative_id = initiative.id, + member_id = app.session.member.id + }, + routing = { + ok = { + mode = "redirect", + module = "initiative", + view = "show", + id = initiative.id + } + } + } + end + if (initiative.discussion_url and #initiative.discussion_url > 0) then + slot.put(" · ") + if initiative.discussion_url:find("^https?://") then + if initiative.discussion_url and #initiative.discussion_url > 0 then + ui.link{ + attr = { + target = "_blank", + title = _"Discussion with initiators" + }, + text = _"Discuss with initiators", + external = initiative.discussion_url + } + end + else + slot.put(encode.html(initiative.discussion_url)) + end + end + if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then + slot.put(" · ") + ui.link{ + text = _"change discussion URL", + module = "initiative", + view = "edit", + id = initiative.id + } + slot.put(" ") + end + end + } + end + + end } + ui.container{ attr = { class = "content" }, content = function() + if app.session.member_id then + execute.view{ + module = "supporter", + view = "_show_box", + params = { + initiative = initiative + } + } + end + + end } + + + -- voting results + if initiative.issue.ranks_available and initiative.admitted then + local class = initiative.winner and "admitted_info" or "not_admitted_info" + ui.container{ + attr = { class = class }, + content = function() + local max_value = initiative.issue.voter_count + slot.put(" ") + local positive_votes = initiative.positive_votes + local negative_votes = initiative.negative_votes + local sum_votes = initiative.positive_votes + initiative.negative_votes + local function perc(votes, sum) + if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end + return "" + end + slot.put(_"Yes" .. ": " .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "") + slot.put(" · ") + slot.put(_"Abstention" .. ": " .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "") + slot.put(" · ") + slot.put(_"No" .. ": " .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "") + slot.put(" · ") + slot.put("") + if initiative.winner then + slot.put(_"Approved") + elseif initiative.rank then + slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) + else + slot.put(_"Not approved") + end + slot.put("") + end + } + end + + ui.container{ attr = { class = "content" }, content = function() + execute.view{ + module = "initiative", + view = "_battles", + params = { initiative = initiative } + } + end } + + -- initiative not admitted info + if initiative.admitted == false then + local policy = initiative.issue.policy + ui.container{ + attr = { class = "not_admitted_info" }, + content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) }) + } + end + + -- initiative revoked info + if initiative.revoked then + ui.container{ + attr = { class = "revoked_info" }, + content = function() + slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) + local suggested_initiative = initiative.suggested_initiative + if suggested_initiative then + slot.put("

") + slot.put(_("The initiators suggest to support the following initiative:")) + slot.put(" ") + ui.link{ + content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), + module = "initiative", + view = "show", + id = suggested_initiative.id + } + end + end + } + end + + + -- invited as initiator + if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then + ui.container{ + attr = { class = "initiator_invite_info" }, + content = function() + slot.put(_"You are invited to become initiator of this initiative.") + slot.put(" ") + ui.link{ + image = { static = "icons/16/tick.png" }, + text = _"Accept invitation", + module = "initiative", + action = "accept_invitation", + id = initiative.id, + routing = { + default = { + mode = "redirect", + module = request.get_module(), + view = request.get_view(), + id = param.get_id_cgi(), + params = param.get_all_cgi() + } + } + } + slot.put(" ") + ui.link{ + image = { static = "icons/16/cross.png" }, + text = _"Refuse invitation", + module = "initiative", + action = "reject_initiator_invitation", + params = { + initiative_id = initiative.id, + member_id = app.session.member.id + }, + routing = { + default = { + mode = "redirect", + module = request.get_module(), + view = request.get_view(), + id = param.get_id_cgi(), + params = param.get_all_cgi() + } + } + } + end + } + end + + -- draft updated + local supporter + + if app.session.member_id then + supporter = app.session.member:get_reference_selector("supporters") + :add_where{ "initiative_id = ?", initiative.id } + :optional_object_mode() + :exec() + end + + if supporter and not initiative.issue.closed then + local old_draft_id = supporter.draft_id + local new_draft_id = initiative.current_draft.id + if old_draft_id ~= new_draft_id then + ui.container{ + attr = { class = "draft_updated_info" }, + content = function() + slot.put(_"The draft of this initiative has been updated!") + slot.put(" ") + ui.link{ + content = _"Show diff", + module = "draft", + view = "diff", + params = { + old_draft_id = old_draft_id, + new_draft_id = new_draft_id + } + } + if not initiative.revoked then + slot.put(" ") + ui.link{ + text = _"Refresh support to current draft", + module = "initiative", + action = "add_support", + id = initiative.id, + routing = { + default = { + mode = "redirect", + module = "initiative", + view = "show", + id = initiative.id + } + } + } + end + end + } + end + end + + if not show_as_head then + local drafts_count = initiative:get_reference_selector("drafts"):count() + + ui.container{ attr = { class = "content" }, content = function() + + if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then + ui.link{ + content = function() + slot.put(_"Edit draft") + end, + module = "draft", + view = "new", + params = { initiative_id = initiative.id } + } + slot.put(" · ") + ui.link{ + content = function() + slot.put(_"Revoke initiative") + end, + module = "initiative", + view = "revoke", + id = initiative.id + } + slot.put(" · ") + end + + ui.tag{ + attr = { class = "draft_version" }, + content = _("Latest draft created at #{date} #{time}", { + date = format.date(initiative.current_draft.created), + time = format.time(initiative.current_draft.created) + }) + } + if drafts_count > 1 then + slot.put(" · ") + ui.link{ + module = "draft", view = "list", params = { initiative_id = initiative.id }, + text = _("List all revisions (#{count})", { count = drafts_count }) + } + end + end } + + execute.view{ + module = "draft", + view = "_show", + params = { + draft = initiative.current_draft + } + } + end +end } + +if not show_as_head then + execute.view{ + module = "suggestion", + view = "_list", + params = { + initiative = initiative, + suggestions_selector = initiative:get_reference_selector("suggestions"), + tab_id = param.get("tab_id") + } + } + + + if config.public_access == "full" or app.session.member_id then + if initiative.issue.ranks_available then + local members_selector = initiative.issue:get_reference_selector("direct_voters") + :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id }) + :add_field("direct_voter.weight as voter_weight") + :add_field("coalesce(vote.grade, 0) as grade") + :left_join("initiative", nil, "initiative.id = vote.initiative_id") + :left_join("issue", nil, "issue.id = initiative.issue_id") + + ui.anchor{ name = "voter", attr = { class = "heading" }, content = _"Member voter" } + + execute.view{ + module = "member", + view = "_list", + params = { + initiative = initiative, + for_votes = true, + members_selector = members_selector, + paginator_name = "voter" + } + } + end + + local members_selector = initiative:get_reference_selector("supporting_members_snapshot") + :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") + :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") + :add_field("direct_interest_snapshot.weight") + :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") + :add_where("direct_supporter_snapshot.satisfied") + :add_field("direct_supporter_snapshot.informed", "is_informed") + + if members_selector:count() > 0 then + if issue.fully_frozen then + ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters (before begin of voting)" } + else + ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters" } + end + + execute.view{ + module = "member", + view = "_list", + params = { + initiative = initiative, + members_selector = members_selector, + paginator_name = "supporters" + } + } + else + if issue.fully_frozen then + ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters (before begin of voting)" } + else + ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters" } + end + slot.put("
") + end + + local members_selector = initiative:get_reference_selector("supporting_members_snapshot") + :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") + :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") + :add_field("direct_interest_snapshot.weight") + :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") + :add_where("NOT direct_supporter_snapshot.satisfied") + :add_field("direct_supporter_snapshot.informed", "is_informed") + + if members_selector:count() > 0 then + if issue.fully_frozen then + ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters (before begin of voting)" } + else + ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters" } + end + + execute.view{ + module = "member", + view = "_list", + params = { + initiative = initiative, + members_selector = members_selector, + paginator_name = "potential_supporters" + } + } + else + if issue.fully_frozen then + ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters (before begin of voting)" } + else + ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters" } + end + slot.put("
") + end + + ui.container{ attr = { class = "heading" }, content = _"Details" } + execute.view { + module = "initiative", + view = "_details", + params = { + initiative = initiative, + members_selector = members_selector + } + } + + end +end \ No newline at end of file diff -r 20395309378a -r 344e5fdce8c9 app/main/initiative/show.lua --- a/app/main/initiative/show.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/initiative/show.lua Thu Jun 28 13:52:42 2012 +0200 @@ -1,442 +1,7 @@ local initiative = Initiative:by_id(param.get_id()) -initiative:load_everything_for_member_id(app.session.member_id) - -local issue = initiative.issue - -if app.session.member_id then - issue:load_everything_for_member_id(app.session.member_id) -end - -app.html_title.title = initiative.name -app.html_title.subtitle = _("Initiative ##{id}", { id = initiative.id }) - -slot.select("head", function() - execute.view{ - module = "issue", view = "_head", - params = { issue = issue, initiative = initiative } - } -end) - -local initiators_members_selector = initiative:get_reference_selector("initiating_members") - :add_field("initiator.accepted", "accepted") - :add_order_by("member.name") -if initiator and initiator.accepted then - initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") -else - initiators_members_selector:add_where("initiator.accepted") -end - -local initiators = initiators_members_selector:exec() - - -local initiatives_selector = initiative.issue:get_reference_selector("initiatives") -slot.select("head", function() - execute.view{ - module = "issue", - view = "_show", - params = { - issue = initiative.issue, - initiative_limit = 3, - for_initiative = initiative - } - } -end) - -util.help("initiative.show") - -ui.container{ attr = { class = "initiative_head" }, content = function() - - ui.container{ - attr = { class = "title" }, - content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) - } - - ui.container{ attr = { class = "content" }, content = function() - if app.session.member_id or config.public_access == "pseudonym" or config.public_access == "full" then - ui.tag{ - attr = { class = "initiator_names" }, - content = function() - for i, initiator in ipairs(initiators) do - slot.put(" ") - if app.session.member_id or config.public_access == "full" then - ui.link{ - content = function () - execute.view{ - module = "member_image", - view = "_show", - params = { - member = initiator, - image_type = "avatar", - show_dummy = true, - class = "micro_avatar", - popup_text = text - } - } - end, - module = "member", view = "show", id = initiator.id - } - slot.put(" ") - end - ui.link{ - text = initiator.name, - module = "member", view = "show", id = initiator.id - } - if not initiator.accepted then - ui.tag{ attr = { title = _"Not accepted yet" }, content = "?" } - end - end - end - } - end - - if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then - slot.put(" · ") - ui.link{ - attr = { class = "action" }, - content = function() - slot.put(_"Invite initiator") - end, - module = "initiative", - view = "add_initiator", - params = { initiative_id = initiative.id } - } - if #initiators > 1 then - slot.put(" · ") - ui.link{ - content = function() - slot.put(_"Remove initiator") - end, - module = "initiative", - view = "remove_initiator", - params = { initiative_id = initiative.id } - } - end - end - if initiator and initiator.accepted == false then - slot.put(" · ") - ui.link{ - text = _"Cancel refuse of invitation", - module = "initiative", - action = "remove_initiator", - params = { - initiative_id = initiative.id, - member_id = app.session.member.id - }, - routing = { - ok = { - mode = "redirect", - module = "initiative", - view = "show", - id = initiative.id - } - } - } - end - end } - ui.container{ attr = { class = "content" }, content = function() - if app.session.member_id then - execute.view{ - module = "supporter", - view = "_show_box", - params = { - initiative = initiative - } - } - end - - end } - - - -- voting results - if initiative.issue.ranks_available and initiative.admitted then - local class = initiative.winner and "admitted_info" or "not_admitted_info" - ui.container{ - attr = { class = class }, - content = function() - local max_value = initiative.issue.voter_count - slot.put(" ") - local positive_votes = initiative.positive_votes - local negative_votes = initiative.negative_votes - local sum_votes = initiative.positive_votes + initiative.negative_votes - local function perc(votes, sum) - if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end - return "" - end - slot.put(_"Yes" .. ": " .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "") - slot.put(" · ") - slot.put(_"Abstention" .. ": " .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "") - slot.put(" · ") - slot.put(_"No" .. ": " .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "") - slot.put(" · ") - slot.put("") - if initiative.winner then - slot.put(_"Approved") - elseif initiative.rank then - slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank })) - else - slot.put(_"Not approved") - end - slot.put("") - end - } - end - - ui.container{ attr = { class = "content" }, content = function() - execute.view{ - module = "initiative", - view = "_battles", - params = { initiative = initiative } - } - end } - - -- initiative not admitted info - if initiative.admitted == false then - local policy = initiative.issue.policy - ui.container{ - attr = { class = "not_admitted_info" }, - content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) }) - } - end - - -- initiative revoked info - if initiative.revoked then - ui.container{ - attr = { class = "revoked_info" }, - content = function() - slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) - local suggested_initiative = initiative.suggested_initiative - if suggested_initiative then - slot.put("

") - slot.put(_("The initiators suggest to support the following initiative:")) - slot.put(" ") - ui.link{ - content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), - module = "initiative", - view = "show", - id = suggested_initiative.id - } - end - end - } - end - - - -- invited as initiator - if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then - ui.container{ - attr = { class = "initiator_invite_info" }, - content = function() - slot.put(_"You are invited to become initiator of this initiative.") - slot.put(" ") - ui.link{ - image = { static = "icons/16/tick.png" }, - text = _"Accept invitation", - module = "initiative", - action = "accept_invitation", - id = initiative.id, - routing = { - default = { - mode = "redirect", - module = request.get_module(), - view = request.get_view(), - id = param.get_id_cgi(), - params = param.get_all_cgi() - } - } - } - slot.put(" ") - ui.link{ - image = { static = "icons/16/cross.png" }, - text = _"Refuse invitation", - module = "initiative", - action = "reject_initiator_invitation", - params = { - initiative_id = initiative.id, - member_id = app.session.member.id - }, - routing = { - default = { - mode = "redirect", - module = request.get_module(), - view = request.get_view(), - id = param.get_id_cgi(), - params = param.get_all_cgi() - } - } - } - end - } - end - - -- draft updated - local supporter - - if app.session.member_id then - supporter = app.session.member:get_reference_selector("supporters") - :add_where{ "initiative_id = ?", initiative.id } - :optional_object_mode() - :exec() - end - - if supporter and not initiative.issue.closed then - local old_draft_id = supporter.draft_id - local new_draft_id = initiative.current_draft.id - if old_draft_id ~= new_draft_id then - ui.container{ - attr = { class = "draft_updated_info" }, - content = function() - slot.put(_"The draft of this initiative has been updated!") - slot.put(" ") - ui.link{ - content = _"Show diff", - module = "draft", - view = "diff", - params = { - old_draft_id = old_draft_id, - new_draft_id = new_draft_id - } - } - if not initiative.revoked then - slot.put(" ") - ui.link{ - text = _"Refresh support to current draft", - module = "initiative", - action = "add_support", - id = initiative.id, - routing = { - default = { - mode = "redirect", - module = "initiative", - view = "show", - id = initiative.id - } - } - } - end - end - } - end - end - - - execute.view{ - module = "draft", - view = "_show", - params = { - draft = initiative.current_draft - } - } - -end } execute.view{ - module = "suggestion", - view = "_list", - params = { - initiative = initiative, - suggestions_selector = initiative:get_reference_selector("suggestions"), - tab_id = param.get("tab_id") + module = "initiative", view = "_show", params = { + initiative = initiative } } - - -if config.public_access == "full" or app.session.member_id then - if initiative.issue.ranks_available then - local members_selector = initiative.issue:get_reference_selector("direct_voters") - :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id }) - :add_field("direct_voter.weight as voter_weight") - :add_field("coalesce(vote.grade, 0) as grade") - :left_join("initiative", nil, "initiative.id = vote.initiative_id") - :left_join("issue", nil, "issue.id = initiative.issue_id") - - ui.anchor{ name = "voter", attr = { class = "heading" }, content = _"Member voter" } - - execute.view{ - module = "member", - view = "_list", - params = { - initiative = initiative, - for_votes = true, - members_selector = members_selector, - paginator_name = "voter" - } - } - end - - local members_selector = initiative:get_reference_selector("supporting_members_snapshot") - :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") - :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") - :add_field("direct_interest_snapshot.weight") - :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") - :add_where("direct_supporter_snapshot.satisfied") - :add_field("direct_supporter_snapshot.informed", "is_informed") - - if members_selector:count() > 0 then - if issue.fully_frozen then - ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters (before begin of voting)" } - else - ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"Supporters" } - end - - execute.view{ - module = "member", - view = "_list", - params = { - initiative = initiative, - members_selector = members_selector, - paginator_name = "supporters" - } - } - else - if issue.fully_frozen then - ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters (before begin of voting)" } - else - ui.anchor{ name = "supporters", attr = { class = "heading" }, content = _"No supporters" } - end - slot.put("
") - end - - local members_selector = initiative:get_reference_selector("supporting_members_snapshot") - :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") - :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") - :add_field("direct_interest_snapshot.weight") - :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") - :add_where("NOT direct_supporter_snapshot.satisfied") - :add_field("direct_supporter_snapshot.informed", "is_informed") - - if members_selector:count() > 0 then - if issue.fully_frozen then - ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters (before begin of voting)" } - else - ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"Potential supporters" } - end - - execute.view{ - module = "member", - view = "_list", - params = { - initiative = initiative, - members_selector = members_selector, - paginator_name = "potential_supporters" - } - } - else - if issue.fully_frozen then - ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters (before begin of voting)" } - else - ui.anchor{ name = "potential_supporters", attr = { class = "heading" }, content = _"No potential supporters" } - end - slot.put("
") - end - - ui.container{ attr = { class = "heading" }, content = _"Details" } - execute.view { - module = "initiative", - view = "_details", - params = { - initiative = initiative, - members_selector = members_selector - } - } - -end diff -r 20395309378a -r 344e5fdce8c9 app/main/supporter/_show_box.lua --- a/app/main/supporter/_show_box.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/app/main/supporter/_show_box.lua Thu Jun 28 13:52:42 2012 +0200 @@ -1,7 +1,5 @@ local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id()) --- TODO performance -local initiator = Initiator:by_pk(initiative.id, app.session.member.id) local initiative = param.get("initiative", "table") local supporter = Supporter:by_pk(initiative.id, app.session.member.id) @@ -77,57 +75,10 @@ end end -if (initiative.discussion_url and #initiative.discussion_url > 0) then - if initiative.discussion_url:find("^https?://") then - if initiative.discussion_url and #initiative.discussion_url > 0 then - ui.link{ - attr = { - target = "_blank", - title = _"Discussion with initiators" - }, - text = _"Discuss with initiators", - external = initiative.discussion_url - } - slot.put(" ") - end - else - slot.put(encode.html(initiative.discussion_url)) - end -end -if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then - ui.link{ - text = _"change discussion URL", - module = "initiative", - view = "edit", - id = initiative.id - } - slot.put(" ") -end -if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then - ui.link{ - content = function() - slot.put(_"Edit draft") - end, - module = "draft", - view = "new", - params = { initiative_id = initiative.id } - } - slot.put(" ") -end -if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then - ui.link{ - content = function() - slot.put(_"Revoke initiative") - end, - module = "initiative", - view = "revoke", - id = initiative.id - } - slot.put(" ") -end if not initiative.issue.closed then + slot.put(" · ") local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id) if ignored_initiative then ui.tag{ diff -r 20395309378a -r 344e5fdce8c9 config/development.lua --- a/config/development.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/config/development.lua Thu Jun 28 13:52:42 2012 +0200 @@ -33,7 +33,7 @@ --config.motd_intern = "==Internal motd==" -config.public_access = "full" +config.public_access = "anonym" -- you can put some js code to the bottom on the page -- here it opens the trace window diff -r 20395309378a -r 344e5fdce8c9 locale/translations.de.lua --- a/locale/translations.de.lua Thu Jun 28 01:02:03 2012 +0200 +++ b/locale/translations.de.lua Thu Jun 28 13:52:42 2012 +0200 @@ -43,7 +43,6 @@ ["Add my interest"] = "Mein Interesse anmelden"; ["Add new suggestion"] = "Neue Anregung hinzufügen"; ["Add new unit"] = "Neue Gliederung"; -["Add suggestion"] = "Neue Anregung"; ["Add to my contacts"] = "Zu meinen Kontakten hinzufügen"; ["Address"] = "Anschrift"; ["Admin"] = "Admin"; @@ -144,6 +143,7 @@ ["Created at"] = "Erzeugt am/um"; ["Current draft"] = "Aktueller Entwurf"; ["Current name"] = "Aktueller Name"; +["Latest draft created from #{name} at #{date} #{time}"] = "Letzter Entwurf von #{name} am #{date} um #{time}"; ["Current status"] = "Aktueller Status"; ["Current trustee"] = "Aktueller Delegierter"; ["Current votings in areas you are member of and issues you are interested in:"] = "Jetzt laufende Abstimmungen zu Themen aus Deinen Themenbereichen oder solchen an denen Du interessiert bist:"; @@ -260,7 +260,6 @@ ["Initiated"] = "Initiiert"; ["Initiative"] = "Initiative"; ["Initiative ##{id}"] = "Initiative ##{id}"; -["Initiative details"] = "Details zur Initiative"; ["Initiative events"] = "Initiativen-Ereignisse"; ["Initiative i#{id}: #{name}"] = "Initiative i#{id}: #{name}"; ["Initiative is revoked now"] = "Initiative ist jetzt zurückgezogen"; @@ -280,6 +279,7 @@ ["Interest removed"] = "Interesse entfernt"; ["Interest updated"] = "Interesse aktualisiert"; ["Interested"] = "Interessiert"; +["Interested members"] = "Interessierte Mitglieder"; ["Internal posts"] = "Interne Ämter"; ["Interval format:"] = "Intervall-Format"; ["Invalid query"] = "Ungültige Anfrage"; @@ -295,7 +295,6 @@ ["Issue accepted"] = "Thema akzeptiert"; ["Issue canceled"] = "Thema abgebrochen"; ["Issue delegation"] = "Issue-Delegation"; -["Issue details"] = "Details zum Thema"; ["Issue events"] = "Themen-Ereignisse"; ["Issue finished"] = "Thema abgeschlossen"; ["Issue finished without voting"] = "Thema ohne Abstimmung abgeschlossen"; @@ -336,7 +335,7 @@ ["Member page"] = "Mitgliederseite"; ["Member successfully registered"] = "Mitglied erfolgreich registriert"; ["Member successfully updated"] = "Mitglied erfolgreich aktualisert"; -["Member voting"] = "Abstimmungsverhalten"; +["Member voter"] = false; ["Member: '#{identification}' (#{name})"] = "Mitglied: '#{identification}' (#{name})"; ["Members"] = "Mitglieder"; ["Membership not existent"] = "Mitgliedschaft existiert nicht"; @@ -374,14 +373,18 @@ ["No more events available"] = "Keine weiteren Ereignisse verfügbar"; ["No multistage majority"] = "Keine mehrstufigen Mehrheiten"; ["No notifications at all"] = "Gar keine Benachrichtigungen"; +["No potential supporters"] = "Keine potentiellen Unterstützer"; +["No potential supporters (before begin of voting)"] = "Keine potentiellen Unterstützer (zum Abstimmungsbeginn)"; ["No reverse beat path"] = "Kein rückwärtsgerichteter Schlagpfad"; +["No suggestions"] = "Keine Anregungen"; +["No suggestions yet"] = "Noch keine Anregungen"; +["No supporters"] = "Keine Unterstützer"; +["No supporters (before begin of voting)"] = "Keine Unterstützer (zum Abstimmungsbeginn)"; ["Not a member"] = "Kein Mitglied"; ["Not accepted yet"] = "Bisher nicht angenommen"; ["Not approved"] = "Nicht angenommen"; ["Not approved (rank #{rank})"] = "Nicht angenommen (Rang #{rank})"; ["Not voted"] = "Nicht abgestimmt"; -["Not voted (not admitted)"] = "Nicht abgestimmt (nicht zugelassen)"; -["Not voted (revoked from initiator)"] = "Nicht abgestimmt (durch Initiator zurückgezogen)"; ["Not voted issues"] = "Nicht abgestimmt"; ["Notification address unconfirmed"] = "E-Mail-Adresse für Benachrichtigungen unbestätigt"; ["Notification email"] = "E-Mail für Benachrichtigungs"; @@ -449,6 +452,7 @@ ["Posts"] = "Ämter"; ["Potential supported"] = "Potentiell unterstützt"; ["Potential supporters"] = "Potentielle Unterstützer"; +["Potential supporters (before begin of voting)"] = "Potentielle Unterstützer (zum Abstimmungsbeginn)"; ["Potentially supported"] = "Potentiell unterstützt"; ["Preview"] = "Vorschau"; ["Profession"] = "Beruf"; @@ -512,6 +516,7 @@ ["Show help text"] = "Zeige Hilfe-Text"; ["Show member"] = "Mitglied anzeigen"; ["Show member history"] = "Historie des Mitglieds anzeigen"; +["Show old revision"] = "Zeige alte Entwürfe"; ["Show older events"] = "Zeige ältere Ereignisse"; ["Show only events which match... (or associtated)"] = "Zeige nur Ereignisse welche folgendes erfüllen... (oder-verknüpft)"; ["Show policies in use"] = "Zeige Regelwerke in Verwendung"; @@ -552,6 +557,7 @@ ["Support this initiative"] = "Diese Initiative unterstützen"; ["Supported"] = "Unterstützt"; ["Supporters"] = "Unterstützer"; +["Supporters (before begin of voting)"] = "Unterstützer (zum Abstimmungesbeginn)"; ["Syntax help"] = "Syntax-Hilfe"; ["Terms of use"] = "Nutzungsbedingungen"; ["The code you've entered is invalid"] = "Der Code, den Du eingeben hast, ist nicht gültig!"; @@ -561,7 +567,6 @@ ["This email address is too short!"] = "Diese E-Mail-Adresse ist zu kurz!"; ["This identifier is not allowed for this instance."] = "Dieser Identifier ist für diese Instanz nicht zugelassen."; ["This initiative"] = "Diese Initiative"; -["This initiative compared to alternative initiatives"] = "Diese Initiative im Vergleich zu alternativen Initiativen"; ["This initiative has been revoked at #{revoked}"] = "Diese Initiative wurde am/um #{revoked} zurückgezogen"; ["This initiative has not been admitted! It failed the quorum of #{quorum}."] = "Diese Initiative wurde nicht zugelassen. Sie hat das Quorum von #{quorum} nicht erreicht."; ["This initiative is already revoked"] = "Diese Initiative ist schon zurückgezogen"; @@ -668,7 +673,6 @@ ["You have ignored this initiative"] = "Du ignorierst diese Initiative"; ["You have ignored this member"] = "Du ignorierst dieses Mitglied"; ["You have not voted #{count} issue(s) you were interested in"] = "Du hast für #{count} Themen, die dich interessieren, noch nicht abgestimmt"; -["You have saved this member as contact"] = "Du hast das Mitglied als Kontakt gespeichert"; ["You have to mark 'Are you sure' to revoke!"] = "Zum Zurückziehen musst Du 'Sicher?' auswählen"; ["You have voting privileges for this unit"] = "Du hast Stimmrecht in dieser Gliederung"; ["You need to be logged in, to use all features of this system."] = "Du musst eingeloggt sein, um alle Funktionen dieses Systems nutzen zu können."; diff -r 20395309378a -r 344e5fdce8c9 static/style.css --- a/static/style.css Thu Jun 28 01:02:03 2012 +0200 +++ b/static/style.css Thu Jun 28 13:52:42 2012 +0200 @@ -346,6 +346,14 @@ padding: 8px 10px 2px 10px; } +.initiative_head .draft_version { + font-weight: bold; +} + +.initiative_head a.title { + display: block; +} + .area_list .title { padding: 8px 10px 0px 10px; } @@ -942,7 +950,6 @@ } .issue .suggestion { - margin-left: 1ex; margin-bottom: 1ex; font-weight: bold; } @@ -1285,7 +1292,7 @@ } .wiki { - line-height: 133%; + line-height: 150%; } .wiki h1,