liquid_feedback_frontend

changeset 961:2141aef04ad7

Configuration example for free timings
author bsw
date Thu Feb 07 23:48:50 2013 +0100 (2013-02-07)
parents aa91b62e3be8
children dfc7b75189ed
files config/example.lua
line diff
     1.1 --- a/config/example.lua	Sat Feb 02 22:20:54 2013 +0100
     1.2 +++ b/config/example.lua	Thu Feb 07 23:48:50 2013 +0100
     1.3 @@ -152,6 +152,49 @@
     1.4  --  cookie_path = "/"
     1.5  --}
     1.6  
     1.7 +-- Free timings
     1.8 +-- ------------------------------------------------------------------------
     1.9 +-- This example expects a date string entered in the free timing field
    1.10 +-- by the user creating a poll, interpreting it as target date for then
    1.11 +-- poll and splits the remaining time at the ratio of 4:1:2
    1.12 +-- Please note, polling policies never have an admission phase
    1.13 +-- The available_func is optional, if not set any target date is allowed
    1.14 +
    1.15 +config.free_timing = {
    1.16 +  calculate_func = function(policy, timing_string)
    1.17 +    function interval_by_seconds(secs)
    1.18 +      local secs_per_day = 60 * 60 * 24
    1.19 +      local days
    1.20 +      days = math.floor(secs / secs_per_day)
    1.21 +      secs = secs - days * secs_per_day
    1.22 +      return days .. " days " .. secs .. " seconds"
    1.23 +    end
    1.24 +    local target_date = parse.date(timing_string, atom.date)
    1.25 +    if not target_date then
    1.26 +      return false
    1.27 +    end
    1.28 +    local target_timestamp = target_date.midday
    1.29 +    local now = atom.timestamp:get_current()
    1.30 +    trace.debug(target_timestamp, now)
    1.31 +    local duration = target_timestamp - now
    1.32 +    if duration < 0 then
    1.33 +      return false
    1.34 +    end
    1.35 +    return {
    1.36 +      discussion = interval_by_seconds(duration / 7 * 4),
    1.37 +      verification = interval_by_seconds(duration / 7 * 1),
    1.38 +      voting = interval_by_seconds(duration / 7 * 2)
    1.39 +    }
    1.40 +  end,
    1.41 +  available_func = function(policy)
    1.42 +    return { 
    1.43 +      { name = "End of 2013", id = '2013-12-31' },
    1.44 +      { name = "End of 2014", id = '2014-12-31' },
    1.45 +      { name = "End of 2015", id = '2015-12-31' }
    1.46 +    }
    1.47 +  end
    1.48 +}
    1.49 +
    1.50  -- WebMCP accelerator
    1.51  -- uncomment the following two lines to use C implementations of chosen
    1.52  -- functions and to disable garbage collection during the request, to

Impressum / About Us