vidpush/app/controllers/videolistings_controller.rb
2014-04-24 16:33:48 -04:00

39 lines
1.2 KiB
Ruby

class VideolistingsController < ApplicationController
before_action :set_videolisting, only: [:publish]
def publish
if @videolisting.published?
@message = "Campaign Already Published."
elsif @videolisting.campaign.processed?
@videolisting.published = true
@videolisting.save
@message = "Campaign Published Successfully."
else
@message = "Error: Campaign Not Published."
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_videolisting
videocode = params[:videocode]
if params[:videolisting]
@videolisting = Videolisting.find_by_videocode(params[:videolisting][:videocode]) || not_found
else
@videolisting = Videolisting.find_by_videocode(videocode) || not_found
end
end
# Only allow a trusted parameter "white list" through.
def videolisting_params
params.require(:videolisting).permit(:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls)
end
def not_found
raise ActionController::RoutingError.new("Not Found by video code")
end
end