liquid_feedback_frontend
changeset 898:ae9ab3edff89
Added polling support
author | bsw |
---|---|
date | Mon Aug 20 03:54:20 2012 +0200 (2012-08-20) |
parents | 54e32e34be01 |
children | ad1e31e13ff6 |
files | app/main/initiative/_action/create.lua app/main/initiative/_list_element.lua app/main/initiative/_show.lua app/main/initiative/new.lua static/style.css |
line diff
1.1 --- a/app/main/initiative/_action/create.lua Mon Aug 20 03:53:55 2012 +0200 1.2 +++ b/app/main/initiative/_action/create.lua Mon Aug 20 03:54:20 2012 +0200 1.3 @@ -76,6 +76,10 @@ 1.4 slot.put_into("error", "Invalid policy.") 1.5 return false 1.6 end 1.7 + if policy.polling and not app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.8 + error("no polling right for this unit") 1.9 + end 1.10 + 1.11 if not area:get_reference_selector("allowed_policies") 1.12 :add_where{ "policy.id = ?", policy_id } 1.13 :optional_object_mode() 1.14 @@ -86,6 +90,13 @@ 1.15 issue = Issue:new() 1.16 issue.area_id = area.id 1.17 issue.policy_id = policy_id 1.18 + 1.19 + if policy.polling then 1.20 + issue.accepted = 'now' 1.21 + issue.state = 'discussion' 1.22 + initiative.polling = true 1.23 + end 1.24 + 1.25 issue:save() 1.26 1.27 if config.etherpad then 1.28 @@ -99,6 +110,9 @@ 1.29 end 1.30 end 1.31 1.32 +if param.get("polling", atom.boolean) and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 1.33 + initiative.polling = true 1.34 +end 1.35 initiative.issue_id = issue.id 1.36 initiative.name = name 1.37 param.update(initiative, "discussion_url")
2.1 --- a/app/main/initiative/_list_element.lua Mon Aug 20 03:53:55 2012 +0200 2.2 +++ b/app/main/initiative/_list_element.lua Mon Aug 20 03:54:20 2012 +0200 2.3 @@ -8,6 +8,10 @@ 2.4 class = class .. " selected" 2.5 end 2.6 2.7 +if initiative.polling then 2.8 + class = class .. " polling" 2.9 +end 2.10 + 2.11 ui.container{ attr = { class = class }, content = function() 2.12 2.13 ui.container{ attr = { class = "rank" }, content = function()
3.1 --- a/app/main/initiative/_show.lua Mon Aug 20 03:53:55 2012 +0200 3.2 +++ b/app/main/initiative/_show.lua Mon Aug 20 03:54:20 2012 +0200 3.3 @@ -53,7 +53,13 @@ 3.4 3.5 util.help("initiative.show") 3.6 3.7 -ui.container{ attr = { class = "initiative_head" }, content = function() 3.8 +local class = "initiative_head" 3.9 + 3.10 +if initiative.polling then 3.11 + class = class .. " polling" 3.12 +end 3.13 + 3.14 +ui.container{ attr = { class = class }, content = function() 3.15 3.16 local text = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name }) 3.17 if show_as_head then
4.1 --- a/app/main/initiative/new.lua Mon Aug 20 03:53:55 2012 +0200 4.2 +++ b/app/main/initiative/new.lua Mon Aug 20 03:54:20 2012 +0200 4.3 @@ -34,7 +34,9 @@ 4.4 else 4.5 tmp = { { id = -1, name = _"Please choose a policy" } } 4.6 for i, allowed_policy in ipairs(area.allowed_policies) do 4.7 - tmp[#tmp+1] = allowed_policy 4.8 + if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then 4.9 + tmp[#tmp+1] = allowed_policy 4.10 + end 4.11 end 4.12 ui.field.select{ 4.13 label = _"Policy", 4.14 @@ -72,6 +74,10 @@ 4.15 } 4.16 end 4.17 4.18 + if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then 4.19 + ui.field.boolean{ name = "polling", label = _"Poll" } 4.20 + end 4.21 + 4.22 if param.get("preview") then 4.23 ui.heading{ level = 1, content = encode.html(param.get("name")) } 4.24 local discussion_url = param.get("discussion_url")
5.1 --- a/static/style.css Mon Aug 20 03:53:55 2012 +0200 5.2 +++ b/static/style.css Mon Aug 20 03:54:20 2012 +0200 5.3 @@ -1076,6 +1076,11 @@ 5.4 xfont-style: italic; 5.5 } 5.6 5.7 +.initiative.polling .name, 5.8 +.initiative_head.polling .title { 5.9 + font-style: italic; 5.10 +} 5.11 + 5.12 @media screen and (max-width: 480px) { 5.13 .initiative .name { 5.14 clear: left;