change videocode to be the listingcode-id

This commit is contained in:
Tyrel Souza 2014-04-30 15:47:48 -04:00
parent 9bdcafd7c0
commit 63044d2499
2 changed files with 6 additions and 7 deletions

View File

@ -8,7 +8,6 @@ class Campaign < ActiveRecord::Base
validates :websiteurl, presence: true validates :websiteurl, presence: true
validates :description, presence: true validates :description, presence: true
validates :productsandservices, presence: true validates :productsandservices, presence: true
# after_save :send_to_better_video
validate :has_at_least_one_videolisting validate :has_at_least_one_videolisting
after_initialize :set_defaults after_initialize :set_defaults
def set_defaults def set_defaults
@ -33,10 +32,4 @@ class Campaign < ActiveRecord::Base
campaigns.to_json campaigns.to_json
end end
# def send_to_better_video
# if self.sent_changed? && self.sent? == true
#
# end
# end
end end

View File

@ -5,6 +5,7 @@ class Videolisting < ActiveRecord::Base
validates :videocode, presence: true, uniqueness: true validates :videocode, presence: true, uniqueness: true
validates :voiceoverselection, presence: true validates :voiceoverselection, presence: true
validates :musicselection, presence: true validates :musicselection, presence: true
after_create :fix_videocode
after_save :send_notification_after_change after_save :send_notification_after_change
after_initialize :set_defaults after_initialize :set_defaults
before_validation :set_videocode before_validation :set_videocode
@ -26,6 +27,11 @@ class Videolisting < ActiveRecord::Base
self.videocode ||= SecureRandom.hex self.videocode ||= SecureRandom.hex
end end
def fix_videocode
self.videocode = "#{self.campaign.listingcode}-#{self.id}"
self.save
end
def set_defaults def set_defaults
self.producttypeid = 721 self.producttypeid = 721
end end