liquid_feedback_frontend

view app/main/index/_notifications.lua @ 990:77873f08d94f

Completed support for check delegations, removed debug code
author bsw
date Sat Apr 20 19:26:58 2013 +0200 (2013-04-20)
parents 81bde33c2256
children
line source
1 local notification_links = {}
3 if app.session.member.notify_email_unconfirmed then
4 notification_links[#notification_links+1] = {
5 module = "index", view = "email_unconfirmed",
6 text = _"Please confirm your email address"
7 }
8 end
10 if app.session.member.notify_level == nil then
11 notification_links[#notification_links+1] = {
12 module = "member", view = "settings_notification",
13 text = _"Please select your preferred notification level"
14 }
15 end
17 if config.check_delegations_interval_soft then
18 local member = Member:new_selector()
19 :add_where({ "id = ?", app.session.member_id })
20 :add_field({ "now() > COALESCE(last_delegation_check, activated) + ?::interval", config.check_delegations_interval_soft }, "needs_delegation_check_soft")
21 :single_object_mode()
22 :exec()
25 if member.needs_delegation_check_soft then
27 local delegations = Delegation:delegations_to_check_for_member_id(member.id)
29 if #delegations > 0 then
30 notification_links[#notification_links+1] = {
31 module = "index", view = "check_delegations",
32 text = _"Check your delegations!"
33 }
34 end
36 end
37 end
39 local broken_delegations_count = Delegation:selector_for_broken(app.session.member_id):count()
41 if broken_delegations_count > 0 then
42 notification_links[#notification_links+1] = {
43 module = "index", view = "broken_delegations",
44 text = _("#{count} of your outgoing delegation(s) are broken", { count = broken_delegations_count })
45 }
47 end
49 local selector = Issue:new_selector()
50 :join("area", nil, "area.id = issue.area_id")
51 :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id })
52 :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
53 :left_join("non_voter", nil, { "non_voter.issue_id = issue.id AND non_voter.member_id = ?", app.session.member.id })
54 :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
55 :add_where{ "direct_voter.member_id ISNULL" }
56 :add_where{ "non_voter.member_id ISNULL" }
57 :add_where{ "interest.member_id NOTNULL" }
58 :add_where{ "issue.fully_frozen NOTNULL" }
59 :add_where{ "issue.closed ISNULL" }
60 :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" }
62 local issues_to_vote_count = selector:count()
63 if issues_to_vote_count > 0 then
64 notification_links[#notification_links+1] = {
65 module = "index", view = "index",
66 params = {
67 tab = "open", filter = "frozen", filter_interest = "issue", filter_delegation = "direct", filter_voting = "not_voted"
68 },
69 text = _("You have not voted #{count} issue(s) you were interested in", { count = issues_to_vote_count })
70 }
71 end
73 local initiator_invites_count = Initiator:selector_for_invites(app.session.member_id):count()
75 if initiator_invites_count > 0 then
76 notification_links[#notification_links+1] = {
77 module = "index", view = "initiator_invites",
78 text = _("You are invited to #{count} initiative(s)", { count = initiator_invites_count })
79 }
80 end
82 updated_drafts_count = Initiative:selector_for_updated_drafts(app.session.member_id):count()
84 if updated_drafts_count > 0 then
85 notification_links[#notification_links+1] = {
86 module = "index", view = "updated_drafts",
87 text = _("New drafts for #{count} initiative(s) you are supporting", { count = updated_drafts_count })
88 }
89 end
91 if #notification_links > 0 then
92 ui.container{ attr = { class = "notifications" }, content = function()
93 ui.tag{ tag = "ul", attr = { class = "notifications" }, content = function()
94 for i, notification_link in ipairs(notification_links) do
95 ui.tag{ tag = "li", content = function()
96 ui.link(notification_link)
97 end }
98 end
99 end }
100 end }
101 end

Impressum / About Us