# HG changeset patch # User bsw # Date 1286207489 -7200 # Node ID e5a221e57dc6b1d4e137e6370cb99f8bc49a4da4 # Parent 9f3f74e82a651d2535286bad24620df77bed01c6# Parent 915cc0341538f3b9f7c2e860a366e8cac786863c merge diff -r 9f3f74e82a65 -r e5a221e57dc6 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Mon Oct 04 17:51:29 2010 +0200 @@ -0,0 +1,2 @@ +tmp +.+~ \ No newline at end of file diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/_layout/default.html --- a/app/main/_layout/default.html Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/_layout/default.html Mon Oct 04 17:51:29 2010 +0200 @@ -83,5 +83,6 @@ diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/admin/_action/area_update.lua --- a/app/main/admin/_action/area_update.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/admin/_action/area_update.lua Mon Oct 04 17:51:29 2010 +0200 @@ -16,4 +16,12 @@ area:save() +param.update_relationship{ + param_name = "allowed_policies", + id = area.id, + connecting_model = AllowedPolicy, + own_reference = "area_id", + foreign_reference = "policy_id" +} + slot.put_into("notice", _"Area successfully updated") diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/admin/area_show.lua --- a/app/main/admin/area_show.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/admin/area_show.lua Mon Oct 04 17:51:29 2010 +0200 @@ -24,6 +24,12 @@ ui.field.text{ label = _"Name", name = "name" } ui.field.boolean{ label = _"Active?", name = "active" } ui.field.text{ label = _"Description", name = "description", multiline = true } + ui.multiselect{ label = _"Policies", name = "allowed_policies[]", + foreign_records = Policy:new_selector():add_where{ "active='t'"}:exec(), + foreign_id = "id", + foreign_name = "name", + connecting_records = area.allowed_policies, + foreign_reference = "id" } ui.submit{ text = _"Save" } end } diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/delegation/_show_box.lua --- a/app/main/delegation/_show_box.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/delegation/_show_box.lua Mon Oct 04 17:51:29 2010 +0200 @@ -1,4 +1,4 @@ -function change_delegation(scope, area_id, issue, delegation) +function change_delegation(scope, area_id, issue, delegation, initiative_id) local image local text if scope == "global" and delegation then @@ -34,6 +34,7 @@ view = "new", params = { issue_id = issue and issue.id or nil, + initiative_id = initiative_id or nil, area_id = area_id }, } @@ -62,11 +63,13 @@ local delegation local area_id local issue_id +local initiative_id local scope = "global" if param.get("initiative_id", atom.integer) then - issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id + initiative_id = param.get("initiative_id", atom.integer) + issue_id = Initiative:by_id(initiative_id).issue_id scope = "issue" end @@ -84,6 +87,7 @@ local delegation local issue + if issue_id then issue = Issue:by_id(issue_id) delegation = Delegation:by_pk(app.session.member.id, nil, issue_id) @@ -149,7 +153,7 @@ :exec() if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then - change_delegation(scope, area_id, issue, delegation) + change_delegation(scope, area_id, issue, delegation, initiative_id) end for i, record in ipairs(delegation_chain) do @@ -210,6 +214,6 @@ end } else - change_delegation(scope, area_id, issue) + change_delegation(scope, area_id, issue, nil, initiative_id) end end) diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/delegation/new.lua --- a/app/main/delegation/new.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/delegation/new.lua Mon Oct 04 17:51:29 2010 +0200 @@ -10,6 +10,8 @@ util.help("delegation.new.issue") end +local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) + if not area and not issue then slot.put_into("title", encode.html(_"Set global delegation")) util.help("delegation.new.global") @@ -80,9 +82,21 @@ name = _"No delegation" } } + for i, record in ipairs(contact_members) do records[#records+1] = record end + disabled_records = {} + -- add initiative authors + if initiative then + records[#records+1] = {id="_", name=_"--- Initiators ---"} + disabled_records["_"] = true + for i,record in ipairs(initiative.initiators) do + trace.debug(record) + trace.debug(record.member.name) + records[#records+1] = record.member + end + end ui.field.select{ label = _"Trustee", @@ -90,7 +104,9 @@ foreign_records = records, foreign_id = "id", foreign_name = "name", + disabled_records = disabled_records } + ui.submit{ text = _"Save" } end } diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/initiative/show_static.lua --- a/app/main/initiative/show_static.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/initiative/show_static.lua Mon Oct 04 17:51:29 2010 +0200 @@ -19,7 +19,8 @@ execute.view{ module = "issue", view = "_show_head", - params = { issue = initiative.issue } + params = { issue = initiative.issue, + initiative = initiative } } --slot.put_into("html_head", '') diff -r 9f3f74e82a65 -r e5a221e57dc6 app/main/issue/_show_head.lua --- a/app/main/issue/_show_head.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/app/main/issue/_show_head.lua Mon Oct 04 17:51:29 2010 +0200 @@ -1,4 +1,5 @@ local issue = param.get("issue", "table") +local initiative = param.get("initiative", "table") local direct_voter @@ -68,7 +69,8 @@ execute.view{ module = "delegation", view = "_show_box", - params = { issue_id = issue.id } + params = { issue_id = issue.id, + initiative_id = initiative and initiative.id or nil} } end diff -r 9f3f74e82a65 -r e5a221e57dc6 bin/liquid-admin.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/liquid-admin.lua Mon Oct 04 17:51:29 2010 +0200 @@ -0,0 +1,86 @@ +#!/usr/bin/env lua + +OptionParser = require("utils.optparse") + +COMMANDS = {{"setpwd ", "Set a user command"}, + {"listuser", "List usernames"}, + } + +t={usage="", version="", commands=COMMANDS} +op=OptionParser(t) +--op.add_option({"-t", action="safe_true", dest="test", help=""}) +op.add_option({"-c", action="store", dest="config", help="config name to use", default="default"}) +op.add_option({"-w", action="store", dest="webmcp", help="path to webmcp", default="../webmcp"}) + +options,args = op.parse_args() + +if #args == 0 then + print("Error: command is required\n") + op.print_help() + return +end + +-- dirty dirty dirty, dirty dirty, dirty dirty dow monkey patch env +if not os.setenv then + + local env, getenv = { }, os.getenv + + function os.setenv(k,v) + env[k] = v + end + + function os.getenv(k) + return env[k] or getenv(k) + end + +end + +-- detect current path FIXME: platform portable +local PWD = io.popen("pwd"):read() +os.setenv("WEBMCP_APP_BASEPATH", PWD) +os.setenv("WEBMCP_CONFIG_NAME", options.config) +os.setenv("WEBMCP_INTERACTIVE", "yes") + +-- load webmcp framework +WEBMCP_PATH = options.webmcp .. "/framework/" +dofile(options.webmcp .. "/framework/cgi-bin/webmcp.lua") + +function error(why) + print(why) + os.exit(2) +end + +if args[1] == "setpwd" then + if #args < 2 then + error("login is required") + end + require("model.member") + user = Member:by_login(args[2]) + if not user then + error("User "..args[2].." not found") + end + print("Enter password:") + password = io.read() + if password then + user:set_password(password) + user:save() + end +end + +if args[1] == "listusers" then + require("model.member") + sel = Member:new_selector() + users = sel:exec() + --sel:optional_object_mode() + print("Login Active") + for i,v in pairs(users) do + if v.login then + print(v.login .. string.rep(" ", 25-#v.login), v.active) + end + end +end + + + + + diff -r 9f3f74e82a65 -r e5a221e57dc6 config/development.lua --- a/config/development.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/config/development.lua Mon Oct 04 17:51:29 2010 +0200 @@ -33,4 +33,12 @@ config.motd_intern = "==Internal motd==" -config.public_access = "anonymous" \ No newline at end of file +config.public_access = "anonymous" + +-- you can put some js code to the bottom on the page +-- here it opens the trace window + +--slot.put_into( +-- "custom_script", +-- "document.getElementById('trace_show').onclick();" +--) diff -r 9f3f74e82a65 -r e5a221e57dc6 locale/translations.de.lua --- a/locale/translations.de.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/locale/translations.de.lua Mon Oct 04 17:51:29 2010 +0200 @@ -1,5 +1,6 @@ #!/usr/bin/env lua return { +["--- Initiators ---"] = "--- Initiatoren ---"; ["##{id}"] = false; ["##{issue_id}.#{id} #{name}"] = false; ["#{interested_issues_to_vote_count} issue(s) you are interested in"] = "#{interested_issues_to_vote_count} Themen, die Dich interessieren"; diff -r 9f3f74e82a65 -r e5a221e57dc6 locale/translations.en.lua --- a/locale/translations.en.lua Fri Sep 24 14:49:36 2010 +0200 +++ b/locale/translations.en.lua Mon Oct 04 17:51:29 2010 +0200 @@ -1,5 +1,6 @@ #!/usr/bin/env lua return { +["--- Initiators ---"] = false; ["##{id}"] = false; ["##{issue_id}.#{id} #{name}"] = false; ["#{interested_issues_to_vote_count} issue(s) you are interested in"] = false; diff -r 9f3f74e82a65 -r e5a221e57dc6 model/allowed_policy.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/model/allowed_policy.lua Mon Oct 04 17:51:29 2010 +0200 @@ -0,0 +1,2 @@ +AllowedPolicy = mondelefant.new_class() +AllowedPolicy.table = 'allowed_policy' diff -r 9f3f74e82a65 -r e5a221e57dc6 utils/optparse.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/optparse.lua Mon Oct 04 17:51:29 2010 +0200 @@ -0,0 +1,139 @@ +-- Lua command line option parser. +-- Interface based on Pythons optparse. +-- http://docs.python.org/lib/module-optparse.html +-- (c) 2008 David Manura, Licensed under the same terms as Lua (MIT license) +-- +-- To be used like this: +-- t={usage="", version=""} +-- op=OptionParser(t) +-- op=add_option{"", action=, dest=, help=""} +-- +-- with : +-- the option string to be used (can be anything, if one letter opt, then should be -x val, more letters: -xy=val ) +-- one of +-- - store: store in options as key, val +-- - store_true: stores key, true +-- - store_false: stores key, false +-- is the key under which the option is saved +-- +-- options,args = op.parse_args() +-- +-- now options is the table of options (key, val) and args is the table with non-option arguments. +-- You can use op.fail(message) for failing and op.print_help() for printing the usage as you like. + +--module('utils.optparse') + +local function OptionParser(t) + local usage = t.usage + local version = t.version + local commands = t.commands + + local o = {} + local option_descriptions = {} + local option_of = {} + + function o.fail(s) -- extension + io.stderr:write(s .. '\n') + os.exit(1) + end + + function o.add_option(optdesc) + option_descriptions[#option_descriptions+1] = optdesc + for _,v in pairs(optdesc) do + option_of[v] = optdesc + end + end + function o.parse_args() + -- expand options (e.g. "--input=file" -> "--input", "file") + local arg = {unpack(arg)} + for i=#arg,1,-1 do local v = arg[i] + local flag, val = v:match('^(%-%-%w+)=(.*)') + if flag then + arg[i] = flag + table.insert(arg, i+1, val) + end + end + + local options = {} + for _,optdesc in ipairs(option_descriptions) do + options[optdesc["dest"]] = optdesc.default + end + local args = {} + local i = 1 + while i <= #arg do local v = arg[i] + local optdesc = option_of[v] + if optdesc then + local action = optdesc.action + local val + if action == 'store' or action == nil then + i = i + 1 + val = arg[i] + if not val then o.fail('option requires an argument ' .. v) end + elseif action == 'store_true' then + val = true + elseif action == 'store_false' then + val = false + end + options[optdesc.dest] = val + else + if v:match('^%-') then o.fail('invalid option ' .. v) end + args[#args+1] = v + end + i = i + 1 + end + if options.help then + o.print_help() + os.exit() + end + if options.version then + io.stdout:write(t.version .. "\n") + os.exit() + end + return options, args + end + + local function flags_str(optdesc) + local sflags = {} + local action = optdesc.action + for _,flag in ipairs(optdesc) do + local sflagend + if action == nil or action == 'store' then + local metavar = optdesc.metavar or optdesc.dest:upper() + sflagend = #flag == 2 and ' ' .. metavar + or '=' .. metavar + else + sflagend = '' + end + sflags[#sflags+1] = flag .. sflagend + end + return table.concat(sflags, ', ') + end + + function o.print_help() + io.stdout:write("Usage: " .. usage:gsub('%%prog', arg[0]) .. "\n") + io.stdout:write("\n") + io.stdout:write("Options:\n") + for _,optdesc in ipairs(option_descriptions) do + io.stdout:write(" " .. flags_str(optdesc) .. + " " .. optdesc.help .. "\n") + end + if commands then + io.stdout:write("\nCommands:\n") + for _,command in ipairs(commands) do + io.stdout:write(" " .. command[1] .. + string.rep(" ", 30-#command[1]) .. + command[2] .. "\n") + end + end + + end + o.add_option{"--help", action="store_true", dest="help", + help="show this help message and exit"} + if t.version then + o.add_option{"--version", action="store_true", dest="version", + help="output version info."} + end + return o +end + +return OptionParser \ No newline at end of file