# HG changeset patch # User bsw # Date 1360277330 -3600 # Node ID 2141aef04ad7a5863bb537cea399e8f9485b6a97 # Parent aa91b62e3be828d9be833260cbc59209e3628202 Configuration example for free timings diff -r aa91b62e3be8 -r 2141aef04ad7 config/example.lua --- a/config/example.lua Sat Feb 02 22:20:54 2013 +0100 +++ b/config/example.lua Thu Feb 07 23:48:50 2013 +0100 @@ -152,6 +152,49 @@ -- cookie_path = "/" --} +-- Free timings +-- ------------------------------------------------------------------------ +-- This example expects a date string entered in the free timing field +-- by the user creating a poll, interpreting it as target date for then +-- poll and splits the remaining time at the ratio of 4:1:2 +-- Please note, polling policies never have an admission phase +-- The available_func is optional, if not set any target date is allowed + +config.free_timing = { + calculate_func = function(policy, timing_string) + function interval_by_seconds(secs) + local secs_per_day = 60 * 60 * 24 + local days + days = math.floor(secs / secs_per_day) + secs = secs - days * secs_per_day + return days .. " days " .. secs .. " seconds" + end + local target_date = parse.date(timing_string, atom.date) + if not target_date then + return false + end + local target_timestamp = target_date.midday + local now = atom.timestamp:get_current() + trace.debug(target_timestamp, now) + local duration = target_timestamp - now + if duration < 0 then + return false + end + return { + discussion = interval_by_seconds(duration / 7 * 4), + verification = interval_by_seconds(duration / 7 * 1), + voting = interval_by_seconds(duration / 7 * 2) + } + end, + available_func = function(policy) + return { + { name = "End of 2013", id = '2013-12-31' }, + { name = "End of 2014", id = '2014-12-31' }, + { name = "End of 2015", id = '2015-12-31' } + } + end +} + -- WebMCP accelerator -- uncomment the following two lines to use C implementations of chosen -- functions and to disable garbage collection during the request, to