liquid_feedback_frontend

annotate app/main/index/_member_home.lua @ 759:08052bcabb7f

Added tag translate for changeset ea5e8d55a5f0
author bsw
date Thu Jun 28 22:57:50 2012 +0200 (2012-06-28)
parents 7567db9ef18e
children a3eb6ca34484
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@619 6
bsw@598 7 ui.container{ attr = { class = "ui_filter" }, content = function()
bsw@598 8 ui.container{ attr = { class = "ui_filter_head" }, content = function()
bsw@598 9
bsw@598 10 ui.link{
bsw@598 11 attr = { class = filter_unit == "my_areas" and "ui_tabs_link active" or nil },
bsw@598 12 text = _"My areas",
bsw@598 13 module = "index", view = "index", params = { filter_unit = "my_areas" }
bsw@598 14 }
bsw@598 15
bsw@598 16 slot.put(" ")
bsw@594 17
bsw@598 18 ui.link{
bsw@598 19 attr = { class = filter_unit == "my_units" and "ui_tabs_link active" or nil },
bsw@598 20 text = _"All areas in my units",
bsw@598 21 module = "index", view = "index", params = { filter_unit = "my_units" }
bsw@598 22 }
bsw@598 23
bsw@598 24 slot.put(" ")
bsw@558 25
bsw@598 26 ui.link{
bsw@598 27 attr = { class = filter_unit == "global" and "active" or nil },
bsw@598 28 text = _"All units",
bsw@598 29 module = "index", view = "index", params = { filter_unit = "global" }
bsw@598 30 }
bsw@598 31 end }
bsw@594 32 end }
bsw@594 33 end
bsw@558 34
bsw@594 35 if not for_member then
bsw@594 36 if filter_unit == "global" then
bsw@594 37 execute.view{ module = "unit", view = "_list" }
bsw@594 38 return
bsw@594 39 end
bsw@594 40
bsw@558 41 end
bsw@558 42
bsw@598 43 local units = Unit:new_selector():add_order_by("name"):exec()
bsw@598 44
bsw@598 45 if member then
bsw@598 46 units:load_delegation_info_once_for_member_id(member.id)
bsw@598 47 end
bsw@558 48
bsw@558 49 for i, unit in ipairs(units) do
bsw@571 50 if member:has_voting_right_for_unit_id(unit.id) then
bsw@598 51
bsw@571 52 local areas_selector = Area:new_selector()
bsw@598 53 :reset_fields()
bsw@598 54 :add_field("area.id", nil, { "grouped" })
bsw@707 55 :add_field("area.unit_id", nil, { "grouped" })
bsw@598 56 :add_field("area.name", nil, { "grouped" })
bsw@598 57 :add_field("member_weight", nil, { "grouped" })
bsw@598 58 :add_field("direct_member_count", nil, { "grouped" })
bsw@598 59 :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 60 :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 61 :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 62 :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 63 :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 64 :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 65 :add_where{ "area.unit_id = ?", unit.id }
bsw@571 66 :add_where{ "area.active" }
bsw@598 67 :add_order_by("area.name")
bsw@598 68
bsw@598 69 if filter_unit == "my_areas" then
bsw@598 70 areas_selector:join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
bsw@706 71 else
bsw@706 72 areas_selector:join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", member.id })
bsw@598 73 end
bsw@571 74
bsw@571 75 local area_count = areas_selector:count()
bsw@571 76
bsw@619 77 local max_area_count = Area:new_selector()
bsw@619 78 :add_where{ "area.unit_id = ?", unit.id }
bsw@619 79 :add_where{ "area.active" }
bsw@619 80 :count()
bsw@619 81 local more_area_count = max_area_count - area_count
bsw@619 82 local delegated_count = Area:new_selector()
bsw@619 83 :add_where{ "area.unit_id = ?", unit.id }
bsw@619 84 :add_where{ "area.active" }
bsw@619 85 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
bsw@619 86 :add_where{ "membership.member_id ISNULL" }
bsw@619 87 :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
bsw@619 88 :add_where{ "delegation.trustee_id NOTNULL" }
bsw@619 89 :count()
bsw@558 90
bsw@619 91 local more_area_text
bsw@619 92 if area_count == 0 and more_area_count == 1 then
bsw@619 93 more_area_text = _("You are not participating in the only area of the unit")
bsw@619 94 elseif area_count == 0 and more_area_count > 0 then
bsw@619 95 more_area_text = _("You are not participating in any of the #{count} areas in this unit", { count = more_area_count })
bsw@619 96 elseif area_count > 0 and more_area_count == 1 then
bsw@619 97 more_area_text = _("One more area in this unit")
bsw@619 98 elseif area_count > 0 and more_area_count > 0 then
bsw@619 99 more_area_text = _("#{count} more areas in this unit", { count = more_area_count })
bsw@619 100 end
bsw@619 101 local delegated_text
bsw@619 102 if delegated_count == 1 then
bsw@619 103 delegated_text = _("One of them have an area delegation set", { count = delegated_count })
bsw@619 104 elseif delegated_count > 0 then
bsw@619 105 delegated_text = _("#{count} of them have an area delegation set", { count = delegated_count })
bsw@619 106 end
bsw@619 107
bsw@622 108 ui.container{ attr = { class = "area_list" }, content = function()
bsw@622 109 execute.view{ module = "unit", view = "_head", params = { unit = unit, show_content = true } }
bsw@598 110
bsw@598 111 if area_count > 0 then
bsw@598 112 local areas = areas_selector:exec()
bsw@707 113
bsw@713 114 areas:load_delegation_info_once_for_member_id(member.id)
bsw@713 115
bsw@598 116 for i, area in ipairs(areas) do
bsw@571 117 execute.view{
bsw@598 118 module = "area", view = "_list_entry", params = {
bsw@598 119 area = area
bsw@571 120 }
bsw@571 121 }
bsw@571 122 end
bsw@623 123 end
bsw@623 124
bsw@619 125 if area_count == 0 and member:has_voting_right_for_unit_id(unit.id) or
bsw@619 126 more_area_count > 0 then
bsw@619 127
bsw@571 128 end
bsw@558 129 end }
bsw@623 130 ui.container{ attr = { class = "area", style="margin-top: 1ex; margin-left: 10px;" }, content = function()
bsw@623 131 ui.container{ attr = { class = "title" }, content = function()
bsw@623 132 if more_area_text then
bsw@623 133 ui.link{ module = "unit", view = "show", id = unit.id, text = more_area_text }
bsw@623 134 end
bsw@623 135 if delegated_text then
bsw@623 136 slot.put(" · ")
bsw@623 137 ui.tag{ content = delegated_text }
bsw@623 138 end
bsw@623 139 end }
bsw@623 140 end }
bsw@623 141 slot.put("<br />")
bsw@571 142 end
bsw@558 143 end
bsw@558 144
bsw@558 145

Impressum / About Us