video/app/controllers/admin/video_channels_controller.rb

54 lines
1.3 KiB
Ruby
Raw Normal View History

2015-08-31 09:46:03 +00:00
class Admin::VideoChannelsController < OrbitAdminController
def index
@table_fields = [:title,:category,t('video.owner')]
@video_channels = VideoChannel.all
@tags = @module_app.tags
@categories = @module_app.categories
@filter_fields = filter_fields(@categories, @tags)
@video_channels = VideoChannel.order_by(sort).with_categories(filters("category")).with_tags(filters("tag"))
end
def new
@video_channel = VideoChannel.new
@tags = @module_app.tags
@categories = @module_app.categories
end
def create
@video_channel = VideoChannel.new(video_channel_vars)
@video_channel.save
redirect_to admin_video_channels_path
end
def edit
@video_channel = VideoChannel.find(params[:id])
if can_edit_or_delete?(@video_channel)
@tags = @module_app.tags
@categories = @module_app.categories
else
render_401
end
end
def update
video_channel = VideoChannel.find(params[:id])
video_channel.update_attributes(video_channel_vars)
video_channel.save
redirect_to admin_video_channels_path
end
def destroy
video_channel = VideoChannel.find(params[:id])
video_channel.destroy
redirect_to admin_video_channels_path
end
def setup_vars
@module_app = ModuleApp.where(:key => "video").first
end
def video_channel_vars
params.require(:video_channel).permit!
end
end