Updated video cleaned up the ui

This commit is contained in:
saurabhbhatia 2013-07-24 11:47:42 +08:00
parent d701d9d6ad
commit eb853f773d
8 changed files with 126 additions and 36 deletions

View File

@ -3,7 +3,7 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController
before_filter :force_order_for_user,:except => [:index] before_filter :force_order_for_user,:except => [:index]
def index def index
@videos = ChannelVideo.all @channel_videos = ChannelVideo.all
client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
@client_videos = client.videos_by(:user => 'ntuprs', :per_page => 5) @client_videos = client.videos_by(:user => 'ntuprs', :per_page => 5)
@ -14,9 +14,9 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController
end end
def show def show
@video = ChannelVideo.find(params[:id]) @channel_video = ChannelVideo.find(params[:id])
client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
@client_videos = client.videos_by(:user => 'ntuprs', :per_page => 5) @client_videos = client.videos_by(:user => @channel_video.channel_name, :per_page => 5)
respond_to do |format| respond_to do |format|
format.html format.html
@ -25,24 +25,36 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController
end end
def new def new
@video = ChannelVideo.new @channel_video = ChannelVideo.new
end
def edit
@channel_video = ChannelVideo.find(params[:id])
end end
def create def create
@video = ChannelVideo.new(params[:video]) @channel_video = ChannelVideo.new(params[:channel_video])
@video.save!
if @channel_video.save
redirect_to panel_videos_back_end_channel_videos_url redirect_to panel_videos_back_end_channel_videos_url
else
render 'new'
end
end end
def update def update
@video = ChannelVideo.find(params[:id]) @channel_video = ChannelVideo.find(params[:id])
@video.update_attributes(params[:video])
if @channel_video.update_attributes(params[:channel_video])
redirect_to panel_videos_back_end_channel_videos_url redirect_to panel_videos_back_end_channel_videos_url
else
render 'edit'
end
end end
def destroy def destroy
@video = ChannelVideo.find(params[:id]) @channel_video = ChannelVideo.find(params[:id])
@video.destroy @channel_video.destroy
redirect_to panel_videos_back_end_channel_videos_url redirect_to panel_videos_back_end_channel_videos_url
end end

View File

@ -0,0 +1,75 @@
class Panel::Announcement::Widget::VideosController < OrbitWidgetController
def initialize
super
@app_title = 'videos'
end
# GET /bulletins
# GET /bulletins.xml
def index
# @part = PagePart.find(params[:part_id])
# if @part.widget_data_count
# @page_num = @part.widget_data_count
# else
# @page_num = 4
# end
# if @part.widget_field
# @widget_fields = @part.widget_field
# else
# @widget_fields = []
# end
# @title = params[:part_title]
# @widget_style = @part.widget_style
# @category_id = @part.category
# date_now = Time.now
# if !@category_id.blank?
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
# @current_category = BulletinCategory.from_id(@category_id) rescue nil
# elsif !params[:tag_id].blank?
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
# else
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
# end
# get_categorys
end
# def bulletins_list_and_pic
# if params[:widget_data_count]
# @page_num = params[:widget_data_count];
# else
# @page_num = 4;
# end
# @title = params[:part_title]
# date_now = Time.now
# if !params[:category_id].blank?
# @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num )
# @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
# elsif !params[:tag_id].blank?
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
# else
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num )
# end
# get_categorys
# end
# def reload_bulletins
# @selected_tag = Tag.find(params[:tag_id])
# @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil
# end
end

View File

@ -2,5 +2,9 @@ class ChannelVideo
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
attr_accessible :channel_name
field :channel_name field :channel_name
validates_presence_of :channel_name
end end

View File

@ -1,9 +1,9 @@
<br/>
<h2>YouTube Channel</h2>
<div class="control-group"> <div class="control-group">
<label class="control-label" for=""><%= t "name" %></label> <label class="control-label" for=""><%= t "Enter the Name of your YouTube channel" %></label>
<div class="controls"> <div class="controls">
<%= f.fields_for :name_translations do |f| %> <%= f.text_field :channel_name, :class=>'span4', :placeholder => 'Channel Name'%>
<%= f.text_field locale, :class=>'span4', :value => (@location_info.name_translations[locale.to_s] rescue nil) %>
<% end %>
</div> </div>
</div> </div>

View File

@ -1,3 +1,3 @@
<%= form_for @video, :url=> panel_videos_back_end_channel_video_path(@video), :html => { :class=>"form-horizontal"} do |f| %> <%= form_for @channel_video, :url => panel_videos_back_end_channel_video_path, :method => :put, :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>

View File

@ -1,31 +1,30 @@
<br/>
<h3>YouTube Channel</h3>
<table class="table main-list"> <table class="table main-list">
<thead> <thead>
<tr> <tr>
<th class="span1"></th> <th class="span4"><%= t('channel_name') %></th>
<th class="span4"><%= t('videos.show') %></th>
<%if is_manager? %> <%if is_manager? %>
<th class="span1"><%= t('videos.edit') %></th> <th class="span4"><%= t('videos.edit') %></th>
<th class="span1"><%= t('videos.delete') %></th> <th class="span4"><%= t('videos.delete') %></th>
<% end %> <% end %>
</tr> </tr>
</thead> </thead>
<tbody id="tbody_locations" class="sort-holder"> <tbody id="tbody_locations" class="sort-holder">
<% @videos.each do |video| %> <% @channel_videos.each do |video| %>
<% @client_videos.videos.each do |v| %>
<tr class="with_action"> <tr class="with_action">
<% @video = v.video_id.split(/tag:youtube.com,2008:video:+/).last %> <td><%= video.channel_name %></td>
<% @vd = UnvlogIt.new("https://www.youtube.com/watch?v=#{@video}")%> <td><%= link_to 'Show Channel Videos', panel_videos_back_end_channel_video_path(video) %></td>
<td><%= @vd.embed_html(400, 300).html_safe %></td>
<td><%= @vd.title %></td>
<td><%= link_to 'Show', panel_videos_back_end_channel_video_path(video) %></td>
<%if is_manager? %> <%if is_manager? %>
<td><%= link_to 'Edit', edit_panel_videos_back_end_channel_video_path(video) %></td> <td><%= link_to 'Edit', edit_panel_videos_back_end_channel_video_path(video) %></td>
<td><%= link_to 'Destroy', panel_videos_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %></td> <td><%= link_to 'Delete Channel', panel_videos_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %></td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
<% end %>
</tbody> </tbody>
</table> </table>
<%if is_manager? %> <%if is_manager? %>
<td><%= link_to 'New', new_panel_videos_back_end_channel_video_path, :class => "btn btn-primary", :id=>"create_event_btn", :ref=>"add-btn" %></td> <%= link_to 'New', new_panel_videos_back_end_channel_video_path, :class => "btn btn-primary pull-right", :id=>"create_event_btn", :ref=>"add-btn" %>
<% end %> <% end %>

View File

@ -1,3 +1,3 @@
<%= form_for @video, :url=> panel_videos_back_end_channel_videos_path, :html => { :class=>"form-horizontal"} do |f| %> <%= form_for @channel_video, :url => panel_videos_back_end_channel_videos_path, :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>

View File

@ -32,14 +32,14 @@ module Videos
# end # end
side_bar do side_bar do
head_label_i18n 'video.video',:icon_class=>"icon-facetime-video" head_label_i18n 'video.channel',:icon_class=>"icon-facetime-video"
available_for [:admin,:guest,:manager,:sub_manager] available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['videos']}) active_for_controllers ({:private=>['videos']})
head_link_path "panel_videos_back_end_videos_path" head_link_path "panel_videos_back_end_channel_videos_path"
context_link 'video.channel', context_link 'video.videos',
:link_path=>"panel_videos_back_end_channel_videos_path" , :link_path=>"panel_videos_back_end_videos_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{:channel_videos=>:index}, :active_for_action=>{:channel_videos=>:index},
:available_for => [:manager] :available_for => [:manager]