liquid_feedback_frontend
annotate app/main/initiative/_action/add_support.lua @ 9:0ee1e0c42d4c
Version beta5
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
Minor security fix: Added missing security filter for admin section. Reading of member listing including login names was possible for all users. Write access has not been possible though.
Changing of name and login is possible while a history of these changes is written and accessible by all users.
Statistics shown in area list
Trimming of user input also converts multiple whitespaces to single space character.
author | bsw |
---|---|
date | Mon Jan 04 12:00:00 2010 +0100 (2010-01-04) |
parents | afd9f769c7ae |
children | 72c5e0ee7c98 |
rev | line source |
---|---|
bsw/jbe@0 | 1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() |
bsw/jbe@0 | 2 |
bsw/jbe@5 | 3 -- TODO important m1 selectors returning result _SET_! |
bsw/jbe@5 | 4 local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec() |
bsw/jbe@5 | 5 |
bsw/jbe@5 | 6 if issue.closed then |
bsw/jbe@5 | 7 slot.put_into("error", _"This issue is already closed.") |
bsw/jbe@5 | 8 return false |
bsw/jbe@5 | 9 elseif issue.fully_frozen then |
bsw/jbe@5 | 10 slot.put_into("error", _"Voting for this issue has already begun.") |
bsw/jbe@5 | 11 return false |
bsw/jbe@5 | 12 end |
bsw/jbe@5 | 13 |
bsw/jbe@0 | 14 local member = app.session.member |
bsw/jbe@0 | 15 |
bsw/jbe@0 | 16 local supporter = Supporter:by_pk(initiative.id, member.id) |
bsw/jbe@0 | 17 |
bsw/jbe@0 | 18 local last_draft = Draft:new_selector() |
bsw/jbe@0 | 19 :add_where{ "initiative_id = ?", initiative.id } |
bsw/jbe@0 | 20 :add_order_by("id DESC") |
bsw/jbe@0 | 21 :limit(1) |
bsw/jbe@0 | 22 :single_object_mode() |
bsw/jbe@0 | 23 :exec() |
bsw/jbe@0 | 24 |
bsw/jbe@0 | 25 if not supporter then |
bsw/jbe@0 | 26 supporter = Supporter:new() |
bsw/jbe@0 | 27 supporter.member_id = member.id |
bsw/jbe@0 | 28 supporter.initiative_id = initiative.id |
bsw/jbe@0 | 29 supporter.draft_id = last_draft.id |
bsw/jbe@0 | 30 supporter:save() |
bsw/jbe@0 | 31 slot.put_into("notice", _"Your support has been added to this initiative") |
bsw/jbe@0 | 32 elseif supporter.draft_id ~= last_draft.id then |
bsw/jbe@0 | 33 supporter.draft_id = last_draft.id |
bsw/jbe@0 | 34 supporter:save() |
bsw/jbe@0 | 35 slot.put_into("notice", _"Your support has been updated to the latest draft") |
bsw/jbe@0 | 36 else |
bsw/jbe@0 | 37 slot.put_into("notice", _"You are already supporting the latest draft") |
bsw/jbe@0 | 38 end |