| rev | 
   line source | 
| 
bsw@1045
 | 
     1 local notification_links = {}
 | 
| 
bsw@1045
 | 
     2 
 | 
| 
bsw@1045
 | 
     3 if app.session.member.notify_email_unconfirmed then
 | 
| 
bsw@1045
 | 
     4   notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
     5     module = "index", view = "email_unconfirmed",
 | 
| 
bsw@1045
 | 
     6     text = _"Confirm your email address"
 | 
| 
bsw@1045
 | 
     7   }
 | 
| 
bsw@1045
 | 
     8 end
 | 
| 
bsw@1045
 | 
     9 
 | 
| 
bsw/jbe@1309
 | 
    10 local agents = Agent:new_selector()
 | 
| 
bsw/jbe@1309
 | 
    11   :add_where{ "controller_id = ?", app.session.member_id }
 | 
| 
bsw/jbe@1309
 | 
    12   :add_where{ "accepted ISNULL" }
 | 
| 
bsw/jbe@1309
 | 
    13   :exec()
 | 
| 
bsw/jbe@1309
 | 
    14 for i, agent in ipairs(agents) do
 | 
| 
bsw/jbe@1309
 | 
    15   local member = Member:by_id(agent.controlled_id)
 | 
| 
bsw/jbe@1309
 | 
    16   notification_links[#notification_links+1] = {
 | 
| 
bsw/jbe@1309
 | 
    17     module = "agent", view = "show", params = { controlled_id = agent.controlled_id },
 | 
| 
bsw/jbe@1309
 | 
    18     text = _("Account access invitation from '#{member_name}'", { member_name = member.name })
 | 
| 
bsw/jbe@1309
 | 
    19   }
 | 
| 
bsw/jbe@1309
 | 
    20 end
 | 
| 
bsw/jbe@1309
 | 
    21 
 | 
| 
bsw@1045
 | 
    22 if config.check_delegations_interval_soft then
 | 
| 
bsw@1045
 | 
    23   local member = Member:new_selector()
 | 
| 
bsw@1045
 | 
    24     :add_where({ "id = ?", app.session.member_id })
 | 
| 
bsw@1045
 | 
    25     :add_field({ "now() > COALESCE(last_delegation_check, activated) + ?::interval", config.check_delegations_interval_soft }, "needs_delegation_check_soft")
 | 
| 
bsw@1045
 | 
    26     :single_object_mode()
 | 
| 
bsw@1045
 | 
    27     :exec()
 | 
| 
bsw@1045
 | 
    28     
 | 
| 
bsw@1045
 | 
    29 
 | 
| 
bsw@1045
 | 
    30   if member.needs_delegation_check_soft then
 | 
| 
bsw@1045
 | 
    31 
 | 
| 
bsw@1045
 | 
    32     local delegations = Delegation:delegations_to_check_for_member_id(member.id)
 | 
| 
bsw@1045
 | 
    33     
 | 
| 
bsw@1045
 | 
    34     if #delegations > 0 then
 | 
| 
bsw@1045
 | 
    35       notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
    36         module = "index", view = "check_delegations", 
 | 
| 
bsw@1045
 | 
    37         text = _"Check your outgoing delegations"
 | 
| 
bsw@1045
 | 
    38       }
 | 
| 
bsw@1045
 | 
    39     end
 | 
| 
bsw@1045
 | 
    40     
 | 
| 
bsw@1045
 | 
    41   end
 | 
| 
bsw@1045
 | 
    42 end
 | 
| 
bsw@1045
 | 
    43 
 | 
| 
bsw@1045
 | 
    44 local broken_delegations = Delegation:selector_for_broken(app.session.member_id):exec()
 | 
| 
bsw@1045
 | 
    45 
 | 
| 
bsw@1045
 | 
    46 for i, delegation in ipairs(broken_delegations) do
 | 
| 
bsw@1045
 | 
    47   local scope
 | 
| 
bsw@1045
 | 
    48   local context
 | 
| 
bsw@1195
 | 
    49   local id
 | 
| 
bsw@1045
 | 
    50   if delegation.scope == "unit" then
 | 
| 
bsw@1045
 | 
    51     scope = _"unit"
 | 
| 
bsw@1045
 | 
    52     id = delegation.unit_id
 | 
| 
bsw@1045
 | 
    53     context = delegation.unit.name
 | 
| 
bsw@1045
 | 
    54   elseif delegation.scope == "area" then
 | 
| 
bsw@1045
 | 
    55     scope = _"area"
 | 
| 
bsw@1045
 | 
    56     id = delegation.area_id
 | 
| 
bsw@1045
 | 
    57     context = delegation.area.name
 | 
| 
bsw@1045
 | 
    58   elseif delegation.scope == "issue" then
 | 
| 
bsw@1045
 | 
    59     scope = _"issue"
 | 
| 
bsw@1045
 | 
    60     id = delegation.issue_id
 | 
| 
bsw@1045
 | 
    61     context = delegation.issue.name
 | 
| 
bsw@1045
 | 
    62   end
 | 
| 
bsw@1045
 | 
    63    
 | 
| 
bsw@1045
 | 
    64   notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
    65     module = delegation.scope, view = "show", id = id,
 | 
| 
bsw@1045
 | 
    66     text = _("Check your #{scope} delegation to '#{trustee_name}' for '#{context}'", {
 | 
| 
bsw@1045
 | 
    67       trustee_name = delegation.trustee.name,
 | 
| 
bsw@1045
 | 
    68       scope = scope,
 | 
| 
bsw@1045
 | 
    69       context = context
 | 
| 
bsw@1045
 | 
    70     })
 | 
| 
bsw@1045
 | 
    71   }
 | 
| 
bsw@1045
 | 
    72 end
 | 
| 
bsw@1045
 | 
    73 
 | 
| 
bsw@1045
 | 
    74 local selector = Issue:new_selector()
 | 
| 
bsw@1045
 | 
    75   :join("area", nil, "area.id = issue.area_id")
 | 
| 
bsw@1045
 | 
    76   :join("privilege", nil, { "privilege.unit_id = area.unit_id AND privilege.member_id = ? AND privilege.voting_right", app.session.member_id })
 | 
| 
bsw@1045
 | 
    77   :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
 | 
| 
bsw@1045
 | 
    78   :left_join("non_voter", nil, { "non_voter.issue_id = issue.id AND non_voter.member_id = ?", app.session.member.id })
 | 
| 
bsw@1045
 | 
    79   :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
 | 
| 
bsw@1045
 | 
    80   :add_where{ "direct_voter.member_id ISNULL" }
 | 
| 
bsw@1045
 | 
    81   :add_where{ "non_voter.member_id ISNULL" }
 | 
| 
bsw@1045
 | 
    82   :add_where{ "interest.member_id NOTNULL" }
 | 
| 
bsw@1045
 | 
    83   :add_where{ "issue.fully_frozen NOTNULL" }
 | 
| 
bsw@1045
 | 
    84   :add_where{ "issue.closed ISNULL" }
 | 
| 
bsw@1045
 | 
    85   :add_order_by{ "issue.fully_frozen + issue.voting_time ASC" }
 | 
| 
bsw@1045
 | 
    86   
 | 
| 
bsw@1045
 | 
    87 local issues_to_vote = selector:exec()
 | 
| 
bsw@1045
 | 
    88 
 | 
| 
bsw@1045
 | 
    89 for i, issue in ipairs(issues_to_vote) do
 | 
| 
bsw@1045
 | 
    90   notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
    91     module = "issue", view = "show", id = issue.id,
 | 
| 
bsw@1045
 | 
    92     text = _("#{issue} is in voting", { issue = issue.name })
 | 
| 
bsw@1045
 | 
    93   }
 | 
| 
bsw@1045
 | 
    94 end
 | 
| 
bsw@1045
 | 
    95 
 | 
| 
bsw@1045
 | 
    96 local initiator_invites = Initiator:selector_for_invites(app.session.member_id):exec()
 | 
| 
bsw@1045
 | 
    97   
 | 
| 
bsw@1045
 | 
    98 for i, initiative in ipairs(initiator_invites) do
 | 
| 
bsw@1045
 | 
    99   notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
   100     module = "initiative", view = "show", id = initiative.id,
 | 
| 
bsw@1045
 | 
   101     text = _("You are invited to become initiator of '#{initiative_name}'", { initiative_name = initiative.display_name })
 | 
| 
bsw@1045
 | 
   102   }
 | 
| 
bsw@1045
 | 
   103 end
 | 
| 
bsw@1045
 | 
   104 
 | 
| 
bsw@1145
 | 
   105 local updated_drafts = Initiative:selector_for_updated_drafts(app.session.member_id):exec()
 | 
| 
bsw@1045
 | 
   106 
 | 
| 
bsw@1045
 | 
   107 for i, initiative in ipairs(updated_drafts) do
 | 
| 
bsw@1045
 | 
   108   notification_links[#notification_links+1] = {
 | 
| 
bsw@1045
 | 
   109     module = "initiative", view = "show", id = initiative.id,
 | 
| 
bsw@1045
 | 
   110     text = _("New draft for initiative '#{initiative_name}'", { initiative_name = initiative.display_name })
 | 
| 
bsw@1045
 | 
   111   }
 | 
| 
bsw@1045
 | 
   112 end
 | 
| 
bsw@1045
 | 
   113 
 | 
| 
bsw@1045
 | 
   114 if #notification_links > 0 then
 | 
| 
bsw/jbe@1309
 | 
   115   ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   116     ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   117       ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Notifications" }
 | 
| 
bsw/jbe@1309
 | 
   118     end }
 | 
| 
bsw/jbe@1309
 | 
   119     ui.container{ attr = { class = "mdl-card__content what-can-i-do-here" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   120       ui.tag{ tag = "ul", attr = { class = "ul" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
   121         for i, notification_link in ipairs(notification_links) do
 | 
| 
bsw/jbe@1309
 | 
   122           ui.tag{ tag = "li", content = function()
 | 
| 
bsw/jbe@1309
 | 
   123             ui.link(notification_link)
 | 
| 
bsw/jbe@1309
 | 
   124           end }
 | 
| 
bsw@1045
 | 
   125         end
 | 
| 
bsw/jbe@1309
 | 
   126       end }
 | 
| 
bsw@1045
 | 
   127     end }
 | 
| 
bsw/jbe@1309
 | 
   128   end }
 | 
| 
bsw@1045
 | 
   129 end
 |