bsw/jbe@0: local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() bsw/jbe@0: bsw/jbe@5: -- TODO important m1 selectors returning result _SET_! bsw/jbe@5: local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec() bsw/jbe@5: bsw/jbe@5: if issue.closed then bsw/jbe@5: slot.put_into("error", _"This issue is already closed.") bsw/jbe@5: return false bsw/jbe@5: elseif issue.fully_frozen then bsw/jbe@5: slot.put_into("error", _"Voting for this issue has already begun.") bsw/jbe@5: return false bsw/jbe@5: end bsw/jbe@5: bsw/jbe@0: local member = app.session.member bsw/jbe@0: bsw/jbe@0: local supporter = Supporter:by_pk(initiative.id, member.id) bsw/jbe@0: bsw/jbe@0: if supporter then bsw/jbe@0: supporter:destroy() bsw@277: -- slot.put_into("notice", _"Your support has been removed from this initiative") bsw/jbe@0: else bsw@277: -- slot.put_into("notice", _"You are already not supporting this initiative") bsw/jbe@0: end