Class Admin::VideosController
In: app/controllers/admin/videos_controller.rb
Parent: Sadmin::BaseController

Methods

Public Instance methods

[Source]

     # File app/controllers/admin/videos_controller.rb, line 116
116:   def auto_complete_for_video_tag_list_es
117:     auto_complete_for_tag_list(params[:video][:tag_list_es])
118:     if @tags.length > 0
119:       render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
120:     else
121:       render :nothing => true
122:     end  
123:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 41
41:   def create
42:     @title = "Crear video"
43:     @video = Video.new(params[:video])
44:     
45:     if @video.save
46:       flash[:notice] = 'El video se ha guardado correctamente'
47:       submit_to_ubervu(@video)
48:       redirect_to admin_video_path(@video)
49:     else
50:       render :action => 'new'
51:     end
52:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 71
71:   def destroy
72:     @video = Video.find(params[:id])
73:     if @video.destroy
74:       flash[:notice] = "El video ha sido eliminado"
75:       redirect_to admin_videos_path
76:     else
77:       flash[:error] = "No hemos podido eliminar el video"
78:       redirect_to admin_video_path(@video)
79:     end
80:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 54
54:   def edit
55:     @title = "Modificar video"
56:     @video = Video.find(params[:id])
57:   end

[Source]

     # File app/controllers/admin/videos_controller.rb, line 83
 83:   def find_video
 84:     v = Video.new(:video_path => params[:video_path])
 85:     if !v.valid? && v.errors.on("video_path")
 86:       render :update do |page|
 87:         page.replace_html :find_video, :text => "<span style='color:red'>Directorio incorrecto.<br/> #{v.errors.on('video_path')}</span>"
 88:       end
 89:     else        
 90:       logger.info "Buscando videos en #{Video::VIDEO_PATH + params[:video_path] + '*.flv'}"
 91:       found_videos = Video.videos_in_dir(params[:video_path])
 92:       if found_videos.length > 0
 93:         found_preview_photo = File.exists?("#{Video::VIDEO_PATH + params[:video_path]}.jpg")
 94:         render :update do |page|
 95:           page.replace_html :find_video, :text => "<span style='color:green'>#{found_videos.length} videos encontrados</span>"
 96:           if found_preview_photo
 97:             page.insert_html :bottom, :find_video, :text => ". <span style='color:green'>Foto para el preview encontrada</span>"
 98:           else
 99:             page.insert_html :bottom, :find_video, :text => ". <span style='color:red'>Foto para el preview NO encontrada</span>"
100:           end
101:         end
102:       else
103:         if File.exists?("#{Video::VIDEO_PATH + params[:video_path]}.jpg")
104:           render :update do |page|
105:             page.replace_html :find_video, :text => "<span style='color:green'>1 imagen encontrada</span>"
106:           end
107:         else
108:           render :update do |page|
109:             page.replace_html :find_video, :text => "<span style='color:red'>video NO encontrado</span>"
110:           end
111:         end
112:       end
113:     end
114:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 6
 6:   def index
 7:     @sort_order = params[:sort] ||  "update"
 8:     
 9:     case @sort_order
10:     when "update"
11:       order = "updated_at DESC, title_es, published_at DESC"
12:     when "publish"
13:       order = "published_at DESC, title_es, updated_at DESC"
14:     when "title"
15:       order = "lower(tildes(title_es)), published_at DESC, updated_at DESC"
16:     end
17:     
18:     conditions = []
19:     if params[:q].present?
20:       conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like '%#{params[:q].tildes.downcase}%'"
21:     end   
22: 
23:     @videos = Video.paginate :page => params[:page], :per_page => 20, 
24:       :order => order,
25:       :conditions => conditions.join(' AND ')
26: 
27:     @title = "Videos"
28:     
29:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 36
36:   def new
37:     @title = "Nuevo video"
38:     @video = Video.new
39:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 31
31:   def show
32:     @video = Video.find(params[:id])
33:     @title = @video.title
34:   end

[Source]

    # File app/controllers/admin/videos_controller.rb, line 59
59:   def update
60:     @video = Video.find(params[:id])
61:     
62:     if @video.update_attributes(params[:video])
63:       flash[:notice] = 'El documento se ha guardado correctamente'
64:       submit_to_ubervu(@video)
65:       redirect_to admin_video_path(@video)
66:     else
67:       render :action => params[:return_to] || 'edit'
68:     end
69:   end

[Validate]