liquid_feedback_frontend

diff app/main/initiative/_action/create.lua @ 1092:5b65ea5c24f5

Fixed free timings in poll mode
author bsw
date Fri Oct 17 13:03:31 2014 +0200 (2014-10-17)
parents 701a5cf6b067
children 9604ba51624a
line diff
     1.1 --- a/app/main/initiative/_action/create.lua	Fri Oct 17 11:30:09 2014 +0200
     1.2 +++ b/app/main/initiative/_action/create.lua	Fri Oct 17 13:03:31 2014 +0200
     1.3 @@ -98,11 +98,42 @@
     1.4    end
     1.5  end
     1.6  
     1.7 +local timing
     1.8 +if policy.free_timeable then
     1.9 +  local free_timing_string = util.trim(param.get("free_timing"))
    1.10 +  if not free_timing_string or #free_timing_string < 1 then
    1.11 +    slot.put_into("error", _"Choose timing")
    1.12 +    return false
    1.13 +  end
    1.14 +  local available_timings
    1.15 +  if config.free_timing and config.free_timing.available_func then
    1.16 +    available_timings = config.free_timing.available_func(policy)
    1.17 +    if available_timings == false then
    1.18 +      error("error in free timing config")
    1.19 +    end
    1.20 +  end
    1.21 +  if available_timings then
    1.22 +    local timing_available = false
    1.23 +    for i, available_timing in ipairs(available_timings) do
    1.24 +      if available_timing.id == free_timing_string then
    1.25 +	timing_available = true
    1.26 +      end
    1.27 +    end
    1.28 +    if not timing_available then
    1.29 +      slot.put_into("error", _"Invalid timing")
    1.30 +      return false
    1.31 +    end
    1.32 +  end
    1.33 +  timing = config.free_timing.calculate_func(policy, free_timing_string)
    1.34 +  if not timing then
    1.35 +    error("error in free timing config")
    1.36 +  end
    1.37 +end
    1.38 +
    1.39  if param.get("preview") or param.get("edit") then
    1.40    return
    1.41  end
    1.42  
    1.43 -
    1.44  local initiative = Initiative:new()
    1.45  
    1.46  if not issue then
    1.47 @@ -116,29 +147,6 @@
    1.48      initiative.polling = true
    1.49      
    1.50      if policy.free_timeable then
    1.51 -      local free_timing_string = util.trim(param.get("free_timing"))
    1.52 -      local available_timings
    1.53 -      if config.free_timing and config.free_timing.available_func then
    1.54 -        available_timings = config.free_timing.available_func(policy)
    1.55 -        if available_timings == false then
    1.56 -          error("error in free timing config")
    1.57 -        end
    1.58 -      end
    1.59 -      if available_timings then
    1.60 -        local timing_available = false
    1.61 -        for i, available_timing in ipairs(available_timings) do
    1.62 -          if available_timing.id == free_timing_string then
    1.63 -            timing_available = true
    1.64 -          end
    1.65 -        end
    1.66 -        if not timing_available then
    1.67 -          error('Invalid timing')
    1.68 -        end
    1.69 -      end
    1.70 -      local timing = config.free_timing.calculate_func(policy, free_timing_string)
    1.71 -      if not timing then
    1.72 -        error("error in free timing config")
    1.73 -      end
    1.74        issue.discussion_time = timing.discussion
    1.75        issue.verification_time = timing.verification
    1.76        issue.voting_time = timing.voting

Impressum / About Us