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