class Event < ActiveRecord::Base

#   scope :current, joins('event').where(:event => {:year => Event.current.year})

  def self.current
    Event.find_by_year(Time.now.year) || Event.order(:year).last
  end

  def poplatek
    if zaloha.nil? and startovne.nil?
      nil
    else
      zaloha.to_i+startovne.to_i
    end
  end

  # whether the event has already finished registration due to time or cappacity or any other limit
  def registrace_ukoncena
    true
  end

  def self.current_year
    e = self.current
    if e.nil?
      9999
    else
      e.year
    end
  end

end
