liquid_feedback_frontend

annotate app/main/index/_member_home.lua @ 602:ae14bf355868

Changed all strings "Events" to "Latest events"
author bsw
date Sun Jun 24 22:50:40 2012 +0200 (2012-06-24)
parents 9423b529d5a4
children 7dc5ab12bfe3
rev   line source
bsw@558 1 local member = param.get("member", "table")
bsw@558 2 local for_member = param.get("for_member", atom.boolean)
bsw@598 3 local filter_unit = param.get_all_cgi()["filter_unit"] or "my_areas"
bsw@558 4
bsw@594 5 if not for_member then
bsw@594 6 execute.view{
bsw@594 7 module = "index", view = "_notifications"
bsw@558 8 }
bsw@594 9
bsw@598 10 ui.container{ attr = { class = "ui_filter" }, content = function()
bsw@598 11 ui.container{ attr = { class = "ui_filter_head" }, content = function()
bsw@598 12
bsw@598 13 ui.link{
bsw@598 14 attr = { class = filter_unit == "my_areas" and "ui_tabs_link active" or nil },
bsw@598 15 text = _"My areas",
bsw@598 16 module = "index", view = "index", params = { filter_unit = "my_areas" }
bsw@598 17 }
bsw@598 18
bsw@598 19 slot.put(" ")
bsw@594 20
bsw@598 21 ui.link{
bsw@598 22 attr = { class = filter_unit == "my_units" and "ui_tabs_link active" or nil },
bsw@598 23 text = _"All areas in my units",
bsw@598 24 module = "index", view = "index", params = { filter_unit = "my_units" }
bsw@598 25 }
bsw@598 26
bsw@598 27 slot.put(" ")
bsw@558 28
bsw@598 29 ui.link{
bsw@598 30 attr = { class = filter_unit == "global" and "active" or nil },
bsw@598 31 text = _"All units",
bsw@598 32 module = "index", view = "index", params = { filter_unit = "global" }
bsw@598 33 }
bsw@598 34 end }
bsw@594 35 end }
bsw@594 36 end
bsw@558 37
bsw@594 38 slot.put("<br />")
bsw@558 39
bsw@594 40 if not for_member then
bsw@594 41 if filter_unit == "global" then
bsw@594 42 execute.view{ module = "unit", view = "_list" }
bsw@594 43 return
bsw@594 44 end
bsw@594 45
bsw@558 46 end
bsw@558 47
bsw@598 48 local units = Unit:new_selector():add_order_by("name"):exec()
bsw@598 49
bsw@598 50 if member then
bsw@598 51 units:load_delegation_info_once_for_member_id(member.id)
bsw@598 52 end
bsw@558 53
bsw@558 54 for i, unit in ipairs(units) do
bsw@571 55 if member:has_voting_right_for_unit_id(unit.id) then
bsw@598 56
bsw@571 57 local areas_selector = Area:new_selector()
bsw@598 58 :reset_fields()
bsw@598 59 :add_field("area.id", nil, { "grouped" })
bsw@598 60 :add_field("area.name", nil, { "grouped" })
bsw@598 61 :add_field("member_weight", nil, { "grouped" })
bsw@598 62 :add_field("direct_member_count", nil, { "grouped" })
bsw@598 63 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted ISNULL AND issue.closed ISNULL)", "issues_new_count")
bsw@598 64 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL)", "issues_discussion_count")
bsw@598 65 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL AND issue.closed ISNULL)", "issues_frozen_count")
bsw@598 66 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL)", "issues_voting_count")
bsw@598 67 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed NOTNULL)", "issues_finished_count")
bsw@598 68 :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen ISNULL AND issue.closed NOTNULL)", "issues_cancelled_count")
bsw@571 69 :add_where{ "area.unit_id = ?", unit.id }
bsw@571 70 :add_where{ "area.active" }
bsw@598 71 :add_order_by("area.name")
bsw@598 72
bsw@598 73 if filter_unit == "my_areas" then
bsw@598 74 areas_selector:join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
bsw@598 75 end
bsw@571 76
bsw@571 77 local area_count = areas_selector:count()
bsw@571 78
bsw@598 79 ui.container{ attr = { class = "area_list" }, content = function()
bsw@571 80 ui.container{ attr = { class = "unit_head" }, content = function()
bsw@571 81 ui.link{
bsw@571 82 text = unit.name,
bsw@571 83 module = "unit", view = "show", id = unit.id
bsw@571 84 }
bsw@558 85
bsw@598 86 execute.view{ module = "delegation", view = "_info", params = { unit = unit } }
bsw@598 87 end }
bsw@598 88
bsw@598 89 if area_count > 0 then
bsw@598 90 local areas = areas_selector:exec()
bsw@598 91 for i, area in ipairs(areas) do
bsw@571 92 execute.view{
bsw@598 93 module = "area", view = "_list_entry", params = {
bsw@598 94 area = area
bsw@571 95 }
bsw@571 96 }
bsw@571 97 end
bsw@571 98 elseif member:has_voting_right_for_unit_id(unit.id) then
bsw@598 99 ui.container{ attr = { class = "area" }, content = function()
bsw@598 100 ui.container{ attr = { class = "content" }, content = function()
bsw@598 101 slot.put("<br />")
bsw@598 102 if for_member then
bsw@598 103 ui.tag{ content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
bsw@598 104 else
bsw@598 105 ui.tag{ content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
bsw@598 106 end
bsw@598 107 end }
bsw@598 108 end }
bsw@571 109 end
bsw@571 110 local max_area_count = Area:new_selector()
bsw@571 111 :add_where{ "area.unit_id = ?", unit.id }
bsw@571 112 :add_where{ "area.active" }
bsw@571 113 :count()
bsw@571 114 local more_area_count = max_area_count - area_count
bsw@571 115 local delegated_count = Area:new_selector()
bsw@571 116 :add_where{ "area.unit_id = ?", unit.id }
bsw@571 117 :add_where{ "area.active" }
bsw@571 118 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
bsw@571 119 :add_where{ "membership.member_id ISNULL" }
bsw@571 120 :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
bsw@598 121 :add_where{ "delegation.trustee_id NOTNULL" }
bsw@571 122 :count()
bsw@571 123 if more_area_count > 0 then
bsw@598 124 ui.container{ attr = { class = "area" }, content = function()
bsw@598 125 ui.container{ attr = { class = "content" }, content = function()
bsw@598 126 slot.put("<br />")
bsw@601 127 local text
bsw@601 128 if more_area_count == 1 then
bsw@601 129 text = _("One more area in this unit")
bsw@601 130 else
bsw@601 131 text = _("#{count} more areas in this unit", { count = more_area_count })
bsw@601 132 end
bsw@601 133 ui.link{ module = "unit", view = "show", id = unit.id, text = text }
bsw@601 134 if delegated_count > 0 then
bsw@601 135 slot.put(" &middot; ")
bsw@601 136 local text
bsw@601 137 if delegated_count == 1 then
bsw@601 138 text = _("One of them have an area delegation set", { count = delegated_count })
bsw@601 139 else
bsw@601 140 text = _("#{count} of them have an area delegation set", { count = delegated_count })
bsw@601 141 end
bsw@601 142 ui.tag{ content = text }
bsw@601 143 end
bsw@598 144 end }
bsw@571 145 end }
bsw@558 146 end
bsw@598 147 slot.put("<br />")
bsw@598 148 slot.put("<br />")
bsw@558 149 end }
bsw@571 150 end
bsw@558 151 end
bsw@558 152
bsw@558 153

Impressum / About Us