liquid_feedback_frontend

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

Impressum / About Us