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