Validations for at least one video listing
This commit is contained in:
parent
1acbe34d77
commit
e7c66e9c16
@ -7,7 +7,7 @@ class VideolistingsController < ApplicationController
|
||||
elsif @videolisting.campaign.processed?
|
||||
@videolisting.published = true
|
||||
@videolisting.save
|
||||
#TODO: SEND OUT EMAIL HERE.
|
||||
|
||||
@message = "Campaign Published Successfully."
|
||||
else
|
||||
@message = "Error: Campaign Not Published."
|
||||
@ -29,4 +29,7 @@ class VideolistingsController < ApplicationController
|
||||
def videolisting_params
|
||||
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
@ -6,15 +6,23 @@ class Campaign < ActiveRecord::Base
|
||||
validates :websiteurl, presence: true
|
||||
validates :description, presence: true
|
||||
validates :productsandservices, presence: true
|
||||
after_save :send_to_better_video
|
||||
validate :has_at_least_one_videolisting
|
||||
|
||||
|
||||
def has_at_least_one_videolisting
|
||||
errors.add(:base, 'Must add at least one Videolisting') if self.videolistings.blank?
|
||||
end
|
||||
|
||||
|
||||
def init
|
||||
self.clientid = 720
|
||||
end
|
||||
|
||||
after_create :send_to_better_video
|
||||
def send_to_better_video
|
||||
#TODO Make API Calls
|
||||
if self.processed_changed? && self.processed == true
|
||||
#TODO Make API Calls
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,6 +3,7 @@ class Videolisting < ActiveRecord::Base
|
||||
validates :videocode, presence: true, uniqueness: true
|
||||
validates :voiceoverselection, presence: true
|
||||
validates :musicselection, presence: true
|
||||
after_save :send_notification_after_change
|
||||
|
||||
def init
|
||||
self.producttypeid = 721
|
||||
@ -12,4 +13,10 @@ class Videolisting < ActiveRecord::Base
|
||||
def asseturls_array
|
||||
self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
|
||||
end
|
||||
|
||||
def send_notification_after_change
|
||||
if self.published_changed? && self.published == true
|
||||
#TODO: SEND OUT EMAIL HERE.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,7 @@
|
||||
<span><%= videolisting.notes %></span>
|
||||
</span>
|
||||
<span class="videolisting-item">
|
||||
<strong>asseturls</strong>
|
||||
<strong>Asset URLs</strong>
|
||||
|
||||
<% videolisting.asseturls_array.each do |asset| %>
|
||||
<span class="list-item"><%= asset[:asseturl] %></span>
|
||||
|
Loading…
Reference in New Issue
Block a user