76 lines
2.4 KiB
Ruby
76 lines
2.4 KiB
Ruby
class Admin::VideoProsController < OrbitAdminController
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
|
|
def index
|
|
@tags = @module_app.tags
|
|
@filter_fields = filter_fields(@categories, @tags)
|
|
@video_pro_setting = VideoProSetting.first
|
|
@video_images = VideoImage.order_by(sort).with_categories(filters("category"))
|
|
.with_tags(filters("tag"))
|
|
.with_status(filters("status"))
|
|
@video_images = search_data(@video_images,[:title]).page(params[:page]).per(10)
|
|
@table_fields = [:status, :category, :video_image, :title, "video_pro.postdate", "video_pro.deadline", "video_pro.desc", "video_pro.keyword", "video_pro.post_agency"]
|
|
if request.xhr?
|
|
render :partial=>'index_table'
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@video_image = VideoImage.find(params[:id])
|
|
@item = [['Youtube',"1"],[t('video'),"2"]] #[['Youtube',"1"],[t('video'),"2"],[t('image'),"3"]]
|
|
@item_choose = @video_image.exchange_item
|
|
unless can_edit_or_delete?(@video_image)
|
|
render_401
|
|
end
|
|
end
|
|
|
|
def update
|
|
video_image = VideoImage.find(params[:id])
|
|
video_image.update_user_id = current_user.id.to_s
|
|
video_image.save
|
|
video_image.update_attributes(video_image_params)
|
|
redirect_to params[:referer_url]
|
|
end
|
|
|
|
def new
|
|
@video_image = VideoImage.new
|
|
@item = [['Youtube',"1"],[t('video'),"2"]] #[['Youtube',"1"],[t('video'),"2"],[t('image'),"3"]]
|
|
@tags = @module_app.tags || []
|
|
@video_image.postdate = Date.today
|
|
end
|
|
|
|
def create
|
|
video_image = VideoImage.new(video_image_params)
|
|
video_image.update_user_id = current_user.id.to_s
|
|
video_image.create_user_id = current_user.id.to_s
|
|
video_image.save
|
|
redirect_to params[:referer_url]
|
|
end
|
|
|
|
def destroy
|
|
video_image = VideoImage.find params[:id]
|
|
video_image.destroy
|
|
redirect_to admin_video_pro_path(:page => params[:page])
|
|
end
|
|
|
|
def settings
|
|
@video_pro_setting = VideoProSetting.first
|
|
end
|
|
def update_settings
|
|
@video_pro_setting = VideoProSetting.first
|
|
@video_pro_setting.update_attributes(video_pro_setting_params)
|
|
redirect_to settings_admin_video_pros_path
|
|
end
|
|
|
|
private
|
|
def video_pro_setting_params
|
|
params.require(:video_pro_setting).permit!
|
|
end
|
|
def video_image_params
|
|
params.require(:video_image).permit!
|
|
end
|
|
|
|
def setup_vars
|
|
@module_app = ModuleApp.where(:key => "video_pro").first
|
|
end
|
|
end |