# HG changeset patch # User bsw # Date 1340133646 -7200 # Node ID 18e8de7a2b6a6a259728fb001dfded6b0d03d4af # Parent fc01e21c3d41409d93ed7c70cbc89bef1383cfc2 Show notifications on start page as ulli list with links instead of tabs diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/_index_member.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/_index_member.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,68 @@ + +local tabs = { + module = "index", + view = "index" +} + +local areas_selector = app.session.member:get_reference_selector("areas") +tabs[#tabs+1] = { + name = "areas", + label = _"Home", + icon = { static = "icons/16/package.png" }, + module = "index", + view = "_member_home", + params = { areas_selector = areas_selector, member = app.session.member, for_member = true }, +} + +tabs[#tabs+1] = { + name = "timeline", + label = _"Latest events", + module = "member", + view = "_event_list", + params = { } +} + + +tabs[#tabs+1] = { + name = "open", + label = _"Open issues", + module = "issue", + view = "_list", + link_params = { + filter_interest = not show_as_homepage and "issue" or nil, + }, + params = { + for_state = "open", + issues_selector = Issue:new_selector() + :add_where("issue.closed ISNULL") + :add_order_by("coalesce(issue.fully_frozen + issue.voting_time, issue.half_frozen + issue.verification_time, issue.accepted + issue.discussion_time, issue.created + issue.admission_time) - now()") + } +} + +tabs[#tabs+1] = { + name = "closed", + label = _"Closed issues", + module = "issue", + view = "_list", + link_params = { + filter_interest = not show_as_homepage and "issue" or nil, + }, + params = { + for_state = "closed", + issues_selector = Issue:new_selector() + :add_where("issue.closed NOTNULL") + :add_order_by("issue.closed DESC") + + } +} + +tabs[#tabs+1] = { + name = "members", + label = _"Members", + module = 'member', + view = '_list', + params = { members_selector = Member:new_selector() } +} + + +ui.tabs(tabs) diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/_initiator_invites.lua --- a/app/main/index/_initiator_invites.lua Tue Jun 19 18:45:45 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -local initiatives_selector = param.get("initiatives_selector", "table") - -if initiatives_selector:count() > 0 then - ui.container{ - attr = { style = "font-weight: bold;" }, - content = _"Initiatives that invited you to become initiator:" - } - - execute.view{ - module = "initiative", - view = "_list", - params = { initiatives_selector = initiatives_selector } - } -else - ui.field.text{ value = _"You are currently not invited to any initiative." } -end \ No newline at end of file diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/_member_home.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/_member_home.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,113 @@ +local member = param.get("member", "table") +local for_member = param.get("for_member", atom.boolean) +local filter_unit = param.get_all_cgi()["filter_unit"] or "personal" + + +execute.view{ + module = "index", view = "_notifications" +} + + +ui.container{ attr = { class = "ui_filter_head" }, content = function() + + ui.link{ + attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil }, + text = _"My units and areas", + module = "index", view = "index", params = { filter_unit = "personal" } + } + + slot.put(" ") + + ui.link{ + attr = { class = filter_unit == "global" and "active" or nil }, + text = _"All units", + module = "index", view = "index", params = { filter_unit = "global" } + } +end } + +slot.put("
") + + +if filter_unit == "global" then + execute.view{ module = "unit", view = "_list" } + return +end + +local units = Unit:new_selector():exec() + +for i, unit in ipairs(units) do + local trustee_member = Member:new_selector() + :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id }) + :optional_object_mode() + :exec() + + local areas_selector = Area:new_selector() + :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id }) + :add_where{ "area.unit_id = ?", unit.id } + :add_where{ "area.active" } + :add_order_by("area.member_weight DESC") + + local area_count = areas_selector:count() + + ui.container{ attr = { class = "member_area_list" }, content = function() + ui.container{ attr = { class = "xunit_head" }, content = function() + ui.link{ + text = unit.name, + module = "unit", view = "show", id = unit.id + } + + if trustee_member then + local text = _("Unit delegated to '#{name}'", { name = trustee_member.name }) + ui.image{ + attr = { class = "delegation_arrow", alt = text, title = text }, + static = "delegation_arrow_24_horizontal.png" + } + execute.view{ + module = "member_image", + view = "_show", + params = { + member = trustee_member, + image_type = "avatar", + show_dummy = true, + class = "micro_avatar", + popup_text = text + } + } + end + end } + + if area_count > 0 then + execute.view{ + module = "area", view = "_list", + params = { areas_selector = areas_selector, hide_membership = true } + } + elseif member:has_voting_right_for_unit_id(unit.id) then + if for_member then + ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." } + else + ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." } + end + end + local max_area_count = Area:new_selector() + :add_where{ "area.unit_id = ?", unit.id } + :add_where{ "area.active" } + :count() + local more_area_count = max_area_count - area_count + local delegated_count = Area:new_selector() + :add_where{ "area.unit_id = ?", unit.id } + :add_where{ "area.active" } + :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } ) + :add_where{ "membership.member_id ISNULL" } + :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } ) + :count() + if more_area_count > 0 then + slot.put("
") + ui.container{ attr = { class = "more_areas" }, content = function() + ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id } + end } + end + end } + +end + + diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/_notifications.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/_notifications.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,79 @@ +local notification_links = {} + +if app.session.member.notify_email_unconfirmed then + notification_links[#notification_links+1] = { + module = "index", view = "email_unconfirmed", + text = _"Please confirm your email address" + } +end + +if app.session.member.notify_level == nil then + notification_links[#notification_links+1] = { + module = "member", view = "settings_notification", + text = _"Please select your preferred notification level" + } +end + +local broken_delegations_count = Delegation:selector_for_broken(app.session.member_id):count() + +if broken_delegations_count > 0 then + notification_links[#notification_links+1] = { + module = "index", view = "broken_delegations", + text = _("#{count} of your outgoing delegation(s) are broken", { count = broken_delegations_count }) + } + +end + +local selector = Issue:new_selector() + :join("area", nil, "area.id = issue.area_id") + :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id }) + :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id }) + :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id }) + :add_where{ "direct_voter.member_id ISNULL" } + :add_where{ "interest.member_id NOTNULL" } + :add_where{ "issue.fully_frozen NOTNULL" } + :add_where{ "issue.closed ISNULL" } + :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" } + +local issues_to_vote_count = selector:count() +if issues_to_vote_count > 0 then + notification_links[#notification_links+1] = { + module = "index", view = "index", + params = { + tab = "open", filter = "frozen", filter_interest = "issue", filter_voting = "not_voted" + }, + text = _("You have not voted #{count} issue(s) you was interested in", { count = issues_to_vote_count }) + } +end + +local initiator_invites_count = Initiator:selector_for_invites(app.session.member_id):count() + +if initiator_invites_count > 0 then + notification_links[#notification_links+1] = { + module = "index", view = "initiator_invites", + text = _("You are invited to #{count} initiative(s)", { count = initiator_invites_count }) + } +end + +updated_drafts_count = Initiative:selector_for_updated_drafts(app.session.member_id):count() + +if updated_drafts_count > 0 then + notification_links[#notification_links+1] = { + module = "index", view = "updated_drafts", + text = _("New drafts for #{count} initiative(s) you are supporting", { count = updated_drafts_count }) + } +end + +if #notification_links > 0 then + ui.container{ attr = { class = "notifications" }, content = function() + ui.tag{ tag = "ul", attr = { class = "notifications" }, content = function() + for i, notification_link in ipairs(notification_links) do + ui.tag{ tag = "li", content = function() + ui.link(notification_link) + end } + end + end } + end } +end + + diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/_updated_drafts.lua --- a/app/main/index/_updated_drafts.lua Tue Jun 19 18:45:45 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -local initiatives_selector = param.get("initiatives_selector", "table") -if initiatives_selector:count() > 0 then - ui.container{ - attr = { class = "heading" }, - content = _"Open initiatives you are supporting which has been updated their draft:" - } - - slot.put("
") - - execute.view{ - module = "initiative", - view = "_list", - params = { initiatives_selector = initiatives_selector } - } -end \ No newline at end of file diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/broken_delegations.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/broken_delegations.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,8 @@ +execute.view{ + module = "delegation", + view = "_list", + params = { + delegations_selector = Delegation:selector_for_broken(app.session.member_id), + outgoing = true + } +} diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/email_unconfirmed.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/email_unconfirmed.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,51 @@ +if app.session.member.notify_email_unconfirmed then + + local current = Member:new_selector() + :add_where{ "id = ?", app.session.member_id } + :add_where("notify_email_unconfirmed NOTNULL") + :add_where("notify_email_secret_expiry > now()") + :optional_object_mode() + :exec() + + slot.select("title", function() + ui.tag{ content = _"Notification address unconfirmed" } + end ) + + if current then + ui.tag{ + tag = "div", + content = _("You didn't confirm your email address '#{email}'. You have received an email with an activation link.", { email = app.session.member.notify_email_unconfirmed }) + } + else + ui.tag{ + tag = "div", + content = _("You didn't confirm your email address '#{email}' within 7 days.", { email = app.session.member.notify_email_unconfirmed }) + } + end + slot.put("
") + + ui.link{ + text = _"Change email address", + module = "member", + view = "settings_email", + } + slot.put("
") + slot.put("
") + + ui.link{ + text = _("Resend activation email to '#{email}'", { email = app.session.member.notify_email_unconfirmed }), + module = "member", + action = "update_email", + params = { + resend = true + }, + routing = { + default = { + mode = "redirect", + module = "index", + view = "index" + } + } + } + +end diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/index.lua --- a/app/main/index/index.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/app/main/index/index.lua Tue Jun 19 21:20:46 2012 +0200 @@ -2,12 +2,7 @@ util.help("index.index", _"Home") execute.view{ - module = "member", - view = "_show", - params = { - member = app.session.member, - show_as_homepage = true - } + module = "index", view = "_index_member" } elseif config.public_access then diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/initiator_invites.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/initiator_invites.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,18 @@ + + +local initiatives_selector = Initiator:selector_for_invites(app.session.member_id) + +if initiatives_selector:count() > 0 then + ui.container{ + attr = { style = "font-weight: bold;" }, + content = _"Initiatives that invited you to become initiator:" + } + + execute.view{ + module = "initiative", + view = "_list", + params = { initiatives_selector = initiatives_selector } + } +else + ui.field.text{ value = _"You are currently not invited to any initiative." } +end \ No newline at end of file diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/notification_level.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/notification_level.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,19 @@ +ui.heading{ level = 2, content = _"Notification level not set yet" } + +slot.put("
") + +ui.tag{ + tag = "div", + content = _"You didn't set the level of notifications you like to receive" +} + +slot.put("
") + +ui.link{ + text = _"Configure notifications now", + module = "member", + view = "settings_notification", +} +slot.put("
") +slot.put("
") + diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/index/updated_drafts.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/index/updated_drafts.lua Tue Jun 19 21:20:46 2012 +0200 @@ -0,0 +1,14 @@ +local initiatives_selector = Initiative:selector_for_updated_drafts(app.session.member_id) + +ui.container{ + attr = { class = "heading" }, + content = _"Open initiatives you are supporting which has been updated their draft:" +} + +slot.put("
") + +execute.view{ + module = "initiative", + view = "_list", + params = { initiatives_selector = initiatives_selector } +} diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/initiative/_list.lua --- a/app/main/initiative/_list.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/app/main/initiative/_list.lua Tue Jun 19 21:20:46 2012 +0200 @@ -1,6 +1,13 @@ local issue = param.get("issue", "table") +local initiatives_selector = param.get("initiatives_selector", "table") -local initiatives = issue.initiatives +local initiatives +if issue then + initiatives = issue.initiatives +else + initiatives = initiatives_selector:exec() + initiatives:load_everything_for_member_id(app.session.member_id) +end local highlight_initiative = param.get("highlight_initiative", "table") @@ -21,8 +28,6 @@ end end -local issue = param.get("issue", "table") - local name = "initiative_list" if issue then name = "issue_" .. tostring(issue.id) .. "_initiative_list" diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/member/_area_list.lua --- a/app/main/member/_area_list.lua Tue Jun 19 18:45:45 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -local member = param.get("member", "table") -local for_member = param.get("for_member", atom.boolean) -local filter_unit = param.get_all_cgi()["filter_unit"] or "personal" - -ui.container{ attr = { class = "ui_filter_head" }, content = function() - - ui.link{ - attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil }, - text = _"With voting right", - module = "index", view = "index", params = { filter_unit = "personal" } - } - - slot.put(" ") - - ui.link{ - attr = { class = filter_unit == "global" and "active" or nil }, - text = _"All units", - module = "index", view = "index", params = { filter_unit = "global" } - } -end } - -slot.put("
") - - -if filter_unit == "global" then - execute.view{ module = "unit", view = "_list" } - return -end - -local units = Unit:new_selector():exec() - -for i, unit in ipairs(units) do - local trustee_member = Member:new_selector() - :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id }) - :optional_object_mode() - :exec() - - local areas_selector = Area:new_selector() - :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id }) - :add_where{ "area.unit_id = ?", unit.id } - :add_where{ "area.active" } - :add_order_by("area.member_weight DESC") - - local area_count = areas_selector:count() - - ui.container{ attr = { class = "member_area_list" }, content = function() - ui.container{ attr = { class = "xunit_head" }, content = function() - ui.link{ - text = unit.name, - module = "unit", view = "show", id = unit.id - } - - if trustee_member then - local text = _("Unit delegated to '#{name}'", { name = trustee_member.name }) - ui.image{ - attr = { class = "delegation_arrow", alt = text, title = text }, - static = "delegation_arrow_24_horizontal.png" - } - execute.view{ - module = "member_image", - view = "_show", - params = { - member = trustee_member, - image_type = "avatar", - show_dummy = true, - class = "micro_avatar", - popup_text = text - } - } - end - end } - - if area_count > 0 then - execute.view{ - module = "area", view = "_list", - params = { areas_selector = areas_selector, hide_membership = true } - } - elseif member:has_voting_right_for_unit_id(unit.id) then - if for_member then - ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." } - else - ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." } - end - end - local max_area_count = Area:new_selector() - :add_where{ "area.unit_id = ?", unit.id } - :add_where{ "area.active" } - :count() - local more_area_count = max_area_count - area_count - local delegated_count = Area:new_selector() - :add_where{ "area.unit_id = ?", unit.id } - :add_where{ "area.active" } - :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } ) - :add_where{ "membership.member_id ISNULL" } - :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } ) - :count() - if more_area_count > 0 then - slot.put("
") - ui.container{ attr = { class = "more_areas" }, content = function() - ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id } - end } - end - end } - -end - - diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/member/_email_unconfirmed.lua --- a/app/main/member/_email_unconfirmed.lua Tue Jun 19 18:45:45 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -if app.session.member.notify_email_unconfirmed then - - local current = Member:new_selector() - :add_where{ "id = ?", app.session.member_id } - :add_where("notify_email_unconfirmed NOTNULL") - :add_where("notify_email_secret_expiry > now()") - :optional_object_mode() - :exec() - - ui.heading{ level = 2, content = _"Notification address unconfirmed" } - - if current then - ui.tag{ - tag = "div", - content = _("You didn't confirm your email address '#{email}'. You have received an email with an activation link.", { email = app.session.member.notify_email_unconfirmed }) - } - else - ui.tag{ - tag = "div", - content = _("You didn't confirm your email address '#{email}' within 7 days.", { email = app.session.member.notify_email_unconfirmed }) - } - end - slot.put("
") - - ui.link{ - text = _"Change email address", - module = "member", - view = "settings_email", - } - slot.put("
") - slot.put("
") - - ui.link{ - text = _("Resend activation email to '#{email}'", { email = app.session.member.notify_email_unconfirmed }), - module = "member", - action = "update_email", - params = { - resend = true - }, - routing = { - default = { - mode = "redirect", - module = "index", - view = "index" - } - } - } - -end diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/member/_notify_level_not_set.lua --- a/app/main/member/_notify_level_not_set.lua Tue Jun 19 18:45:45 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -ui.heading{ level = 2, content = _"Notification level not set yet" } - -slot.put("
") - -ui.tag{ - tag = "div", - content = _"You didn't set the level of notifications you like to receive" -} - -slot.put("
") - -ui.link{ - text = _"Configure notifications now", - module = "member", - view = "settings_notification", -} -slot.put("
") -slot.put("
") - diff -r fc01e21c3d41 -r 18e8de7a2b6a app/main/member/_show.lua --- a/app/main/member/_show.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/app/main/member/_show.lua Tue Jun 19 21:20:46 2012 +0200 @@ -1,136 +1,21 @@ -local show_as_homepage = param.get("show_as_homepage", atom.boolean) - local member = param.get("member", "table") local tabs = { module = "member", view = "show_tab", static_params = { - member_id = member.id, - show_as_homepage = show_as_homepage + member_id = member.id } } -if show_as_homepage and app.session.member_id == member.id then - - if app.session.member.notify_email_unconfirmed then - tabs[#tabs+1] = { - class = "yellow", - name = "email_unconfirmed", - label = _"Email unconfirmed", - module = "member", - view = "_email_unconfirmed", - params = {} - } - end - - if app.session.member.notify_level == nil then - tabs[#tabs+1] = { - class = "yellow", - name = "notify_level_not_set", - label = _"Notifications", - module = "member", - view = "_notify_level_not_set" - } - end - - local broken_delegations = Delegation:new_selector() - :join("issue", nil, "issue.id = delegation.issue_id AND issue.closed ISNULL") - :join("member", nil, "delegation.trustee_id = member.id") - :add_where{"delegation.truster_id = ?", member.id} - :add_where{"member.active = 'f' OR (member.last_activity IS NULL OR age(member.last_activity) > ?::interval)", config.delegation_warning_time } - - if broken_delegations:count() > 0 then - tabs[#tabs+1] = { - class = "red", - name = "broken_delegations", - label = _"Delegation problems" .. " (" .. tostring(broken_delegations:count()) .. ")", - icon = { static = "icons/16/table_go.png" }, - module = "delegation", - view = "_list", - params = { delegations_selector = broken_delegations, outgoing = true }, - } - end - - local selector = Issue:new_selector() - :join("area", nil, "area.id = issue.area_id") - :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id }) - :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id }) - :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id }) - :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ? ", app.session.member.id }) - :add_where{ "direct_voter.member_id ISNULL" } - :add_where{ "interest.member_id NOTNULL OR membership.member_id NOTNULL" } - :add_where{ "issue.fully_frozen NOTNULL" } - :add_where{ "issue.closed ISNULL" } - :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" } - - local count = selector:count() - if count > 0 then - tabs[#tabs+1] = { - class = "yellow", - name = "not_voted_issues", - label = _"Now in voting" .. " (" .. tostring(count) .. ")", - icon = { static = "icons/16/email_open.png" }, - module = "issue", - view = "_list", - params = { - issues_selector = selector, - no_filter = true - } - } - end - - local initiator_invites_selector = Initiative:new_selector() - :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id") - :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", app.session.member.id }) - :add_where("_issue_state.closed ISNULL AND _issue_state.half_frozen ISNULL") - - if initiator_invites_selector:count() > 0 then - tabs[#tabs+1] = { - class = "yellow", - name = "initiator_invites", - label = _"Initiator invites" .. " (" .. tostring(initiator_invites_selector:count()) .. ")", - icon = { static = "icons/16/user_add.png" }, - module = "index", - view = "_initiator_invites", - params = { - initiatives_selector = initiator_invites_selector - } - } - end - - local updated_drafts_selector = Initiative:new_selector() - :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id AND _issue_state.closed ISNULL AND _issue_state.fully_frozen ISNULL") - :join("current_draft", "_current_draft", "_current_draft.initiative_id = initiative.id") - :join("supporter", "supporter", { "supporter.member_id = ? AND supporter.initiative_id = initiative.id AND supporter.draft_id < _current_draft.id", app.session.member_id }) - :add_where("initiative.revoked ISNULL") - - if updated_drafts_selector:count() > 0 then - tabs[#tabs+1] = { - class = "yellow", - name = "updated_drafts", - label = _"Updated drafts" .. " (" .. tostring(updated_drafts_selector:count()) .. ")", - icon = { static = "icons/16/script.png" }, - module = "index", - view = "_updated_drafts", - params = { - initiatives_selector = updated_drafts_selector - } - } - end -end - -if not show_as_homepage then - tabs[#tabs+1] = { - name = "profile", - label = _"Profile", - icon = { static = "icons/16/application_form.png" }, - module = "member", - view = "_profile", - params = { member = member }, - } -end - +tabs[#tabs+1] = { + name = "profile", + label = _"Profile", + icon = { static = "icons/16/application_form.png" }, + module = "member", + view = "_profile", + params = { member = member }, +} local areas_selector = member:get_reference_selector("areas") tabs[#tabs+1] = { @@ -139,26 +24,16 @@ icon = { static = "icons/16/package.png" }, module = "member", view = "_area_list", - params = { areas_selector = areas_selector, member = member, for_member = not show_as_homepage }, + params = { areas_selector = areas_selector, member = member, for_member = true }, } -if show_as_homepage then - tabs[#tabs+1] = { - name = "timeline", - label = _"Latest events", - module = "member", - view = "_event_list", - params = { } - } -else - tabs[#tabs+1] = { - name = "timeline", - label = _"Events", - module = "event", - view = "_list", - params = { for_member = member } - } -end +tabs[#tabs+1] = { + name = "timeline", + label = _"Events", + module = "event", + view = "_list", + params = { for_member = member } +} tabs[#tabs+1] = { name = "open", @@ -166,11 +41,11 @@ module = "issue", view = "_list", link_params = { - filter_interest = not show_as_homepage and "issue" or nil, + filter_interest = "issue", }, params = { for_state = "open", - for_member = not show_as_homepage and member or nil, + for_member = member, issues_selector = Issue:new_selector() :add_where("issue.closed ISNULL") :add_order_by("coalesce(issue.fully_frozen + issue.voting_time, issue.half_frozen + issue.verification_time, issue.accepted + issue.discussion_time, issue.created + issue.admission_time) - now()") @@ -183,11 +58,11 @@ module = "issue", view = "_list", link_params = { - filter_interest = not show_as_homepage and "issue" or nil, + filter_interest = "issue", }, params = { for_state = "closed", - for_member = not show_as_homepage and member or nil, + for_member = member, issues_selector = Issue:new_selector() :add_where("issue.closed NOTNULL") :add_order_by("issue.closed DESC") @@ -195,52 +70,39 @@ } } -if show_as_homepage then - tabs[#tabs+1] = { - name = "members", - label = _"Members", - module = 'member', - view = '_list', - params = { members_selector = Member:new_selector() } - } -end - +local outgoing_delegations_selector = member:get_reference_selector("outgoing_delegations") + :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id") + :add_where("_member_showtab_issue.closed ISNULL") +tabs[#tabs+1] = { + name = "outgoing_delegations", + label = _"Outgoing delegations" .. " (" .. tostring(outgoing_delegations_selector:count()) .. ")", + icon = { static = "icons/16/table_go.png" }, + module = "delegation", + view = "_list", + params = { delegations_selector = outgoing_delegations_selector, outgoing = true }, +} -if not show_as_homepage then - local outgoing_delegations_selector = member:get_reference_selector("outgoing_delegations") - :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id") - :add_where("_member_showtab_issue.closed ISNULL") - tabs[#tabs+1] = { - name = "outgoing_delegations", - label = _"Outgoing delegations" .. " (" .. tostring(outgoing_delegations_selector:count()) .. ")", - icon = { static = "icons/16/table_go.png" }, - module = "delegation", - view = "_list", - params = { delegations_selector = outgoing_delegations_selector, outgoing = true }, - } +local incoming_delegations_selector = member:get_reference_selector("incoming_delegations") + :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id") + :add_where("_member_showtab_issue.closed ISNULL") +tabs[#tabs+1] = { + name = "incoming_delegations", + label = _"Incoming delegations" .. " (" .. tostring(incoming_delegations_selector:count()) .. ")", + icon = { static = "icons/16/table_go.png" }, + module = "delegation", + view = "_list", + params = { delegations_selector = incoming_delegations_selector, incoming = true }, +} - local incoming_delegations_selector = member:get_reference_selector("incoming_delegations") - :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id") - :add_where("_member_showtab_issue.closed ISNULL") - tabs[#tabs+1] = { - name = "incoming_delegations", - label = _"Incoming delegations" .. " (" .. tostring(incoming_delegations_selector:count()) .. ")", - icon = { static = "icons/16/table_go.png" }, - module = "delegation", - view = "_list", - params = { delegations_selector = incoming_delegations_selector, incoming = true }, - } - - local contacts_selector = member:get_reference_selector("saved_members"):add_where("public") - tabs[#tabs+1] = { - name = "contacts", - label = _"Contacts" .. " (" .. tostring(contacts_selector:count()) .. ")", - icon = { static = "icons/16/book_edit.png" }, - module = "member", - view = "_list", - params = { members_selector = contacts_selector }, - } -end +local contacts_selector = member:get_reference_selector("saved_members"):add_where("public") +tabs[#tabs+1] = { + name = "contacts", + label = _"Contacts" .. " (" .. tostring(contacts_selector:count()) .. ")", + icon = { static = "icons/16/book_edit.png" }, + module = "member", + view = "_list", + params = { members_selector = contacts_selector }, +} ui.tabs(tabs) diff -r fc01e21c3d41 -r 18e8de7a2b6a model/delegation.lua --- a/model/delegation.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/model/delegation.lua Tue Jun 19 21:20:46 2012 +0200 @@ -53,3 +53,12 @@ end return selector:exec() end + +function Delegation:selector_for_broken(member_id) + return Delegation:new_selector() + :join("issue", nil, "issue.id = delegation.issue_id AND issue.closed ISNULL") + :join("member", nil, "delegation.trustee_id = member.id") + :add_where{"delegation.truster_id = ?", member_id} + :add_where{"member.active = 'f' OR (member.last_activity IS NULL OR age(member.last_activity) > ?::interval)", config.delegation_warning_time } +end + \ No newline at end of file diff -r fc01e21c3d41 -r 18e8de7a2b6a model/initiative.lua --- a/model/initiative.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/model/initiative.lua Tue Jun 19 21:20:46 2012 +0200 @@ -215,10 +215,13 @@ :add_group_by("_direct_supporter_snapshot.member_id") end ---function Member:get_search_selector(search_string) --- return self:new_selector() --- :add_where("active") ---end +function Initiative:selector_for_updated_drafts(member_id) + return Initiative:new_selector() + :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id AND _issue_state.closed ISNULL AND _issue_state.fully_frozen ISNULL") + :join("current_draft", "_current_draft", "_current_draft.initiative_id = initiative.id") + :join("supporter", "supporter", { "supporter.member_id = ? AND supporter.initiative_id = initiative.id AND supporter.draft_id < _current_draft.id", member_id }) + :add_where("initiative.revoked ISNULL") +end function Initiative.object_get:current_draft() diff -r fc01e21c3d41 -r 18e8de7a2b6a model/initiator.lua --- a/model/initiator.lua Tue Jun 19 18:45:45 2012 +0200 +++ b/model/initiator.lua Tue Jun 19 21:20:46 2012 +0200 @@ -25,3 +25,10 @@ :optional_object_mode() :exec() end + +function Initiator:selector_for_invites(member_id) + return Initiative:new_selector() + :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id") + :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", member_id }) + :add_where("_issue_state.closed ISNULL AND _issue_state.half_frozen ISNULL") +end diff -r fc01e21c3d41 -r 18e8de7a2b6a static/style.css --- a/static/style.css Tue Jun 19 18:45:45 2012 +0200 +++ b/static/style.css Tue Jun 19 21:20:46 2012 +0200 @@ -514,6 +514,25 @@ } /************************************************************************* + * notifications + */ + +.notifications { + margin-top: 1ex; + background-color: #fdd; + padding: 1ex; +} + +.notifications ul { + margin: 0; + margin-left: 2em; +} + +.notifications li { + margin-top: 0.5ex; +} + +/************************************************************************* * vertical ui.form */