liquid_feedback_frontend
view app/main/vote/_action/update.lua @ 15:a3ac899559de
Esperanto support activated in frontend
| author | bsw |
|---|---|
| date | Sun Jan 31 22:34:45 2010 +0100 (2010-01-31) |
| parents | afd9f769c7ae |
| children | 00d1004545f1 |
line source
1 local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec()
3 if issue.closed then
4 slot.put_into("error", _"This issue is already closed.")
5 return false
6 end
8 if issue.state ~= "voting" then
9 slot.put_into("error", _"Voting has not started yet.")
10 return false
11 end
13 local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id)
15 if not direct_voter then
16 direct_voter = DirectVoter:new()
17 direct_voter.issue_id = issue.id
18 direct_voter.member_id = app.session.member_id
19 end
21 direct_voter.autoreject = false
23 direct_voter:save()
26 local scoring = param.get("scoring")
28 for initiative_id, grade in scoring:gmatch("([^:;]+):([^:;]+)") do
29 local initiative_id = tonumber(initiative_id)
30 local grade = tonumber(grade)
31 local initiative = Initiative:by_id(initiative_id)
32 if initiative.issue.id ~= issue.id then
33 error("initiative from wrong issue")
34 end
35 local vote = Vote:by_pk(initiative_id, app.session.member.id)
36 if not vote then
37 vote = Vote:new()
38 vote.issue_id = issue.id
39 vote.initiative_id = initiative.id
40 vote.member_id = app.session.member.id
41 end
42 vote.grade = grade
43 vote:save()
44 end
46 trace.debug(scoring)
