liquid_feedback_frontend

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

Impressum / About Us