liquid_feedback_frontend

view app/main/member/show_tab.lua @ 75:733f65c0c0a0

Bugfixes, feature enhancements, code-cleanup, and major work on API

Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
author bsw
date Thu Jul 08 18:44:02 2010 +0200 (2010-07-08)
parents c553898f64cb
children 6a12fb7e4963
line source
1 local show_as_homepage = param.get("show_as_homepage", atom.boolean)
3 local member
5 if request.get_json_request_slots() then
6 member = Member:by_id(param.get("member_id"))
7 else
8 member = param.get("member", "table")
9 end
11 local tabs = {
12 module = "member",
13 view = "show_tab",
14 static_params = {
15 member_id = member.id,
16 show_as_homepage = show_as_homepage
17 }
18 }
20 if show_as_homepage and app.session.member_id == member.id then
22 if app.session.member.notify_email_unconfirmed then
23 tabs[#tabs+1] = {
24 class = "yellow",
25 name = "email_unconfirmed",
26 label = _"Email unconfirmed",
27 icon = { static = "icons/16/bell.png" },
28 module = "member",
29 view = "_email_unconfirmed",
30 params = {}
31 }
32 end
34 if config.motd_intern then
35 tabs[#tabs+1] = {
36 class = "yellow",
37 name = "motd",
38 label = _"Message of the day",
39 icon = { static = "icons/16/bell.png" },
40 module = "index",
41 view = "_motd",
42 params = {}
43 }
44 end
46 local selector = Area:new_selector()
47 :reset_fields()
48 :add_field("area.id", nil, { "grouped" })
49 :add_field("area.name", nil, { "grouped" })
50 :add_field("membership.member_id NOTNULL", "is_member", { "grouped" })
51 :add_field("count(issue.id)", "issues_to_vote_count")
52 :add_field("count(interest.member_id)", "interested_issues_to_vote_count")
53 :add_field("count(interest.member_id NOTNULL OR interest.member_id NOTNULL)", "issues_to_vote_count_sum")
54 :join("issue", nil, "issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL")
55 :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
56 :add_where{ "direct_voter.member_id ISNULL" }
57 :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
58 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ? ", app.session.member.id })
60 local not_voted_areas = {}
61 local issues_to_vote_count = 0
62 for i, area in ipairs(selector:exec()) do
63 if area.is_member or area.interested_issues_to_vote_count > 0 then
64 not_voted_areas[#not_voted_areas+1] = area
65 end
66 if area.is_member then
67 issues_to_vote_count = issues_to_vote_count + area.issues_to_vote_count_sum
68 end
69 end
71 if issues_to_vote_count > 0 then
72 tabs[#tabs+1] = {
73 class = "yellow",
74 name = "not_voted_issues",
75 label = _"Not voted issues" .. " (" .. tostring(issues_to_vote_count) .. ")",
76 icon = { static = "icons/16/email_open.png" },
77 module = "index",
78 view = "_not_voted_issues",
79 params = {
80 areas = not_voted_areas
81 }
82 }
83 end
85 local initiator_invites_selector = Initiative:new_selector()
86 :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id")
87 :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", app.session.member.id })
88 :add_where("_issue_state.closed ISNULL AND _issue_state.half_frozen ISNULL")
90 if initiator_invites_selector:count() > 0 then
91 tabs[#tabs+1] = {
92 class = "yellow",
93 name = "initiator_invites",
94 label = _"Initiator invites" .. " (" .. tostring(initiator_invites_selector:count()) .. ")",
95 icon = { static = "icons/16/user_add.png" },
96 module = "index",
97 view = "_initiator_invites",
98 params = {
99 initiatives_selector = initiator_invites_selector
100 }
101 }
102 end
104 local updated_drafts_selector = Initiative:new_selector()
105 :join("issue", "_issue_state", "_issue_state.id = initiative.issue_id AND _issue_state.closed ISNULL AND _issue_state.fully_frozen ISNULL")
106 :join("current_draft", "_current_draft", "_current_draft.initiative_id = initiative.id")
107 :join("supporter", "supporter", { "supporter.member_id = ? AND supporter.initiative_id = initiative.id AND supporter.draft_id < _current_draft.id", app.session.member_id })
108 :add_where("initiative.revoked ISNULL")
110 if updated_drafts_selector:count() > 0 then
111 tabs[#tabs+1] = {
112 class = "yellow",
113 name = "updated_drafts",
114 label = _"Updated drafts" .. " (" .. tostring(updated_drafts_selector:count()) .. ")",
115 icon = { static = "icons/16/script.png" },
116 module = "index",
117 view = "_updated_drafts",
118 params = {
119 initiatives_selector = updated_drafts_selector
120 }
121 }
122 end
123 end
125 tabs[#tabs+1] = {
126 name = "profile",
127 label = _"Profile",
128 icon = { static = "icons/16/application_form.png" },
129 module = "member",
130 view = "_profile",
131 params = { member = member },
132 }
134 local areas_selector = member:get_reference_selector("areas")
135 tabs[#tabs+1] = {
136 name = "areas",
137 label = _"Areas" .. " (" .. tostring(areas_selector:count()) .. ")",
138 icon = { static = "icons/16/package.png" },
139 module = "area",
140 view = "_list",
141 params = { areas_selector = areas_selector },
142 }
144 local issues_selector = member:get_reference_selector("issues")
145 tabs[#tabs+1] = {
146 name = "issues",
147 label = _"Issues" .. " (" .. tostring(issues_selector:count()) .. ")",
148 icon = { static = "icons/16/folder.png" },
149 module = "issue",
150 view = "_list",
151 params = { issues_selector = issues_selector },
152 }
154 local supported_initiatives_selector = member:get_reference_selector("supported_initiatives")
155 tabs[#tabs+1] = {
156 name = "supported_initiatives",
157 label = _"Supported initiatives" .. " (" .. tostring(supported_initiatives_selector:count()) .. ")",
158 icon = { static = "icons/16/thumb_up_green.png" },
159 module = "initiative",
160 view = "_list",
161 params = { initiatives_selector = supported_initiatives_selector },
162 }
164 local initiated_initiatives_selector = member:get_reference_selector("initiated_initiatives"):add_where("initiator.accepted = true")
165 tabs[#tabs+1] = {
166 name = "initiatied_initiatives",
167 label = _"Initiated initiatives" .. " (" .. tostring(initiated_initiatives_selector:count()) .. ")",
168 icon = { static = "icons/16/user_edit.png" },
169 module = "initiative",
170 view = "_list",
171 params = { initiatives_selector = initiated_initiatives_selector },
172 }
174 local incoming_delegations_selector = member:get_reference_selector("incoming_delegations")
175 :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id")
176 :add_where("_member_showtab_issue.closed ISNULL")
177 tabs[#tabs+1] = {
178 name = "incoming_delegations",
179 label = _"Incoming delegations" .. " (" .. tostring(incoming_delegations_selector:count()) .. ")",
180 icon = { static = "icons/16/table_go.png" },
181 module = "delegation",
182 view = "_list",
183 params = { delegations_selector = incoming_delegations_selector, incoming = true },
184 }
186 local outgoing_delegations_selector = member:get_reference_selector("outgoing_delegations")
187 :left_join("issue", "_member_showtab_issue", "_member_showtab_issue.id = delegation.issue_id")
188 :add_where("_member_showtab_issue.closed ISNULL")
189 tabs[#tabs+1] = {
190 name = "outgoing_delegations",
191 label = _"Outgoing delegations" .. " (" .. tostring(outgoing_delegations_selector:count()) .. ")",
192 icon = { static = "icons/16/table_go.png" },
193 module = "delegation",
194 view = "_list",
195 params = { delegations_selector = outgoing_delegations_selector, outgoing = true },
196 }
198 local contacts_selector = member:get_reference_selector("saved_members"):add_where("public")
199 tabs[#tabs+1] = {
200 name = "contacts",
201 label = _"Contacts" .. " (" .. tostring(contacts_selector:count()) .. ")",
202 icon = { static = "icons/16/book_edit.png" },
203 module = "member",
204 view = "_list",
205 params = { members_selector = contacts_selector },
206 }
208 ui.tabs(tabs)

Impressum / About Us