liquid_feedback_frontend
diff model/event.lua @ 1252:659e3eda2fad
Minor fixes to new notification system
author | bsw |
---|---|
date | Sun Apr 17 16:02:26 2016 +0200 (2016-04-17) |
parents | 84f6e17c7ceb |
children | 5aecbbb04a42 |
line diff
1.1 --- a/model/event.lua Sun Apr 17 15:04:07 2016 +0200 1.2 +++ b/model/event.lua Sun Apr 17 16:02:26 2016 +0200 1.3 @@ -52,7 +52,6 @@ 1.4 1.5 local members_to_notify = Member:new_selector() 1.6 :join("event_for_notification", nil, { "event_for_notification.recipient_id = member.id AND event_for_notification.id = ?", self.id } ) 1.7 - --:add_where("member.activated NOTNULL AND member.notify_email NOTNULL") 1.8 -- SAFETY FIRST, NEVER send notifications for events more then 3 days in past or future 1.9 :add_where("now() - event_for_notification.occurrence BETWEEN '-3 days'::interval AND '3 days'::interval") 1.10 -- do not notify a member about the events caused by the member 1.11 @@ -61,14 +60,12 @@ 1.12 1.13 io.stderr:write("Sending notifications for event " .. self.id .. " to " .. (#members_to_notify) .. " members\n") 1.14 1.15 - local url 1.16 - 1.17 for i, member in ipairs(members_to_notify) do 1.18 local subject 1.19 local body = "" 1.20 1.21 locale.do_with( 1.22 - { lang = member.lang or config.default_lang or 'en' }, 1.23 + { lang = member.lang or config.default_lang }, 1.24 function() 1.25 1.26 body = body .. _("[event mail] Unit: #{name}", { name = self.issue.area.unit.name }) .. "\n" 1.27 @@ -77,6 +74,8 @@ 1.28 body = body .. _("[event mail] Policy: #{policy}", { policy = self.issue.policy.name }) .. "\n\n" 1.29 body = body .. _("[event mail] Phase: #{phase}", { phase = self.state_name }) .. "\n\n" 1.30 1.31 + local url 1.32 + 1.33 if self.initiative_id then 1.34 url = request.get_absolute_baseurl() .. "initiative/show/" .. self.initiative_id .. ".html" 1.35 else 1.36 @@ -96,7 +95,7 @@ 1.37 :count() 1.38 local initiatives = Initiative:new_selector() 1.39 :add_where{ "initiative.issue_id = ?", self.issue_id } 1.40 - :add_order_by("initiative.supporter_count DESC") 1.41 + :add_order_by("initiative.admitted DESC NULLS LAST, initiative.rank NULLS LAST, initiative.harmonic_weight DESC NULLS LAST, id") 1.42 :limit(3) 1.43 :exec() 1.44 for i, initiative in ipairs(initiatives) do 1.45 @@ -114,7 +113,7 @@ 1.46 subject = config.mail_subject_prefix 1.47 1.48 if self.event == "issue_state_changed" then 1.49 - subject = subject .. _("State of #{issue} changed to #{state} / Leading: #{initiative}", { issue = self.issue.name, state = Issue:get_state_name_for_state(self.state), initiative = leading_initiative.display_name }) 1.50 + subject = subject .. _("State of #{issue} changed to #{state} / #{initiative}", { issue = self.issue.name, state = Issue:get_state_name_for_state(self.state), initiative = leading_initiative.display_name }) 1.51 elseif self.event == "initiative_revoked" then 1.52 subject = subject .. _("Initiative revoked: #{initiative_name}", { initiative_name = self.initiative.display_name }) 1.53 end