liquid_feedback_frontend

diff app/main/vote/_action/update.lua @ 5:afd9f769c7ae

Version beta1

Final voting with Schulze-Method is now possible

Many bug fixes and code cleanup

Registration with invite codes

More sort and filter options

Seperated display of "supporters" and "potential supporters"

Optical changes

Flood limit / initiative contigent is now checked by frontend

Neccessary changes to access core beta11
author bsw/jbe
date Fri Dec 25 12:00:00 2009 +0100 (2009-12-25)
parents
children 00d1004545f1
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/vote/_action/update.lua	Fri Dec 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec()
     1.5 +
     1.6 +if issue.closed then
     1.7 +  slot.put_into("error", _"This issue is already closed.")
     1.8 +  return false
     1.9 +end
    1.10 +
    1.11 +if issue.state ~= "voting" then
    1.12 +  slot.put_into("error", _"Voting has not started yet.")
    1.13 +  return false
    1.14 +end
    1.15 +
    1.16 +local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id)
    1.17 +
    1.18 +if not direct_voter then
    1.19 +  direct_voter = DirectVoter:new()
    1.20 +  direct_voter.issue_id = issue.id
    1.21 +  direct_voter.member_id = app.session.member_id
    1.22 +end
    1.23 +
    1.24 +direct_voter.autoreject = false
    1.25 +
    1.26 +direct_voter:save()
    1.27 +
    1.28 +
    1.29 +local scoring = param.get("scoring")
    1.30 +
    1.31 +for initiative_id, grade in scoring:gmatch("([^:;]+):([^:;]+)") do
    1.32 +  local initiative_id = tonumber(initiative_id)
    1.33 +  local grade = tonumber(grade)
    1.34 +  local initiative = Initiative:by_id(initiative_id)
    1.35 +  if initiative.issue.id ~= issue.id then
    1.36 +    error("initiative from wrong issue")
    1.37 +  end
    1.38 +  local vote = Vote:by_pk(initiative_id, app.session.member.id)
    1.39 +  if not vote then
    1.40 +    vote = Vote:new()
    1.41 +    vote.issue_id = issue.id
    1.42 +    vote.initiative_id = initiative.id
    1.43 +    vote.member_id = app.session.member.id
    1.44 +  end
    1.45 +  vote.grade = grade
    1.46 +  vote:save()
    1.47 +end
    1.48 +
    1.49 +trace.debug(scoring)
    1.50 +

Impressum / About Us