diff options
Diffstat (limited to 'site/app/models/agenda_item.rb')
-rw-r--r-- | site/app/models/agenda_item.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/site/app/models/agenda_item.rb b/site/app/models/agenda_item.rb index f590bb1..0ce60ea 100644 --- a/site/app/models/agenda_item.rb +++ b/site/app/models/agenda_item.rb @@ -7,6 +7,7 @@ class AgendaItem < ActiveRecord::Base discussion :string body :text rejected :boolean, :default => false + timelimits :text, :null => false, :default => '' timestamps end @@ -14,6 +15,8 @@ class AgendaItem < ActiveRecord::Base belongs_to :agenda has_many :voting_options + validate :timelimits_entered_properly + # --- Permissions --- # def create_permitted? return false if acting_user.guest? @@ -50,4 +53,14 @@ class AgendaItem < ActiveRecord::Base return false unless agenda.nil? return acting_user == user if [nil, :title, :discussion, :body].include?(field) end + + protected + def timelimits_entered_properly + regexp = /^\d+:\d+( .*)?$/ + for line in timelimits.split("\n") + unless line.match regexp + errors.add(:timelimits, "Line '#{line}' doensn't match '<minutes>:<seconds> <message>'") + end + end + end end |