summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-12 11:23:57 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-12 11:23:57 +0100
commitb16aeeccff8de5fd579d79a48740df7a3e34e7bc (patch)
treebb2ddcb29c6a465d73a3010437bdd076d11360c9 /app/models
parent3c5a0511d228fb3dc00ae860ade1b8ff032cc42f (diff)
parent40b2feb99d75074319f371087c521df198527266 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/models')
-rw-r--r--app/models/conference.rb12
-rw-r--r--app/models/conference_invitee.rb18
2 files changed, 17 insertions, 13 deletions
diff --git a/app/models/conference.rb b/app/models/conference.rb
index aee75d5..6c89d60 100644
--- a/app/models/conference.rb
+++ b/app/models/conference.rb
@@ -7,6 +7,12 @@ class Conference < ActiveRecord::Base
has_many :conference_invitees, :dependent => :destroy
has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy
+ before_validation {
+ if !self.pin.blank?
+ self.pin = self.pin.to_s.gsub(/[^0-9]/, '')
+ end
+ }
+
validates_presence_of :conferenceable_type, :conferenceable_id
validates_presence_of :conferenceable
validates_presence_of :name
@@ -21,15 +27,12 @@ class Conference < ActiveRecord::Base
validates_inclusion_of :open_for_anybody, :in => [true, false]
- validates_numericality_of :pin, :only_integer => true,
- :greater_than => 0,
- :allow_nil => true,
- :allow_blank => true
validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')),
:allow_nil => true,
:allow_blank => true
validate :start_and_end_dates_must_make_sense, :if => Proc.new { |conference| !conference.start.blank? && !conference.end.blank? }
+
before_save :send_pin_email_when_pin_has_changed
@@ -50,7 +53,6 @@ class Conference < ActiveRecord::Base
private
def start_and_end_dates_must_make_sense
- errors.add(:start, 'must be in the future') if self.start < Time.now - 10.minutes
errors.add(:end, 'must be later than the start') if self.end < self.start
end
diff --git a/app/models/conference_invitee.rb b/app/models/conference_invitee.rb
index d6e3bac..6a1349e 100644
--- a/app/models/conference_invitee.rb
+++ b/app/models/conference_invitee.rb
@@ -1,21 +1,23 @@
class ConferenceInvitee < ActiveRecord::Base
attr_accessible :pin, :speaker, :moderator, :phone_number, :phone_number_attributes
-
+
belongs_to :conference
belongs_to :phone_book_entry
has_one :phone_number, :as => :phone_numberable, :dependent => :destroy
accepts_nested_attributes_for :phone_number
+ before_validation {
+ if !self.pin.blank?
+ self.pin = self.pin.to_s.gsub(/[^0-9]/, '')
+ end
+ }
+
validates_presence_of :conference_id
validates_presence_of :conference
validates_presence_of :phone_number
- validates_numericality_of :pin, :only_integer => true,
- :greater_than => 0,
- :allow_nil => true,
- :allow_blank => true
- validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')),
- :allow_nil => true,
- :allow_blank => true
+ validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')),
+ :allow_nil => true,
+ :allow_blank => true
validates_inclusion_of :speaker, :in => [true, false]
validates_inclusion_of :moderator, :in => [true, false]