liquid_feedback_frontend

changeset 886:2e9d39b53b64

Added support for setting/removing of beeing a non voter
author bsw
date Mon Aug 20 02:39:13 2012 +0200 (2012-08-20)
parents e81f35cdc088
children 2cfa41e89c15
files app/main/issue/_show.lua app/main/vote/_action/non_voter.lua model/issue.lua model/non_voter.lua
line diff
     1.1 --- a/app/main/issue/_show.lua	Mon Aug 20 02:38:34 2012 +0200
     1.2 +++ b/app/main/issue/_show.lua	Mon Aug 20 02:39:13 2012 +0200
     1.3 @@ -102,6 +102,43 @@
     1.4        params = { issue_id = issue.id }
     1.5      }
     1.6    end
     1.7 +  
     1.8 +  if voteable and not direct_voter then
     1.9 +    if not issue.member_info.non_voter then
    1.10 +      links[#links+1] ={
    1.11 +        content = _"Do not vote directly",
    1.12 +        module = "vote",
    1.13 +        action = "non_voter",
    1.14 +        params = { issue_id = issue.id },
    1.15 +        routing = {
    1.16 +          default = {
    1.17 +            mode = "redirect",
    1.18 +            module = request.get_module(),
    1.19 +            view = request.get_view(),
    1.20 +            id = param.get_id_cgi(),
    1.21 +            params = param.get_all_cgi()
    1.22 +          }
    1.23 +        }
    1.24 +      }
    1.25 +    else
    1.26 +      links[#links+1] = { attr = { class = "action" }, content = _"Do not vote directly" }
    1.27 +      links[#links+1] ={
    1.28 +        content = _"Cancel do not vote",
    1.29 +        module = "vote",
    1.30 +        action = "non_voter",
    1.31 +        params = { issue_id = issue.id, delete = true },
    1.32 +        routing = {
    1.33 +          default = {
    1.34 +            mode = "redirect",
    1.35 +            module = request.get_module(),
    1.36 +            view = request.get_view(),
    1.37 +            id = param.get_id_cgi(),
    1.38 +            params = param.get_all_cgi()
    1.39 +          }
    1.40 +        }
    1.41 +      }
    1.42 +    end
    1.43 +  end
    1.44  
    1.45    if not for_member or for_member.id == app.session.member_id then
    1.46      
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/app/main/vote/_action/non_voter.lua	Mon Aug 20 02:39:13 2012 +0200
     2.3 @@ -0,0 +1,21 @@
     2.4 +local issue = Issue:new_selector():add_where{ "id = ?", param.get("issue_id", atom.integer) }:for_share():single_object_mode():exec()
     2.5 +
     2.6 +local direct_voter = DirectVoter:by_pk(issue.id, app.session.member_id)
     2.7 +
     2.8 +if direct_voter then
     2.9 +  slot.select("error", function()
    2.10 +    ui.tag{ content = _"You already voted this issue" }
    2.11 +  end )
    2.12 +  return false
    2.13 +end
    2.14 +
    2.15 +local non_voter = NonVoter:by_pk(issue.id, app.session.member_id)
    2.16 +
    2.17 +if non_voter and param.get("delete", atom.boolean) then
    2.18 +  non_voter:destroy()
    2.19 +elseif not non_voter then
    2.20 +  non_voter = NonVoter:new()
    2.21 +  non_voter.issue_id = issue.id
    2.22 +  non_voter.member_id = app.session.member_id
    2.23 +  non_voter:save()
    2.24 +end
    2.25 \ No newline at end of file
     3.1 --- a/model/issue.lua	Mon Aug 20 02:38:34 2012 +0200
     3.2 +++ b/model/issue.lua	Mon Aug 20 02:39:13 2012 +0200
     3.3 @@ -153,6 +153,8 @@
     3.4      selector:add_field("other_trustee.name", "other_trustee_name")
     3.5      selector:left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", options.member_id })
     3.6      selector:add_field("direct_voter.member_id NOTNULL", "direct_voted")
     3.7 +    selector:left_join("non_voter", nil, { "non_voter.issue_id = issue.id AND non_voter.member_id = ?", options.member_id })
     3.8 +    selector:add_field("non_voter.member_id NOTNULL", "non_voter")
     3.9      return selector
    3.10    end
    3.11  }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/model/non_voter.lua	Mon Aug 20 02:39:13 2012 +0200
     4.3 @@ -0,0 +1,10 @@
     4.4 +NonVoter = mondelefant.new_class()
     4.5 +NonVoter.table = 'non_voter'
     4.6 +NonVoter.primary_key = { "issue_id", "member_id" }
     4.7 +
     4.8 +function NonVoter:by_pk(issue_id, member_id)
     4.9 +  return self:new_selector()
    4.10 +    :add_where{ "issue_id = ? AND member_id = ?", issue_id, member_id }
    4.11 +    :optional_object_mode()
    4.12 +    :exec()
    4.13 +end
    4.14 \ No newline at end of file

Impressum / About Us