liquid_feedback_frontend
changeset 1254:55132e0324a4
Added missing files for new notification system
author | bsw |
---|---|
date | Sun Apr 17 16:14:21 2016 +0200 (2016-04-17) |
parents | 235a36a08da1 |
children | 1d645a8d20fc |
files | app/main/area/_action/update_ignore.lua model/ignored_area.lua |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/area/_action/update_ignore.lua Sun Apr 17 16:14:21 2016 +0200 1.3 @@ -0,0 +1,21 @@ 1.4 +local area_id = assert(param.get("area_id", atom.integer), "no area id given") 1.5 + 1.6 + 1.7 +local ignored_area = IgnoredArea:by_pk(app.session.member_id, area_id) 1.8 + 1.9 +if param.get("delete", atom.boolean) then 1.10 + if ignored_area then 1.11 + ignored_area:destroy() 1.12 + slot.select("notice", function() ui.tag{ content = _"You have been subscribed for update emails about this subject area" } end) 1.13 + end 1.14 + return 1.15 +end 1.16 + 1.17 +if not ignored_area then 1.18 + local ignored_area = IgnoredArea:new() 1.19 + ignored_area.member_id = app.session.member_id 1.20 + ignored_area.area_id = area_id 1.21 + ignored_area:save() 1.22 + slot.select("notice", function() ui.tag{ content = _"You will no longer receive update emails about this subject area" } end ) 1.23 + 1.24 +end
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/model/ignored_area.lua Sun Apr 17 16:14:21 2016 +0200 2.3 @@ -0,0 +1,20 @@ 2.4 +IgnoredArea = mondelefant.new_class() 2.5 +IgnoredArea.table = 'ignored_area' 2.6 +IgnoredArea.primary_key = { "member_id", "area_id" } 2.7 + 2.8 +function IgnoredArea:by_pk(member_id, area_id) 2.9 + return self:new_selector() 2.10 + :add_where{ "member_id = ?", member_id } 2.11 + :add_where{ "area_id = ?", area_id } 2.12 + :optional_object_mode() 2.13 + :exec() 2.14 +end 2.15 + 2.16 +function IgnoredArea:destroy_by_member_id(member_id) 2.17 + local ignored_areas = self:new_selector() 2.18 + :add_where{ "member_id = ?", member_id } 2.19 + :exec() 2.20 + for i, ignored_area in ipairs(ignored_areas) do 2.21 + ignored_area:destroy() 2.22 + end 2.23 +end 2.24 \ No newline at end of file