class VideosController < ApplicationController before_filter :get_rental_unit, :except => [:show] skip_before_filter :redirect_from_params, :only => [:state] skip_before_filter :write_referral, :only => [:state] skip_before_filter :check_fb_friends_ids, :only => [:state] skip_before_filter :set_user_time_zone, :only => [:state] skip_before_filter :check_terms_of_use, :only => [:state] def show @rental_unit = RentalUnit.find(params[:rental_unit_id]) unless @rental_unit.has_video? @upload_info = YoutubeProxy.new.upload_token( {:title => @rental_unit.formatted_title, :description => @rental_unit.youtube_description}, save_rental_unit_video_url(@rental_unit) ) end end def new_show @rental_unit = RentalUnit.find(params[:rental_unit_id]) unless @rental_unit.has_video? @upload_info = YoutubeProxy.new.upload_token( {:title => @rental_unit.formatted_title, :description => @rental_unit.youtube_description}, save_rental_unit_video_url(@rental_unit) ) end respond_to do |format| format.html{render :layout => false} end end def new_save Video.create_from_youtube_callback(@rental_unit, params) flash[:notice] = 'Video was uploaded successfully.' respond_to do |format| format.html{redirect_to new_show_rental_unit_video_path(@rental_unit)} end end def new_destroy @rental_unit.video.destroy flash[:notice] = 'Video was deleted successfully.' respond_to do |format| format.html{redirect_to new_show_rental_unit_video_path(@rental_unit)} format.js end end def new_generate @rental_unit.generate_video flash[:notice] = 'Video was created. It will takes some minutes to upload the video to remote server.' respond_to do |format| format.html{redirect_to new_show_rental_unit_video_url(@rental_unit)} format.js end end def save Video.create_from_youtube_callback(@rental_unit, params) flash[:notice] = 'Video was uploaded successfully.' respond_to do |format| format.html{redirect_to rental_unit_video_path(@rental_unit)} end end def destroy @rental_unit.video.destroy flash[:notice] = 'Video was deleted successfully.' respond_to do |format| format.html{redirect_to rental_unit_video_path(@rental_unit)} format.js end end def generate @rental_unit.generate_video flash[:notice] = 'Video was created. It will takes some minutes to upload the video to remote server.' respond_to do |format| format.html{redirect_to rental_unit_video_url(@rental_unit)} format.js end end def state state = @rental_unit.video ? @rental_unit.video.status : 'false' respond_to do |format| format.html{ render :text => state} format.js{ render :text => state} end end protected def get_rental_unit @rental_unit = current_user.rental_units.find(params[:rental_unit_id]) end end