voting period is open when voting dates are not set

This commit is contained in:
differentreality 2016-08-17 15:55:10 +03:00 committed by Stella Rouzi
parent d07de3ca88
commit ea868d4cc7
3 changed files with 6 additions and 6 deletions

View file

@ -72,16 +72,16 @@ class Program < ActiveRecord::Base
def show_voting?
return true unless blind_voting
Date.today > voting_end_date
Time.current > voting_end_date
end
##
# Checks if we are still in voting period
# ====Returns
# * +true+ -> If the voting period is not over yet
# * +true+ -> If the voting period is not over yet (or if the voting dates are not set)
# * +false+ -> If the voting period is over
def voting_period?
return false unless voting_start_date && voting_end_date
return true unless voting_start_date && voting_end_date
(voting_start_date.to_datetime..voting_end_date.to_datetime).cover? Time.current
end