# HG changeset patch # User bsw # Date 1460902461 -7200 # Node ID 55132e0324a439f3c4e6ee49ea62effcf9a93eb3 # Parent 235a36a08da145547291ba3f8dc2cafbd352fc41 Added missing files for new notification system diff -r 235a36a08da1 -r 55132e0324a4 app/main/area/_action/update_ignore.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/area/_action/update_ignore.lua Sun Apr 17 16:14:21 2016 +0200 @@ -0,0 +1,21 @@ +local area_id = assert(param.get("area_id", atom.integer), "no area id given") + + +local ignored_area = IgnoredArea:by_pk(app.session.member_id, area_id) + +if param.get("delete", atom.boolean) then + if ignored_area then + ignored_area:destroy() + slot.select("notice", function() ui.tag{ content = _"You have been subscribed for update emails about this subject area" } end) + end + return +end + +if not ignored_area then + local ignored_area = IgnoredArea:new() + ignored_area.member_id = app.session.member_id + ignored_area.area_id = area_id + ignored_area:save() + slot.select("notice", function() ui.tag{ content = _"You will no longer receive update emails about this subject area" } end ) + +end diff -r 235a36a08da1 -r 55132e0324a4 model/ignored_area.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/model/ignored_area.lua Sun Apr 17 16:14:21 2016 +0200 @@ -0,0 +1,20 @@ +IgnoredArea = mondelefant.new_class() +IgnoredArea.table = 'ignored_area' +IgnoredArea.primary_key = { "member_id", "area_id" } + +function IgnoredArea:by_pk(member_id, area_id) + return self:new_selector() + :add_where{ "member_id = ?", member_id } + :add_where{ "area_id = ?", area_id } + :optional_object_mode() + :exec() +end + +function IgnoredArea:destroy_by_member_id(member_id) + local ignored_areas = self:new_selector() + :add_where{ "member_id = ?", member_id } + :exec() + for i, ignored_area in ipairs(ignored_areas) do + ignored_area:destroy() + end +end \ No newline at end of file