liquid_feedback_frontend
view app/main/index/_notifications.lua @ 785:d2ecfc4ae757
Changed locale/help/index.index.de.txt
| author | jbe | 
|---|---|
| date | Fri Jun 29 00:20:58 2012 +0200 (2012-06-29) | 
| parents | afd406d96044 | 
| children | 6ba4ebe7b707 | 
 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 local broken_delegations_count = Delegation:selector_for_broken(app.session.member_id):count()
    19 if broken_delegations_count > 0 then
    20   notification_links[#notification_links+1] = {
    21     module = "index", view = "broken_delegations",
    22     text = _("#{count} of your outgoing delegation(s) are broken", { count = broken_delegations_count })
    23   }
    25 end
    27 local selector = Issue:new_selector()
    28   :join("area", nil, "area.id = issue.area_id")
    29   :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id })
    30   :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
    31   :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
    32   :add_where{ "direct_voter.member_id ISNULL" }
    33   :add_where{ "interest.member_id NOTNULL" }
    34   :add_where{ "issue.fully_frozen NOTNULL" }
    35   :add_where{ "issue.closed ISNULL" }
    36   :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" }
    38 local issues_to_vote_count = selector:count()
    39 if issues_to_vote_count > 0 then
    40     notification_links[#notification_links+1] = {
    41     module = "index", view = "index",
    42     params = {
    43       tab = "open", filter = "frozen", filter_interest = "issue", filter_delegation = "direct", filter_voting = "not_voted"
    44     },
    45     text = _("You have not voted #{count} issue(s) you were interested in", { count = issues_to_vote_count })
    46   }
    47 end
    49 local initiator_invites_count = Initiator:selector_for_invites(app.session.member_id):count()
    51 if initiator_invites_count > 0 then
    52   notification_links[#notification_links+1] = {
    53     module = "index", view = "initiator_invites",
    54     text = _("You are invited to #{count} initiative(s)", { count = initiator_invites_count })
    55   }
    56 end
    58 updated_drafts_count = Initiative:selector_for_updated_drafts(app.session.member_id):count()
    60 if updated_drafts_count > 0 then
    61   notification_links[#notification_links+1] = {
    62     module = "index", view = "updated_drafts",
    63     text = _("New drafts for #{count} initiative(s) you are supporting", { count = updated_drafts_count })
    64   }
    65 end
    67 if #notification_links > 0 then
    68   ui.container{ attr = { class = "notifications" }, content = function()
    69     ui.tag{ tag = "ul", attr = { class = "notifications" }, content = function()
    70       for i, notification_link in ipairs(notification_links) do
    71         ui.tag{ tag = "li", content = function()
    72           ui.link(notification_link)
    73         end }
    74       end
    75     end }
    76   end }
    77 end
