# HG changeset patch # User bsw # Date 1345427660 -7200 # Node ID ae9ab3edff897afacf2d6a0c3e429cf727407baf # Parent 54e32e34be01309b499955da7d6fe45d31666536 Added polling support diff -r 54e32e34be01 -r ae9ab3edff89 app/main/initiative/_action/create.lua --- a/app/main/initiative/_action/create.lua Mon Aug 20 03:53:55 2012 +0200 +++ b/app/main/initiative/_action/create.lua Mon Aug 20 03:54:20 2012 +0200 @@ -76,6 +76,10 @@ slot.put_into("error", "Invalid policy.") return false end + if policy.polling and not app.session.member:has_polling_right_for_unit_id(area.unit_id) then + error("no polling right for this unit") + end + if not area:get_reference_selector("allowed_policies") :add_where{ "policy.id = ?", policy_id } :optional_object_mode() @@ -86,6 +90,13 @@ issue = Issue:new() issue.area_id = area.id issue.policy_id = policy_id + + if policy.polling then + issue.accepted = 'now' + issue.state = 'discussion' + initiative.polling = true + end + issue:save() if config.etherpad then @@ -99,6 +110,9 @@ end end +if param.get("polling", atom.boolean) and app.session.member:has_polling_right_for_unit_id(area.unit_id) then + initiative.polling = true +end initiative.issue_id = issue.id initiative.name = name param.update(initiative, "discussion_url") diff -r 54e32e34be01 -r ae9ab3edff89 app/main/initiative/_list_element.lua --- a/app/main/initiative/_list_element.lua Mon Aug 20 03:53:55 2012 +0200 +++ b/app/main/initiative/_list_element.lua Mon Aug 20 03:54:20 2012 +0200 @@ -8,6 +8,10 @@ class = class .. " selected" end +if initiative.polling then + class = class .. " polling" +end + ui.container{ attr = { class = class }, content = function() ui.container{ attr = { class = "rank" }, content = function() diff -r 54e32e34be01 -r ae9ab3edff89 app/main/initiative/_show.lua --- a/app/main/initiative/_show.lua Mon Aug 20 03:53:55 2012 +0200 +++ b/app/main/initiative/_show.lua Mon Aug 20 03:54:20 2012 +0200 @@ -53,7 +53,13 @@ util.help("initiative.show") -ui.container{ attr = { class = "initiative_head" }, content = function() +local class = "initiative_head" + +if initiative.polling then + class = class .. " polling" +end + +ui.container{ attr = { class = class }, content = function() local text = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) if show_as_head then diff -r 54e32e34be01 -r ae9ab3edff89 app/main/initiative/new.lua --- a/app/main/initiative/new.lua Mon Aug 20 03:53:55 2012 +0200 +++ b/app/main/initiative/new.lua Mon Aug 20 03:54:20 2012 +0200 @@ -34,7 +34,9 @@ else tmp = { { id = -1, name = _"Please choose a policy" } } for i, allowed_policy in ipairs(area.allowed_policies) do - tmp[#tmp+1] = allowed_policy + if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then + tmp[#tmp+1] = allowed_policy + end end ui.field.select{ label = _"Policy", @@ -72,6 +74,10 @@ } end + if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then + ui.field.boolean{ name = "polling", label = _"Poll" } + end + if param.get("preview") then ui.heading{ level = 1, content = encode.html(param.get("name")) } local discussion_url = param.get("discussion_url") diff -r 54e32e34be01 -r ae9ab3edff89 static/style.css --- a/static/style.css Mon Aug 20 03:53:55 2012 +0200 +++ b/static/style.css Mon Aug 20 03:54:20 2012 +0200 @@ -1076,6 +1076,11 @@ xfont-style: italic; } +.initiative.polling .name, +.initiative_head.polling .title { + font-style: italic; +} + @media screen and (max-width: 480px) { .initiative .name { clear: left;