liquid_feedback_frontend
changeset 1250:84f6e17c7ceb
Completed support for new notification system
author | bsw |
---|---|
date | Sun Apr 17 15:03:44 2016 +0200 (2016-04-17) |
parents | 62f7e7d4f9ec |
children | e3f7555d4de7 |
files | app/main/_filter_view/30_navigation.lua app/main/_prefork/10_init.lua app/main/area/_sidebar_whatcanido.lua app/main/member/_action/update_notify_level.lua app/main/member/settings_notification.lua config/example.lua model/event.lua model/initiative_for_notification.lua model/notification_event_sent.lua model/notification_sent.lua |
line diff
1.1 --- a/app/main/_filter_view/30_navigation.lua Tue Apr 05 20:41:05 2016 +0200 1.2 +++ b/app/main/_filter_view/30_navigation.lua Sun Apr 17 15:03:44 2016 +0200 1.3 @@ -1,4 +1,5 @@ 1.4 slot.select ( 'instance_name', function () 1.5 + slot.put(" @ ") 1.6 slot.put ( encode.html ( config.instance_name ) ) 1.7 end) 1.8
2.1 --- a/app/main/_prefork/10_init.lua Tue Apr 05 20:41:05 2016 +0200 2.2 +++ b/app/main/_prefork/10_init.lua Sun Apr 17 15:03:44 2016 +0200 2.3 @@ -33,6 +33,10 @@ 2.4 config.mail_subject_prefix = "[LiquidFeedback] " 2.5 end 2.6 2.7 +if config.notification_digest_template == nil then 2.8 + config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n" 2.9 +end 2.10 + 2.11 if config.member_image_content_type == nil then 2.12 config.member_image_content_type = "image/jpeg" 2.13 end 2.14 @@ -136,15 +140,17 @@ 2.15 delay = 5, 2.16 handler = function() 2.17 while true do 2.18 - local did_work = false 2.19 - local tmp 2.20 - tmp = Newsletter:send_next_newsletter() 2.21 - if tmp then did_work = true end 2.22 - tmp = Event:send_next_notification() 2.23 - if tmp then did_work = true end 2.24 - tmp = InitiativeForNotification:notify_next_member() 2.25 - if tmp then did_work = true end 2.26 - if not did_work then 2.27 + if not Newsletter:send_next_newsletter() then 2.28 + break 2.29 + end 2.30 + end 2.31 + while true do 2.32 + if not Event:send_next_notification() then 2.33 + break 2.34 + end 2.35 + end 2.36 + while true do 2.37 + if not InitiativeForNotification:notify_next_member() then 2.38 break 2.39 end 2.40 end
3.1 --- a/app/main/area/_sidebar_whatcanido.lua Tue Apr 05 20:41:05 2016 +0200 3.2 +++ b/app/main/area/_sidebar_whatcanido.lua Sun Apr 17 15:03:44 2016 +0200 3.3 @@ -23,6 +23,106 @@ 3.4 end 3.5 3.6 if member and app.session.member:has_voting_right_for_unit_id(area.unit_id) then 3.7 + 3.8 + if not app.session.member.disable_notifications then 3.9 + 3.10 + local ignored_area = IgnoredArea:by_pk(app.session.member_id, area.id) 3.11 + 3.12 + if not ignored_area then 3.13 + ui.sidebarSection ( function () 3.14 + 3.15 + ui.heading { 3.16 + level = 3, 3.17 + content = _"You are receiving updates by email for this subject area" 3.18 + } 3.19 + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () 3.20 + ui.tag { tag = "li", content = function () 3.21 + ui.tag { content = function () 3.22 + ui.link { 3.23 + module = "area", action = "update_ignore", 3.24 + params = { area_id = area.id }, 3.25 + routing = { default = { 3.26 + mode = "redirect", module = "area", view = "show", id = area.id 3.27 + } }, 3.28 + text = _"unsubscribe from update emails about this area" 3.29 + } 3.30 + end } 3.31 + end } 3.32 + end } 3.33 + end ) 3.34 + end 3.35 + 3.36 + if ignored_area then 3.37 + ui.sidebarSection ( function () 3.38 + 3.39 + ui.heading { 3.40 + level = 3, 3.41 + content = _"I want to stay informed" 3.42 + } 3.43 + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () 3.44 + ui.tag { tag = "li", content = function () 3.45 + ui.tag { content = function () 3.46 + ui.link { 3.47 + module = "area", action = "update_ignore", 3.48 + params = { area_id = area.id, delete = true }, 3.49 + routing = { default = { 3.50 + mode = "redirect", module = "area", view = "show", id = area.id 3.51 + } }, 3.52 + text = _"subscribe for update emails about this area" 3.53 + } 3.54 + end } 3.55 + end } 3.56 + end } 3.57 + end ) 3.58 + end 3.59 + 3.60 + else 3.61 + ui.sidebarSection ( function () 3.62 + 3.63 + ui.heading { 3.64 + level = 3, 3.65 + content = _"I want to stay informed about this subject area" 3.66 + } 3.67 + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () 3.68 + ui.tag { tag = "li", content = function () 3.69 + ui.tag { content = function () 3.70 + ui.tag{ content = _"Edit your global " } 3.71 + ui.link { 3.72 + module = "member", view = "settings_notification", 3.73 + params = { return_to = "area", return_to_area_id = area.id }, 3.74 + text = _"notification settings" 3.75 + } 3.76 + ui.tag{ content = _" to receive updates by email" } 3.77 + end } 3.78 + end } 3.79 + end } 3.80 + end ) 3.81 + end 3.82 + 3.83 + if area.delegation_info.own_participation then 3.84 + ui.sidebarSection ( function () 3.85 + ui.image{ attr = { class = "right" }, static = "icons/48/star.png" } 3.86 + ui.heading { 3.87 + level = 3, 3.88 + content = _"You are subscribed for this subject area" 3.89 + } 3.90 + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () 3.91 + ui.tag { tag = "li", content = function () 3.92 + ui.tag { content = function () 3.93 + ui.link { 3.94 + module = "membership", action = "update", 3.95 + routing = { default = { 3.96 + mode = "redirect", module = "area", view = "show", id = area.id 3.97 + } }, 3.98 + params = { area_id = area.id, delete = true }, 3.99 + text = _"unsubscribe" 3.100 + } 3.101 + end } 3.102 + end } 3.103 + end } 3.104 + end ) 3.105 + end 3.106 + 3.107 if not area.delegation_info.own_participation then 3.108 ui.sidebarSection ( function () 3.109 3.110 @@ -47,29 +147,6 @@ 3.111 end ) 3.112 end 3.113 3.114 - if area.delegation_info.own_participation then 3.115 - ui.sidebarSection ( function () 3.116 - ui.image{ attr = { class = "right" }, static = "icons/48/star.png" } 3.117 - ui.heading { 3.118 - level = 3, 3.119 - content = _"You are subscribed for this subject area" 3.120 - } 3.121 - ui.tag { tag = "ul", attr = { class = "ul" }, content = function () 3.122 - ui.tag { tag = "li", content = function () 3.123 - ui.tag { content = function () 3.124 - ui.link { 3.125 - module = "membership", action = "update", 3.126 - routing = { default = { 3.127 - mode = "redirect", module = "area", view = "show", id = area.id 3.128 - } }, 3.129 - params = { area_id = area.id, delete = true }, 3.130 - text = _"unsubscribe" 3.131 - } 3.132 - end } 3.133 - end } 3.134 - end } 3.135 - end ) 3.136 - end 3.137 3.138 3.139 ui.sidebarSection ( function ()
4.1 --- a/app/main/member/_action/update_notify_level.lua Tue Apr 05 20:41:05 2016 +0200 4.2 +++ b/app/main/member/_action/update_notify_level.lua Sun Apr 17 15:03:44 2016 +0200 4.3 @@ -1,2 +1,3 @@ 4.4 app.session.member.disable_notifications = param.get("disable_notifications") == "true" and true or false 4.5 +IgnoredArea:destroy_by_member_id(app.session.member_id) 4.6 app.session.member:save()
5.1 --- a/app/main/member/settings_notification.lua Tue Apr 05 20:41:05 2016 +0200 5.2 +++ b/app/main/member/settings_notification.lua Sun Apr 17 15:03:44 2016 +0200 5.3 @@ -1,4 +1,5 @@ 5.4 local return_to = param.get("return_to") 5.5 +local return_to_area_id param.get("return_to_area_id", atom.integer) 5.6 5.7 ui.titleMember(_"notification settings") 5.8 5.9 @@ -15,9 +16,9 @@ 5.10 routing = { 5.11 ok = { 5.12 mode = "redirect", 5.13 - module = return_to == "home" and "index" or "member", 5.14 - view = return_to == "home" and "index" or "show", 5.15 - id = return_to ~= "home" and app.session.member_id or nil 5.16 + module = return_to == "area" and "area" or return_to == "home" and "index" or "member", 5.17 + view = return_to == "area" and "show" or return_to == "home" and "index" or "show", 5.18 + id = return_to == "area" and return_to_area_id or return_to ~= "home" and app.session.member_id or nil 5.19 } 5.20 }, 5.21 content = function() 5.22 @@ -25,7 +26,7 @@ 5.23 ui.section( function() 5.24 5.25 ui.sectionHead( function() 5.26 - ui.heading { level = 1, content = _"For which issue phases do you like to receive notification emails?" } 5.27 + ui.heading { level = 1, content = _"Do you like to receive updates by email?" } 5.28 end ) 5.29 5.30
6.1 --- a/config/example.lua Tue Apr 05 20:41:05 2016 +0200 6.2 +++ b/config/example.lua Sun Apr 17 15:03:44 2016 +0200 6.3 @@ -147,6 +147,19 @@ 6.4 -- config.mail_reply_to = { name = "Support", address = "support@example.com" } 6.5 6.6 6.7 +-- Template for digest emails 6.8 +-- #{name} will be replaced by member screen name 6.9 +-- #{digest} will be replaced with the digest content 6.10 +-- ------------------------------------------------------------------------ 6.11 +-- config.notification_digest_template = [[ 6.12 +-- Hello #{name}, 6.13 +-- 6.14 +-- this is your personal digest. 6.15 +-- 6.16 +-- #{digest} 6.17 +-- ]] 6.18 + 6.19 + 6.20 -- Configuration of password hashing algorithm (defaults to "crypt_sha512") 6.21 -- ------------------------------------------------------------------------ 6.22 -- config.password_hash_algorithm = "crypt_sha512"
7.1 --- a/model/event.lua Tue Apr 05 20:41:05 2016 +0200 7.2 +++ b/model/event.lua Sun Apr 17 15:03:44 2016 +0200 7.3 @@ -137,14 +137,14 @@ 7.4 7.5 function Event:send_next_notification() 7.6 7.7 - local notification_sent = NotificationSent:new_selector() 7.8 + local notification_event_sent = NotificationEventSent:new_selector() 7.9 :optional_object_mode() 7.10 :for_update() 7.11 :exec() 7.12 7.13 local last_event_id = 0 7.14 - if notification_sent then 7.15 - last_event_id = notification_sent.event_id 7.16 + if notification_event_sent then 7.17 + last_event_id = notification_event_sent.event_id 7.18 end 7.19 7.20 local event = Event:new_selector() 7.21 @@ -156,9 +156,9 @@ 7.22 7.23 if event then 7.24 if last_event_id == 0 then 7.25 - db:query{ "INSERT INTO notification_sent (event_id) VALUES (?)", event.id } 7.26 + db:query{ "INSERT INTO notification_event_sent (event_id) VALUES (?)", event.id } 7.27 else 7.28 - db:query{ "UPDATE notification_sent SET event_id = ?", event.id } 7.29 + db:query{ "UPDATE notification_event_sent SET event_id = ?", event.id } 7.30 end 7.31 7.32 event:send_notification()
8.1 --- a/model/initiative_for_notification.lua Tue Apr 05 20:41:05 2016 +0200 8.2 +++ b/model/initiative_for_notification.lua Sun Apr 17 15:03:44 2016 +0200 8.3 @@ -132,7 +132,7 @@ 8.4 if suggestion_count == 1 then 8.5 info[#info+1] = _"new suggestion for " .. initiatives_for_notification[1].initiative.display_name 8.6 else 8.7 - info[#info+1] = _("#{suggestion_count} suggestions added", { suggestion_count = suggestion_count }) 8.8 + info[#info+1] = _("#{count} suggestions added", { count = suggestion_count }) 8.9 end 8.10 end 8.11 8.12 @@ -175,4 +175,4 @@ 8.13 return true 8.14 end 8.15 8.16 -ScheduledNotificationToSend:get_next() 8.17 \ No newline at end of file 8.18 +ScheduledNotificationToSend:get_next()