From eb853f773df6b536d3296e043c00220b710764d4 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Wed, 24 Jul 2013 11:47:42 +0800 Subject: [PATCH] Updated video cleaned up the ui --- .../back_end/channel_videos_controller.rb | 36 ++++++--- .../panel/videos/widget/videos_controller.rb | 75 +++++++++++++++++++ .../videos/app/models/channel_video.rb | 4 + .../back_end/channel_videos/_form.html.erb | 8 +- .../back_end/channel_videos/edit.html.erb | 2 +- .../back_end/channel_videos/index.html.erb | 27 ++++--- .../back_end/channel_videos/new.html.erb | 2 +- vendor/built_in_modules/videos/init.rb | 8 +- 8 files changed, 126 insertions(+), 36 deletions(-) create mode 100644 vendor/built_in_modules/videos/app/controllers/panel/videos/widget/videos_controller.rb diff --git a/vendor/built_in_modules/videos/app/controllers/panel/videos/back_end/channel_videos_controller.rb b/vendor/built_in_modules/videos/app/controllers/panel/videos/back_end/channel_videos_controller.rb index 5f716287f..5c1f51753 100644 --- a/vendor/built_in_modules/videos/app/controllers/panel/videos/back_end/channel_videos_controller.rb +++ b/vendor/built_in_modules/videos/app/controllers/panel/videos/back_end/channel_videos_controller.rb @@ -3,7 +3,7 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController before_filter :force_order_for_user,:except => [:index] def index - @videos = ChannelVideo.all + @channel_videos = ChannelVideo.all client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") @client_videos = client.videos_by(:user => 'ntuprs', :per_page => 5) @@ -14,9 +14,9 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController end def show - @video = ChannelVideo.find(params[:id]) + @channel_video = ChannelVideo.find(params[:id]) 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| format.html @@ -25,24 +25,36 @@ class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController end def new - @video = ChannelVideo.new + @channel_video = ChannelVideo.new + end + + def edit + @channel_video = ChannelVideo.find(params[:id]) end def create - @video = ChannelVideo.new(params[:video]) - @video.save! - redirect_to panel_videos_back_end_channel_videos_url + @channel_video = ChannelVideo.new(params[:channel_video]) + + if @channel_video.save + redirect_to panel_videos_back_end_channel_videos_url + else + render 'new' + end end def update - @video = ChannelVideo.find(params[:id]) - @video.update_attributes(params[:video]) - redirect_to panel_videos_back_end_channel_videos_url + @channel_video = ChannelVideo.find(params[:id]) + + if @channel_video.update_attributes(params[:channel_video]) + redirect_to panel_videos_back_end_channel_videos_url + else + render 'edit' + end end def destroy - @video = ChannelVideo.find(params[:id]) - @video.destroy + @channel_video = ChannelVideo.find(params[:id]) + @channel_video.destroy redirect_to panel_videos_back_end_channel_videos_url end diff --git a/vendor/built_in_modules/videos/app/controllers/panel/videos/widget/videos_controller.rb b/vendor/built_in_modules/videos/app/controllers/panel/videos/widget/videos_controller.rb new file mode 100644 index 000000000..ca3f0f040 --- /dev/null +++ b/vendor/built_in_modules/videos/app/controllers/panel/videos/widget/videos_controller.rb @@ -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 diff --git a/vendor/built_in_modules/videos/app/models/channel_video.rb b/vendor/built_in_modules/videos/app/models/channel_video.rb index 56b678a8d..86493e9af 100644 --- a/vendor/built_in_modules/videos/app/models/channel_video.rb +++ b/vendor/built_in_modules/videos/app/models/channel_video.rb @@ -2,5 +2,9 @@ class ChannelVideo include Mongoid::Document include Mongoid::Timestamps + attr_accessible :channel_name + field :channel_name + + validates_presence_of :channel_name end \ No newline at end of file diff --git a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb index e5ee7be31..27c3be5da 100644 --- a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb +++ b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb @@ -1,9 +1,9 @@ +
+

YouTube Channel

- +
- <%= f.fields_for :name_translations do |f| %> - <%= f.text_field locale, :class=>'span4', :value => (@location_info.name_translations[locale.to_s] rescue nil) %> - <% end %> + <%= f.text_field :channel_name, :class=>'span4', :placeholder => 'Channel Name'%>
diff --git a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb index 3416e3ed5..6c3724913 100644 --- a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb +++ b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb @@ -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} %> <% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb index a75e883a4..1a36c4ffe 100644 --- a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb +++ b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb @@ -1,31 +1,30 @@ +
+

YouTube Channel

+ - + + <%if is_manager? %> - - + + <% end %> - <% @videos.each do |video| %> - <% @client_videos.videos.each do |v| %> + <% @channel_videos.each do |video| %> - <% @video = v.video_id.split(/tag:youtube.com,2008:video:+/).last %> - <% @vd = UnvlogIt.new("https://www.youtube.com/watch?v=#{@video}")%> - - - + + <%if is_manager? %> - - <%end%> + + <% end %> - <%end%> <% end %>
<%= t('channel_name') %><%= t('videos.show') %><%= t('videos.edit') %><%= t('videos.delete') %><%= t('videos.edit') %><%= t('videos.delete') %>
<%= @vd.embed_html(400, 300).html_safe %><%= @vd.title %><%= link_to 'Show', panel_videos_back_end_channel_video_path(video) %><%= video.channel_name %><%= link_to 'Show Channel Videos', panel_videos_back_end_channel_video_path(video) %><%= link_to 'Edit', edit_panel_videos_back_end_channel_video_path(video) %><%= link_to 'Destroy', panel_videos_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %><%= link_to 'Delete Channel', panel_videos_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %>
<%if is_manager? %> -<%= link_to 'New', new_panel_videos_back_end_channel_video_path, :class => "btn btn-primary", :id=>"create_event_btn", :ref=>"add-btn" %> +<%= 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 %> diff --git a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb index bc400850b..4f74e3a92 100644 --- a/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb +++ b/vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb @@ -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} %> <% end %> diff --git a/vendor/built_in_modules/videos/init.rb b/vendor/built_in_modules/videos/init.rb index 49ae90d86..560f0d90f 100644 --- a/vendor/built_in_modules/videos/init.rb +++ b/vendor/built_in_modules/videos/init.rb @@ -32,14 +32,14 @@ module Videos # end 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] 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', - :link_path=>"panel_videos_back_end_channel_videos_path" , + context_link 'video.videos', + :link_path=>"panel_videos_back_end_videos_path" , :priority=>1, :active_for_action=>{:channel_videos=>:index}, :available_for => [:manager]