liquid_feedback_frontend

diff app/main/opinion/_action/update.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 768faea1096d
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/opinion/_action/update.lua	Wed Nov 18 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +local member_id = app.session.member.id
     1.5 +
     1.6 +local suggestion_id = param.get("suggestion_id", atom.integer)
     1.7 +
     1.8 +local opinion = Opinion:by_pk(member_id, suggestion_id)
     1.9 +
    1.10 +if opinion and param.get("delete") then
    1.11 +  opinion:destroy()
    1.12 +  slot.put_into("notice", _"Your opinion has been updated")
    1.13 +  return
    1.14 +end
    1.15 +
    1.16 +if not opinion then
    1.17 +  opinion = Opinion:new()
    1.18 +  opinion.member_id     = member_id
    1.19 +  opinion.suggestion_id = suggestion_id
    1.20 +  opinion.fulfilled     = false
    1.21 +end
    1.22 +
    1.23 +local degree = param.get("degree", atom.number)
    1.24 +local fulfilled = param.get("fulfilled", atom.boolean)
    1.25 +
    1.26 +if degree ~= nil then
    1.27 +  opinion.degree = degree
    1.28 +end
    1.29 +
    1.30 +if fulfilled ~= nil then
    1.31 +  opinion.fulfilled = fulfilled
    1.32 +end
    1.33 +
    1.34 +opinion:save()
    1.35 +
    1.36 +slot.put_into("notice", _"Your opinion has been updated")

Impressum / About Us