liquid_feedback_frontend
view app/main/initiative/_action/revoke.lua @ 1200:8e36f08eaac6
Added Moonbridge to about page
| author | bsw | 
|---|---|
| date | Tue Jun 23 19:57:10 2015 +0200 (2015-06-23) | 
| parents | 1997cf1da04b | 
| children | 32cc544d5a5b | 
 line source
     1 local initiative = Initiative:by_id(param.get_id())
     3 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
     4 if not initiator or initiator.accepted ~= true then
     5   error("access denied")
     6 end
     8 -- TODO important m1 selectors returning result _SET_!
     9 local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
    11 if issue.closed then
    12   slot.put_into("error", _"This issue is already closed.")
    13   return false
    14 elseif issue.half_frozen then 
    15   slot.put_into("error", _"This issue is already frozen.")
    16   return false
    17 elseif not issue.accepted and issue.phase_finished then
    18   slot.put_into("error", _"Current phase is already closed.")
    19   return false
    20 end
    22 if initiative.revoked then
    23   slot.put_into("error", _"This initiative is already revoked")
    24   return false
    25 end
    27 local suggested_initiative_id = param.get("suggested_initiative_id", atom.integer)
    29 if suggested_initiative_id ~= -1 then
    30   local suggested_initiative = Initiative:by_id(suggested_initiative_id)
    31   if not suggested_initiative then
    32     error("object not found")
    33   end
    34   if initiative.id == suggested_initiative.id then
    35     slot.put_into("error", _"You can't suggest the initiative you are revoking")
    36     return false
    37   end
    38   initiative.suggested_initiative_id = suggested_initiative.id
    39 end
    41 if not param.get("are_you_sure", atom.boolean) then
    42   slot.put_into("error", _"You have to mark 'Are you sure' to revoke!")
    43   return false
    44 end
    46 initiative.revoked_by_member_id = app.session.member_id
    47 initiative.revoked = "now"
    48 initiative:save()
    50 slot.put_into("notice", _"Initiative is revoked now")
