liquid_feedback_frontend
annotate app/main/vote/_action/non_voter.lua @ 889:6ba4ebe7b707
Respect non_voter for not voted issues notification
| author | bsw |
|---|---|
| date | Mon Aug 20 02:59:05 2012 +0200 (2012-08-20) |
| parents | 2e9d39b53b64 |
| children | 941941955c0e |
| rev | line source |
|---|---|
| bsw@886 | 1 local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec() |
| bsw@886 | 2 |
| bsw@886 | 3 local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id) |
| bsw@886 | 4 |
| bsw@886 | 5 if direct_voter then |
| bsw@886 | 6 slot.select("error", function() |
| bsw@886 | 7 ui.tag{ content = _"You already voted this issue" } |
| bsw@886 | 8 end ) |
| bsw@886 | 9 return false |
| bsw@886 | 10 end |
| bsw@886 | 11 |
| bsw@886 | 12 local non_voter = NonVoter:by_pk(issue.id, app.session.member_id) |
| bsw@886 | 13 |
| bsw@886 | 14 if non_voter and param.get("delete", atom.boolean) then |
| bsw@886 | 15 non_voter:destroy() |
| bsw@886 | 16 elseif not non_voter then |
| bsw@886 | 17 non_voter = NonVoter:new() |
| bsw@886 | 18 non_voter.issue_id = issue.id |
| bsw@886 | 19 non_voter.member_id = app.session.member_id |
| bsw@886 | 20 non_voter:save() |
| bsw@886 | 21 end |