liquid_feedback_frontend
changeset 120:e5a221e57dc6
merge
author | bsw |
---|---|
date | Mon Oct 04 17:51:29 2010 +0200 (2010-10-04) |
parents | 9f3f74e82a65 915cc0341538 |
children | 082450e65aa8 |
files | app/main/_layout/default.html locale/translations.de.lua |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Mon Oct 04 17:51:29 2010 +0200 1.3 @@ -0,0 +1,2 @@ 1.4 +tmp 1.5 +.+~ 1.6 \ No newline at end of file
2.1 --- a/app/main/_layout/default.html Fri Sep 24 14:49:36 2010 +0200 2.2 +++ b/app/main/_layout/default.html Mon Oct 04 17:51:29 2010 +0200 2.3 @@ -83,5 +83,6 @@ 2.4 </div> 2.5 </body> 2.6 <script> 2.7 + <!-- WEBMCP SLOTNODIV custom_script --> 2.8 </script> 2.9 </html>
3.1 --- a/app/main/admin/_action/area_update.lua Fri Sep 24 14:49:36 2010 +0200 3.2 +++ b/app/main/admin/_action/area_update.lua Mon Oct 04 17:51:29 2010 +0200 3.3 @@ -16,4 +16,12 @@ 3.4 3.5 area:save() 3.6 3.7 +param.update_relationship{ 3.8 + param_name = "allowed_policies", 3.9 + id = area.id, 3.10 + connecting_model = AllowedPolicy, 3.11 + own_reference = "area_id", 3.12 + foreign_reference = "policy_id" 3.13 +} 3.14 + 3.15 slot.put_into("notice", _"Area successfully updated")
4.1 --- a/app/main/admin/area_show.lua Fri Sep 24 14:49:36 2010 +0200 4.2 +++ b/app/main/admin/area_show.lua Mon Oct 04 17:51:29 2010 +0200 4.3 @@ -24,6 +24,12 @@ 4.4 ui.field.text{ label = _"Name", name = "name" } 4.5 ui.field.boolean{ label = _"Active?", name = "active" } 4.6 ui.field.text{ label = _"Description", name = "description", multiline = true } 4.7 + ui.multiselect{ label = _"Policies", name = "allowed_policies[]", 4.8 + foreign_records = Policy:new_selector():add_where{ "active='t'"}:exec(), 4.9 + foreign_id = "id", 4.10 + foreign_name = "name", 4.11 + connecting_records = area.allowed_policies, 4.12 + foreign_reference = "id" } 4.13 ui.submit{ text = _"Save" } 4.14 end 4.15 }
5.1 --- a/app/main/delegation/_show_box.lua Fri Sep 24 14:49:36 2010 +0200 5.2 +++ b/app/main/delegation/_show_box.lua Mon Oct 04 17:51:29 2010 +0200 5.3 @@ -1,4 +1,4 @@ 5.4 -function change_delegation(scope, area_id, issue, delegation) 5.5 +function change_delegation(scope, area_id, issue, delegation, initiative_id) 5.6 local image 5.7 local text 5.8 if scope == "global" and delegation then 5.9 @@ -34,6 +34,7 @@ 5.10 view = "new", 5.11 params = { 5.12 issue_id = issue and issue.id or nil, 5.13 + initiative_id = initiative_id or nil, 5.14 area_id = area_id 5.15 }, 5.16 } 5.17 @@ -62,11 +63,13 @@ 5.18 local delegation 5.19 local area_id 5.20 local issue_id 5.21 +local initiative_id 5.22 5.23 local scope = "global" 5.24 5.25 if param.get("initiative_id", atom.integer) then 5.26 - issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id 5.27 + initiative_id = param.get("initiative_id", atom.integer) 5.28 + issue_id = Initiative:by_id(initiative_id).issue_id 5.29 scope = "issue" 5.30 end 5.31 5.32 @@ -84,6 +87,7 @@ 5.33 5.34 local delegation 5.35 local issue 5.36 + 5.37 if issue_id then 5.38 issue = Issue:by_id(issue_id) 5.39 delegation = Delegation:by_pk(app.session.member.id, nil, issue_id) 5.40 @@ -149,7 +153,7 @@ 5.41 :exec() 5.42 5.43 if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then 5.44 - change_delegation(scope, area_id, issue, delegation) 5.45 + change_delegation(scope, area_id, issue, delegation, initiative_id) 5.46 end 5.47 5.48 for i, record in ipairs(delegation_chain) do 5.49 @@ -210,6 +214,6 @@ 5.50 end 5.51 } 5.52 else 5.53 - change_delegation(scope, area_id, issue) 5.54 + change_delegation(scope, area_id, issue, nil, initiative_id) 5.55 end 5.56 end)
6.1 --- a/app/main/delegation/new.lua Fri Sep 24 14:49:36 2010 +0200 6.2 +++ b/app/main/delegation/new.lua Mon Oct 04 17:51:29 2010 +0200 6.3 @@ -10,6 +10,8 @@ 6.4 util.help("delegation.new.issue") 6.5 end 6.6 6.7 +local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) 6.8 + 6.9 if not area and not issue then 6.10 slot.put_into("title", encode.html(_"Set global delegation")) 6.11 util.help("delegation.new.global") 6.12 @@ -80,9 +82,21 @@ 6.13 name = _"No delegation" 6.14 } 6.15 } 6.16 + 6.17 for i, record in ipairs(contact_members) do 6.18 records[#records+1] = record 6.19 end 6.20 + disabled_records = {} 6.21 + -- add initiative authors 6.22 + if initiative then 6.23 + records[#records+1] = {id="_", name=_"--- Initiators ---"} 6.24 + disabled_records["_"] = true 6.25 + for i,record in ipairs(initiative.initiators) do 6.26 + trace.debug(record) 6.27 + trace.debug(record.member.name) 6.28 + records[#records+1] = record.member 6.29 + end 6.30 + end 6.31 6.32 ui.field.select{ 6.33 label = _"Trustee", 6.34 @@ -90,7 +104,9 @@ 6.35 foreign_records = records, 6.36 foreign_id = "id", 6.37 foreign_name = "name", 6.38 + disabled_records = disabled_records 6.39 } 6.40 + 6.41 ui.submit{ text = _"Save" } 6.42 end 6.43 }
7.1 --- a/app/main/initiative/show_static.lua Fri Sep 24 14:49:36 2010 +0200 7.2 +++ b/app/main/initiative/show_static.lua Mon Oct 04 17:51:29 2010 +0200 7.3 @@ -19,7 +19,8 @@ 7.4 execute.view{ 7.5 module = "issue", 7.6 view = "_show_head", 7.7 - params = { issue = initiative.issue } 7.8 + params = { issue = initiative.issue, 7.9 + initiative = initiative } 7.10 } 7.11 7.12 --slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
8.1 --- a/app/main/issue/_show_head.lua Fri Sep 24 14:49:36 2010 +0200 8.2 +++ b/app/main/issue/_show_head.lua Mon Oct 04 17:51:29 2010 +0200 8.3 @@ -1,4 +1,5 @@ 8.4 local issue = param.get("issue", "table") 8.5 +local initiative = param.get("initiative", "table") 8.6 8.7 local direct_voter 8.8 8.9 @@ -68,7 +69,8 @@ 8.10 execute.view{ 8.11 module = "delegation", 8.12 view = "_show_box", 8.13 - params = { issue_id = issue.id } 8.14 + params = { issue_id = issue.id, 8.15 + initiative_id = initiative and initiative.id or nil} 8.16 } 8.17 end 8.18
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/bin/liquid-admin.lua Mon Oct 04 17:51:29 2010 +0200 9.3 @@ -0,0 +1,86 @@ 9.4 +#!/usr/bin/env lua 9.5 + 9.6 +OptionParser = require("utils.optparse") 9.7 + 9.8 +COMMANDS = {{"setpwd <username> <password>", "Set a user command"}, 9.9 + {"listuser", "List usernames"}, 9.10 + } 9.11 + 9.12 +t={usage="<some usage message>", version="<version string>", commands=COMMANDS} 9.13 +op=OptionParser(t) 9.14 +--op.add_option({"-t", action="safe_true", dest="test", help="<help message for this option>"}) 9.15 +op.add_option({"-c", action="store", dest="config", help="config name to use", default="default"}) 9.16 +op.add_option({"-w", action="store", dest="webmcp", help="path to webmcp", default="../webmcp"}) 9.17 + 9.18 +options,args = op.parse_args() 9.19 + 9.20 +if #args == 0 then 9.21 + print("Error: command is required\n") 9.22 + op.print_help() 9.23 + return 9.24 +end 9.25 + 9.26 +-- dirty dirty dirty, dirty dirty, dirty dirty dow monkey patch env 9.27 +if not os.setenv then 9.28 + 9.29 + local env, getenv = { }, os.getenv 9.30 + 9.31 + function os.setenv(k,v) 9.32 + env[k] = v 9.33 + end 9.34 + 9.35 + function os.getenv(k) 9.36 + return env[k] or getenv(k) 9.37 + end 9.38 + 9.39 +end 9.40 + 9.41 +-- detect current path FIXME: platform portable 9.42 +local PWD = io.popen("pwd"):read() 9.43 +os.setenv("WEBMCP_APP_BASEPATH", PWD) 9.44 +os.setenv("WEBMCP_CONFIG_NAME", options.config) 9.45 +os.setenv("WEBMCP_INTERACTIVE", "yes") 9.46 + 9.47 +-- load webmcp framework 9.48 +WEBMCP_PATH = options.webmcp .. "/framework/" 9.49 +dofile(options.webmcp .. "/framework/cgi-bin/webmcp.lua") 9.50 + 9.51 +function error(why) 9.52 + print(why) 9.53 + os.exit(2) 9.54 +end 9.55 + 9.56 +if args[1] == "setpwd" then 9.57 + if #args < 2 then 9.58 + error("login is required") 9.59 + end 9.60 + require("model.member") 9.61 + user = Member:by_login(args[2]) 9.62 + if not user then 9.63 + error("User "..args[2].." not found") 9.64 + end 9.65 + print("Enter password:") 9.66 + password = io.read() 9.67 + if password then 9.68 + user:set_password(password) 9.69 + user:save() 9.70 + end 9.71 +end 9.72 + 9.73 +if args[1] == "listusers" then 9.74 + require("model.member") 9.75 + sel = Member:new_selector() 9.76 + users = sel:exec() 9.77 + --sel:optional_object_mode() 9.78 + print("Login Active") 9.79 + for i,v in pairs(users) do 9.80 + if v.login then 9.81 + print(v.login .. string.rep(" ", 25-#v.login), v.active) 9.82 + end 9.83 + end 9.84 +end 9.85 + 9.86 + 9.87 + 9.88 + 9.89 +
10.1 --- a/config/development.lua Fri Sep 24 14:49:36 2010 +0200 10.2 +++ b/config/development.lua Mon Oct 04 17:51:29 2010 +0200 10.3 @@ -33,4 +33,12 @@ 10.4 10.5 config.motd_intern = "==Internal motd==" 10.6 10.7 -config.public_access = "anonymous" 10.8 \ No newline at end of file 10.9 +config.public_access = "anonymous" 10.10 + 10.11 +-- you can put some js code to the bottom on the page 10.12 +-- here it opens the trace window 10.13 + 10.14 +--slot.put_into( 10.15 +-- "custom_script", 10.16 +-- "document.getElementById('trace_show').onclick();" 10.17 +--)
11.1 --- a/locale/translations.de.lua Fri Sep 24 14:49:36 2010 +0200 11.2 +++ b/locale/translations.de.lua Mon Oct 04 17:51:29 2010 +0200 11.3 @@ -1,5 +1,6 @@ 11.4 #!/usr/bin/env lua 11.5 return { 11.6 +["--- Initiators ---"] = "--- Initiatoren ---"; 11.7 ["##{id}"] = false; 11.8 ["##{issue_id}.#{id} #{name}"] = false; 11.9 ["#{interested_issues_to_vote_count} issue(s) you are interested in"] = "#{interested_issues_to_vote_count} Themen, die Dich interessieren";
12.1 --- a/locale/translations.en.lua Fri Sep 24 14:49:36 2010 +0200 12.2 +++ b/locale/translations.en.lua Mon Oct 04 17:51:29 2010 +0200 12.3 @@ -1,5 +1,6 @@ 12.4 #!/usr/bin/env lua 12.5 return { 12.6 +["--- Initiators ---"] = false; 12.7 ["##{id}"] = false; 12.8 ["##{issue_id}.#{id} #{name}"] = false; 12.9 ["#{interested_issues_to_vote_count} issue(s) you are interested in"] = false;
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/model/allowed_policy.lua Mon Oct 04 17:51:29 2010 +0200 13.3 @@ -0,0 +1,2 @@ 13.4 +AllowedPolicy = mondelefant.new_class() 13.5 +AllowedPolicy.table = 'allowed_policy'
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/utils/optparse.lua Mon Oct 04 17:51:29 2010 +0200 14.3 @@ -0,0 +1,139 @@ 14.4 +-- Lua command line option parser. 14.5 +-- Interface based on Pythons optparse. 14.6 +-- http://docs.python.org/lib/module-optparse.html 14.7 +-- (c) 2008 David Manura, Licensed under the same terms as Lua (MIT license) 14.8 +-- 14.9 +-- To be used like this: 14.10 +-- t={usage="<some usage message>", version="<version string>"} 14.11 +-- op=OptionParser(t) 14.12 +-- op=add_option{"<opt>", action=<action>, dest=<dest>, help="<help message for this option>"} 14.13 +-- 14.14 +-- with : 14.15 +-- <opt> the option string to be used (can be anything, if one letter opt, then should be -x val, more letters: -xy=val ) 14.16 +-- <action> one of 14.17 +-- - store: store in options as key, val 14.18 +-- - store_true: stores key, true 14.19 +-- - store_false: stores key, false 14.20 +-- <dest> is the key under which the option is saved 14.21 +-- 14.22 +-- options,args = op.parse_args() 14.23 +-- 14.24 +-- now options is the table of options (key, val) and args is the table with non-option arguments. 14.25 +-- You can use op.fail(message) for failing and op.print_help() for printing the usage as you like. 14.26 + 14.27 +--module('utils.optparse') 14.28 + 14.29 +local function OptionParser(t) 14.30 + local usage = t.usage 14.31 + local version = t.version 14.32 + local commands = t.commands 14.33 + 14.34 + local o = {} 14.35 + local option_descriptions = {} 14.36 + local option_of = {} 14.37 + 14.38 + function o.fail(s) -- extension 14.39 + io.stderr:write(s .. '\n') 14.40 + os.exit(1) 14.41 + end 14.42 + 14.43 + function o.add_option(optdesc) 14.44 + option_descriptions[#option_descriptions+1] = optdesc 14.45 + for _,v in pairs(optdesc) do 14.46 + option_of[v] = optdesc 14.47 + end 14.48 + end 14.49 + function o.parse_args() 14.50 + -- expand options (e.g. "--input=file" -> "--input", "file") 14.51 + local arg = {unpack(arg)} 14.52 + for i=#arg,1,-1 do local v = arg[i] 14.53 + local flag, val = v:match('^(%-%-%w+)=(.*)') 14.54 + if flag then 14.55 + arg[i] = flag 14.56 + table.insert(arg, i+1, val) 14.57 + end 14.58 + end 14.59 + 14.60 + local options = {} 14.61 + for _,optdesc in ipairs(option_descriptions) do 14.62 + options[optdesc["dest"]] = optdesc.default 14.63 + end 14.64 + local args = {} 14.65 + local i = 1 14.66 + while i <= #arg do local v = arg[i] 14.67 + local optdesc = option_of[v] 14.68 + if optdesc then 14.69 + local action = optdesc.action 14.70 + local val 14.71 + if action == 'store' or action == nil then 14.72 + i = i + 1 14.73 + val = arg[i] 14.74 + if not val then o.fail('option requires an argument ' .. v) end 14.75 + elseif action == 'store_true' then 14.76 + val = true 14.77 + elseif action == 'store_false' then 14.78 + val = false 14.79 + end 14.80 + options[optdesc.dest] = val 14.81 + else 14.82 + if v:match('^%-') then o.fail('invalid option ' .. v) end 14.83 + args[#args+1] = v 14.84 + end 14.85 + i = i + 1 14.86 + end 14.87 + if options.help then 14.88 + o.print_help() 14.89 + os.exit() 14.90 + end 14.91 + if options.version then 14.92 + io.stdout:write(t.version .. "\n") 14.93 + os.exit() 14.94 + end 14.95 + return options, args 14.96 + end 14.97 + 14.98 + local function flags_str(optdesc) 14.99 + local sflags = {} 14.100 + local action = optdesc.action 14.101 + for _,flag in ipairs(optdesc) do 14.102 + local sflagend 14.103 + if action == nil or action == 'store' then 14.104 + local metavar = optdesc.metavar or optdesc.dest:upper() 14.105 + sflagend = #flag == 2 and ' ' .. metavar 14.106 + or '=' .. metavar 14.107 + else 14.108 + sflagend = '' 14.109 + end 14.110 + sflags[#sflags+1] = flag .. sflagend 14.111 + end 14.112 + return table.concat(sflags, ', ') 14.113 + end 14.114 + 14.115 + function o.print_help() 14.116 + io.stdout:write("Usage: " .. usage:gsub('%%prog', arg[0]) .. "\n") 14.117 + io.stdout:write("\n") 14.118 + io.stdout:write("Options:\n") 14.119 + for _,optdesc in ipairs(option_descriptions) do 14.120 + io.stdout:write(" " .. flags_str(optdesc) .. 14.121 + " " .. optdesc.help .. "\n") 14.122 + end 14.123 + if commands then 14.124 + io.stdout:write("\nCommands:\n") 14.125 + for _,command in ipairs(commands) do 14.126 + io.stdout:write(" " .. command[1] .. 14.127 + string.rep(" ", 30-#command[1]) .. 14.128 + command[2] .. "\n") 14.129 + end 14.130 + end 14.131 + 14.132 + end 14.133 + o.add_option{"--help", action="store_true", dest="help", 14.134 + help="show this help message and exit"} 14.135 + if t.version then 14.136 + o.add_option{"--version", action="store_true", dest="version", 14.137 + help="output version info."} 14.138 + end 14.139 + return o 14.140 +end 14.141 + 14.142 +return OptionParser 14.143 \ No newline at end of file