# HG changeset patch # User bsw # Date 1460898224 -7200 # Node ID 84f6e17c7ceb281aa6f258644c7d470e7ae65627 # Parent 62f7e7d4f9ec7243f29410b8f9e78998d207d43f Completed support for new notification system diff -r 62f7e7d4f9ec -r 84f6e17c7ceb app/main/_filter_view/30_navigation.lua --- a/app/main/_filter_view/30_navigation.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/app/main/_filter_view/30_navigation.lua Sun Apr 17 15:03:44 2016 +0200 @@ -1,4 +1,5 @@ slot.select ( 'instance_name', function () + slot.put(" @ ") slot.put ( encode.html ( config.instance_name ) ) end) diff -r 62f7e7d4f9ec -r 84f6e17c7ceb app/main/_prefork/10_init.lua --- a/app/main/_prefork/10_init.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/app/main/_prefork/10_init.lua Sun Apr 17 15:03:44 2016 +0200 @@ -33,6 +33,10 @@ config.mail_subject_prefix = "[LiquidFeedback] " end +if config.notification_digest_template == nil then + config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n" +end + if config.member_image_content_type == nil then config.member_image_content_type = "image/jpeg" end @@ -136,15 +140,17 @@ delay = 5, handler = function() while true do - local did_work = false - local tmp - tmp = Newsletter:send_next_newsletter() - if tmp then did_work = true end - tmp = Event:send_next_notification() - if tmp then did_work = true end - tmp = InitiativeForNotification:notify_next_member() - if tmp then did_work = true end - if not did_work then + if not Newsletter:send_next_newsletter() then + break + end + end + while true do + if not Event:send_next_notification() then + break + end + end + while true do + if not InitiativeForNotification:notify_next_member() then break end end diff -r 62f7e7d4f9ec -r 84f6e17c7ceb app/main/area/_sidebar_whatcanido.lua --- a/app/main/area/_sidebar_whatcanido.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/app/main/area/_sidebar_whatcanido.lua Sun Apr 17 15:03:44 2016 +0200 @@ -23,6 +23,106 @@ end if member and app.session.member:has_voting_right_for_unit_id(area.unit_id) then + + if not app.session.member.disable_notifications then + + local ignored_area = IgnoredArea:by_pk(app.session.member_id, area.id) + + if not ignored_area then + ui.sidebarSection ( function () + + ui.heading { + level = 3, + content = _"You are receiving updates by email for this subject area" + } + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () + ui.tag { tag = "li", content = function () + ui.tag { content = function () + ui.link { + module = "area", action = "update_ignore", + params = { area_id = area.id }, + routing = { default = { + mode = "redirect", module = "area", view = "show", id = area.id + } }, + text = _"unsubscribe from update emails about this area" + } + end } + end } + end } + end ) + end + + if ignored_area then + ui.sidebarSection ( function () + + ui.heading { + level = 3, + content = _"I want to stay informed" + } + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () + ui.tag { tag = "li", content = function () + ui.tag { content = function () + ui.link { + module = "area", action = "update_ignore", + params = { area_id = area.id, delete = true }, + routing = { default = { + mode = "redirect", module = "area", view = "show", id = area.id + } }, + text = _"subscribe for update emails about this area" + } + end } + end } + end } + end ) + end + + else + ui.sidebarSection ( function () + + ui.heading { + level = 3, + content = _"I want to stay informed about this subject area" + } + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () + ui.tag { tag = "li", content = function () + ui.tag { content = function () + ui.tag{ content = _"Edit your global " } + ui.link { + module = "member", view = "settings_notification", + params = { return_to = "area", return_to_area_id = area.id }, + text = _"notification settings" + } + ui.tag{ content = _" to receive updates by email" } + end } + end } + end } + end ) + end + + if area.delegation_info.own_participation then + ui.sidebarSection ( function () + ui.image{ attr = { class = "right" }, static = "icons/48/star.png" } + ui.heading { + level = 3, + content = _"You are subscribed for this subject area" + } + ui.tag { tag = "ul", attr = { class = "ul" }, content = function () + ui.tag { tag = "li", content = function () + ui.tag { content = function () + ui.link { + module = "membership", action = "update", + routing = { default = { + mode = "redirect", module = "area", view = "show", id = area.id + } }, + params = { area_id = area.id, delete = true }, + text = _"unsubscribe" + } + end } + end } + end } + end ) + end + if not area.delegation_info.own_participation then ui.sidebarSection ( function () @@ -47,29 +147,6 @@ end ) end - if area.delegation_info.own_participation then - ui.sidebarSection ( function () - ui.image{ attr = { class = "right" }, static = "icons/48/star.png" } - ui.heading { - level = 3, - content = _"You are subscribed for this subject area" - } - ui.tag { tag = "ul", attr = { class = "ul" }, content = function () - ui.tag { tag = "li", content = function () - ui.tag { content = function () - ui.link { - module = "membership", action = "update", - routing = { default = { - mode = "redirect", module = "area", view = "show", id = area.id - } }, - params = { area_id = area.id, delete = true }, - text = _"unsubscribe" - } - end } - end } - end } - end ) - end ui.sidebarSection ( function () diff -r 62f7e7d4f9ec -r 84f6e17c7ceb app/main/member/_action/update_notify_level.lua --- a/app/main/member/_action/update_notify_level.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/app/main/member/_action/update_notify_level.lua Sun Apr 17 15:03:44 2016 +0200 @@ -1,2 +1,3 @@ app.session.member.disable_notifications = param.get("disable_notifications") == "true" and true or false +IgnoredArea:destroy_by_member_id(app.session.member_id) app.session.member:save() diff -r 62f7e7d4f9ec -r 84f6e17c7ceb app/main/member/settings_notification.lua --- a/app/main/member/settings_notification.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/app/main/member/settings_notification.lua Sun Apr 17 15:03:44 2016 +0200 @@ -1,4 +1,5 @@ local return_to = param.get("return_to") +local return_to_area_id param.get("return_to_area_id", atom.integer) ui.titleMember(_"notification settings") @@ -15,9 +16,9 @@ routing = { ok = { mode = "redirect", - module = return_to == "home" and "index" or "member", - view = return_to == "home" and "index" or "show", - id = return_to ~= "home" and app.session.member_id or nil + module = return_to == "area" and "area" or return_to == "home" and "index" or "member", + view = return_to == "area" and "show" or return_to == "home" and "index" or "show", + id = return_to == "area" and return_to_area_id or return_to ~= "home" and app.session.member_id or nil } }, content = function() @@ -25,7 +26,7 @@ ui.section( function() ui.sectionHead( function() - ui.heading { level = 1, content = _"For which issue phases do you like to receive notification emails?" } + ui.heading { level = 1, content = _"Do you like to receive updates by email?" } end ) diff -r 62f7e7d4f9ec -r 84f6e17c7ceb config/example.lua --- a/config/example.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/config/example.lua Sun Apr 17 15:03:44 2016 +0200 @@ -147,6 +147,19 @@ -- config.mail_reply_to = { name = "Support", address = "support@example.com" } +-- Template for digest emails +-- #{name} will be replaced by member screen name +-- #{digest} will be replaced with the digest content +-- ------------------------------------------------------------------------ +-- config.notification_digest_template = [[ +-- Hello #{name}, +-- +-- this is your personal digest. +-- +-- #{digest} +-- ]] + + -- Configuration of password hashing algorithm (defaults to "crypt_sha512") -- ------------------------------------------------------------------------ -- config.password_hash_algorithm = "crypt_sha512" diff -r 62f7e7d4f9ec -r 84f6e17c7ceb model/event.lua --- a/model/event.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/model/event.lua Sun Apr 17 15:03:44 2016 +0200 @@ -137,14 +137,14 @@ function Event:send_next_notification() - local notification_sent = NotificationSent:new_selector() + local notification_event_sent = NotificationEventSent:new_selector() :optional_object_mode() :for_update() :exec() local last_event_id = 0 - if notification_sent then - last_event_id = notification_sent.event_id + if notification_event_sent then + last_event_id = notification_event_sent.event_id end local event = Event:new_selector() @@ -156,9 +156,9 @@ if event then if last_event_id == 0 then - db:query{ "INSERT INTO notification_sent (event_id) VALUES (?)", event.id } + db:query{ "INSERT INTO notification_event_sent (event_id) VALUES (?)", event.id } else - db:query{ "UPDATE notification_sent SET event_id = ?", event.id } + db:query{ "UPDATE notification_event_sent SET event_id = ?", event.id } end event:send_notification() diff -r 62f7e7d4f9ec -r 84f6e17c7ceb model/initiative_for_notification.lua --- a/model/initiative_for_notification.lua Tue Apr 05 20:41:05 2016 +0200 +++ b/model/initiative_for_notification.lua Sun Apr 17 15:03:44 2016 +0200 @@ -132,7 +132,7 @@ if suggestion_count == 1 then info[#info+1] = _"new suggestion for " .. initiatives_for_notification[1].initiative.display_name else - info[#info+1] = _("#{suggestion_count} suggestions added", { suggestion_count = suggestion_count }) + info[#info+1] = _("#{count} suggestions added", { count = suggestion_count }) end end @@ -175,4 +175,4 @@ return true end -ScheduledNotificationToSend:get_next() \ No newline at end of file +ScheduledNotificationToSend:get_next() diff -r 62f7e7d4f9ec -r 84f6e17c7ceb model/notification_event_sent.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/model/notification_event_sent.lua Sun Apr 17 15:03:44 2016 +0200 @@ -0,0 +1,2 @@ +NotificationEventSent = mondelefant.new_class() +NotificationEventSent.table = 'notification_event_sent' diff -r 62f7e7d4f9ec -r 84f6e17c7ceb model/notification_sent.lua --- a/model/notification_sent.lua Tue Apr 05 20:41:05 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -NotificationSent = mondelefant.new_class() -NotificationSent.table = 'notification_sent'