category disable for backend
This commit is contained in:
parent
c5fdff764e
commit
56caf4b34e
|
@ -154,15 +154,17 @@ class OrbitBackendController< ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def get_viewable(object_class)
|
def get_viewable(object_class, query=nil)
|
||||||
objects = get_objects(object_class).order_by(:created_at, :desc)
|
objects = get_objects(object_class,query).order_by(:created_at, :desc)
|
||||||
Kaminari.paginate_array(objects).page(params[:page]).per(10)
|
Kaminari.paginate_array(objects).page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_objects(object_class, query=nil)
|
def get_objects(object_class, query=nil)
|
||||||
object_class = object_class.classify.constantize
|
object_class = object_class.classify.constantize
|
||||||
|
# debugger
|
||||||
|
# a=1
|
||||||
if query
|
if query
|
||||||
objects = object_class.all.where(query)
|
objects = object_class.where(query)
|
||||||
else
|
else
|
||||||
objects = object_class.all
|
objects = object_class.all
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,10 +6,10 @@ $mid_site_connection
|
||||||
module MiddleSiteConnection
|
module MiddleSiteConnection
|
||||||
|
|
||||||
@mid_host = {
|
@mid_host = {
|
||||||
:host => 'mruling.nccu.edu.tw', #mruling.nccu.edu.tw or 127.0.0.1
|
:host => '127.0.0.1', #mruling.nccu.edu.tw or 127.0.0.1
|
||||||
:port => 3306, #3306 or 8005
|
:port => 8005, #3306 or 8005
|
||||||
:username => "rulingcom",
|
:username => "root",
|
||||||
:password => "5w3iJQ9OJQMGhJibKP6YQje8",
|
:password => "a3G6yWd9",
|
||||||
:database => "RSS23_NCCU_MIDDLE",
|
:database => "RSS23_NCCU_MIDDLE",
|
||||||
:encoding => "UTF8"
|
:encoding => "UTF8"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,44 @@
|
||||||
module OrbitControllerLib
|
module OrbitControllerLib
|
||||||
module DivisionForDisable
|
module DivisionForDisable
|
||||||
def get_disable_object_by_user(object_class)
|
# def get_disable_object_by_user(object_class)
|
||||||
if is_admin? or is_manager?
|
# if is_admin? or is_manager?
|
||||||
object_class.admin_manager_all
|
# object_class.admin_manager_all
|
||||||
else
|
# else
|
||||||
object_class.all
|
# object_class.all
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
def get_categories_for_index(object_class,id = nil)
|
||||||
|
class_ref = object_class.constantize
|
||||||
|
ivar_name = "@#{object_class.to_s.underscore.pluralize}"
|
||||||
|
instance_variable_set(ivar_name, [])
|
||||||
|
if(is_manager? || is_admin?)
|
||||||
|
instance_variable_set(ivar_name, (id ? class_ref.admin_manager_all.find(id).to_a : class_ref.admin_manager_all))
|
||||||
|
elsif is_sub_manager?
|
||||||
|
instance_variable_set(ivar_name, (class_ref.all))
|
||||||
|
end
|
||||||
|
instance_variable_get(ivar_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_categorys(object_class,id = nil,func_authed_for_sub_manager = 'submit')
|
||||||
|
class_ref = object_class.constantize
|
||||||
|
# ivar_name = "@#{object_class.to_s.underscore.pluralize}"
|
||||||
|
ivar_name = "@#{object_class.to_s.underscore}s"
|
||||||
|
instance_variable_set(ivar_name, [])
|
||||||
|
@bulletin_categorys = []
|
||||||
|
if(is_manager? || is_admin?)
|
||||||
|
#instance_variable_set(ivar_name, (id ? class_ref.admin_manager_all.find(id).to_a : class_ref.admin_manager_all))
|
||||||
|
instance_variable_set(ivar_name, (id ? class_ref.all.find(id).to_a : class_ref.all))
|
||||||
|
elsif is_sub_manager?
|
||||||
|
instance_variable_set(ivar_name, class_ref.all.authed_for_user(current_user,func_authed_for_sub_manager))
|
||||||
|
end
|
||||||
|
if instance_variable_get(ivar_name).empty? && params[:action] != "index"
|
||||||
|
flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
|
||||||
|
redirect_to :action => :index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,13 +5,24 @@ module OrbitCoreLib
|
||||||
base.instance_eval("field :disable,type: Boolean,:default => false")
|
base.instance_eval("field :disable,type: Boolean,:default => false")
|
||||||
base.instance_eval("scope :all,where(disable: false)")
|
base.instance_eval("scope :all,where(disable: false)")
|
||||||
base.instance_eval("scope :admin_manager_all,find(:all)")
|
base.instance_eval("scope :admin_manager_all,find(:all)")
|
||||||
|
|
||||||
base.define_singleton_method :find do |*args|
|
base.define_singleton_method :find do |*args|
|
||||||
if args ==[:all]
|
if args ==[:all]
|
||||||
unscoped
|
unscoped
|
||||||
else
|
else
|
||||||
unscoped.find(args)
|
res = unscoped.find(args)
|
||||||
|
res.count == 1 ? res[0] : res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
base.define_singleton_method :first do |*args|
|
||||||
|
all.first
|
||||||
|
end
|
||||||
|
|
||||||
|
base.define_singleton_method :last do |*args|
|
||||||
|
all.last
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
module ObjectAuthable
|
module ObjectAuthable
|
||||||
|
|
|
@ -51,12 +51,12 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
||||||
object_auth
|
object_auth
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_categorys(id = nil)
|
# def get_categorys(id = nil)
|
||||||
@bulletin_categorys = []
|
# @bulletin_categorys = []
|
||||||
if(is_manager? || is_admin?)
|
# if(is_manager? || is_admin?)
|
||||||
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
# @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
||||||
elsif is_sub_manager?
|
# elsif is_sub_manager?
|
||||||
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
# @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,9 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
|
||||||
before_filter :for_app_manager,:except => [:index]
|
before_filter :for_app_manager,:except => [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bulletin_categorys = BulletinCategory.all
|
@bulletin_categorys = get_categories_for_index("BulletinCategory")
|
||||||
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
||||||
@bulletin_category = BulletinCategory.new(:display => 'List')
|
@bulletin_category = BulletinCategory.new(:display => 'List')
|
||||||
|
|
||||||
@url = panel_announcement_back_end_bulletin_categorys_path
|
@url = panel_announcement_back_end_bulletin_categorys_path
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -108,7 +107,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
|
||||||
# DELETE /bulletins/1
|
# DELETE /bulletins/1
|
||||||
# DELETE /bulletins/1.xml
|
# DELETE /bulletins/1.xml
|
||||||
def destroy
|
def destroy
|
||||||
@bulletin_category = BulletinCategory.find(params[:id]).first
|
@bulletin_category = BulletinCategory.find(params[:id])
|
||||||
@bulletin_category.disable = @bulletin_category.disable ? false : true
|
@bulletin_category.disable = @bulletin_category.disable ? false : true
|
||||||
|
|
||||||
if @bulletin_category.save!
|
if @bulletin_category.save!
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
include AdminHelper
|
include AdminHelper
|
||||||
|
include OrbitControllerLib::DivisionForDisable
|
||||||
|
|
||||||
layout 'new_admin'
|
layout 'new_admin'
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :get_categorys ,:only => [ :new,:edit,:update]
|
before_filter :only => [ :new,:edit,:update] do |controller|
|
||||||
|
controller.get_categorys('BulletinCategory')
|
||||||
|
end
|
||||||
# before_filter :for_admin_only,:only => [:]
|
# before_filter :for_admin_only,:only => [:]
|
||||||
# before_filter :for_app_manager,:only => [:index,:show,]
|
# before_filter :for_app_manager,:only => [:index,:show,]
|
||||||
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
|
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
|
||||||
def index
|
def index
|
||||||
# @bulletins = Bulletin.all
|
# @bulletins = Bulletin.all
|
||||||
# @bulletins = Bulletin.desc("postdate desc")
|
# @bulletins = Bulletin.desc("postdate desc")
|
||||||
get_categorys(params[:bulletin_category_id])
|
get_categorys('BulletinCategory',params[:bulletin_category_id])
|
||||||
get_tags
|
get_tags
|
||||||
|
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
|
@ -35,11 +39,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# @bulletins = Bulletin.search(params[:search], params[:category_id])
|
# @bulletins = Bulletin.search(params[:search], params[:category_id])
|
||||||
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
|
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
|
||||||
|
|
||||||
|
|
||||||
# @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10)
|
# @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10)
|
||||||
@bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin") : get_viewable("bulletin")
|
@bulletin_categories = get_categories_for_index("BulletinCategory")
|
||||||
@bulletin_categories = BulletinCategory.all
|
@bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
|
||||||
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
|
||||||
|
@bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin",:bulletin_category_id.in => @bulletin_category_ids) : get_viewable("bulletin",:bulletin_category_id.in => @bulletin_category_ids)
|
||||||
|
|
||||||
@bulletin_link = BulletinLink.new
|
@bulletin_link = BulletinLink.new
|
||||||
@link_url = panel_announcement_back_end_bulletins_path
|
@link_url = panel_announcement_back_end_bulletins_path
|
||||||
|
@ -327,19 +331,28 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_categorys(id = nil)
|
# def get_categories_for_index(id = nil)
|
||||||
@bulletin_categorys = []
|
# @bulletin_categories = []
|
||||||
#@unit_list_for_anc = UnitListForAnc.all
|
# if(is_manager? || is_admin?)
|
||||||
if(is_manager? || is_admin?)
|
# @bulletin_categories = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
|
||||||
@bulletin_categorys = (id ? BulletinCategory.all.find(id).to_a : BulletinCategory.all)
|
# elsif is_sub_manager?
|
||||||
elsif is_sub_manager?
|
# @bulletin_categories = BulletinCategory.all
|
||||||
@bulletin_categorys = BulletinCategory.all.authed_for_user(current_user,'submit')
|
# end
|
||||||
end
|
# @bulletin_categories
|
||||||
if @bulletin_categorys.empty? && params[:action] != "index"
|
# end
|
||||||
flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
|
|
||||||
redirect_to :action => :index
|
# def get_categorys(id = nil)
|
||||||
end
|
# @bulletin_categorys = []
|
||||||
end
|
# if(is_manager? || is_admin?)
|
||||||
|
# @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
|
||||||
|
# elsif is_sub_manager?
|
||||||
|
# @bulletin_categorys = BulletinCategory.all.authed_for_user(current_user,'submit')
|
||||||
|
# end
|
||||||
|
# if @bulletin_categorys.empty? && params[:action] != "index"
|
||||||
|
# flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
|
||||||
|
# redirect_to :action => :index
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
|
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController
|
class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController
|
||||||
|
include OrbitControllerLib::DivisionForDisable
|
||||||
before_filter :for_app_manager,:except => [:index]
|
before_filter :for_app_manager,:except => [:index]
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@news_bulletin_categorys = get_disable_object_by_user(NewsBulletinCategory)
|
@news_bulletin_categorys = get_categories_for_index("NewsBulletinCategory")
|
||||||
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
||||||
|
|
||||||
@news_bulletin_category = NewsBulletinCategory.new(:display => 'List')
|
@news_bulletin_category = NewsBulletinCategory.new(:display => 'List')
|
||||||
|
@ -110,7 +110,7 @@ class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendContro
|
||||||
# DELETE /news_bulletins/1
|
# DELETE /news_bulletins/1
|
||||||
# DELETE /news_bulletins/1.xml
|
# DELETE /news_bulletins/1.xml
|
||||||
def destroy
|
def destroy
|
||||||
@news_bulletin_category = NewsBulletinCategory.find(params[:id]).first
|
@news_bulletin_category = NewsBulletinCategory.find(params[:id])
|
||||||
@news_bulletin_category.disable = @news_bulletin_category.disable ? false : true
|
@news_bulletin_category.disable = @news_bulletin_category.disable ? false : true
|
||||||
|
|
||||||
if @news_bulletin_category.save!
|
if @news_bulletin_category.save!
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
|
include OrbitControllerLib::DivisionForDisable
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
# before_filter :for_admin_only,:only => [:]
|
# before_filter :for_admin_only,:only => [:]
|
||||||
# before_filter :for_app_manager,:only => [:index,:show,]
|
# before_filter :for_app_manager,:only => [:index,:show,]
|
||||||
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_news_bulletins]
|
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_news_bulletins]
|
||||||
before_filter :get_categorys ,:only => [ :new,:edit,:update]
|
before_filter :only => [ :new,:edit,:update] do |controller|
|
||||||
|
controller.get_categorys('NewsBulletinCategory')
|
||||||
|
controller.get_unit_list
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @news_bulletins = NewsBulletin.all
|
# @news_bulletins = NewsBulletin.all
|
||||||
# @news_bulletins = NewsBulletin.desc("postdate desc")
|
# @news_bulletins = NewsBulletin.desc("postdate desc")
|
||||||
get_categorys(params[:news_bulletin_category_id])
|
get_categorys("NewsBulletinCategory",params[:news_bulletin_category_id])
|
||||||
get_tags
|
get_tags
|
||||||
|
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
|
@ -37,9 +41,12 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
|
|
||||||
|
|
||||||
# @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_news_bulletins : NewsBulletin.all.page(params[:page]).per(10)
|
# @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_news_bulletins : NewsBulletin.all.page(params[:page]).per(10)
|
||||||
@news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin") : get_viewable("news_bulletin")
|
|
||||||
@news_bulletin_categories = NewsBulletinCategory.all
|
@news_bulletin_categories = get_categories_for_index("NewsBulletinCategory")
|
||||||
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
@news_bulletin_category_ids = @news_bulletin_categories.collect{|t| t.id.to_s} + [nil]
|
||||||
|
|
||||||
|
|
||||||
|
@news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) : get_viewable("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids)
|
||||||
|
|
||||||
@news_bulletin_link = NewsBulletinLink.new
|
@news_bulletin_link = NewsBulletinLink.new
|
||||||
@link_url = panel_news_back_end_news_bulletins_path
|
@link_url = panel_news_back_end_news_bulletins_path
|
||||||
|
@ -315,20 +322,32 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_categorys(id = nil)
|
# def get_categories_for_index(id = nil)
|
||||||
@news_bulletin_categorys = []
|
# @news_bulletin_categories = []
|
||||||
@unit_list_for_anc = UnitListForAnc.all
|
# if(is_manager? || is_admin?)
|
||||||
if(is_manager? || is_admin?)
|
# @news_bulletin_categories = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all)
|
||||||
@news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.all)
|
# elsif is_sub_manager?
|
||||||
elsif is_sub_manager?
|
# @news_bulletin_categories = NewsBulletinCategory.all
|
||||||
@news_bulletin_categorys = NewsBulletinCategory.all.authed_for_user(current_user,'submit')
|
# end
|
||||||
end
|
# @news_bulletin_categories
|
||||||
if @news_bulletin_categorys.empty? && params[:action] != "index"
|
# end
|
||||||
flash[:alert] = t("news.error.no_avilb_cate_for_posting")
|
|
||||||
redirect_to :action => :index
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# def get_categorys(id = nil)
|
||||||
|
# @news_bulletin_categorys = []
|
||||||
|
# @unit_list_for_anc = UnitListForAnc.all
|
||||||
|
# if(is_manager? || is_admin?)
|
||||||
|
# @news_bulletin_categorys = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all)
|
||||||
|
# elsif is_sub_manager?
|
||||||
|
# @news_bulletin_categorys = NewsBulletinCategory.all.authed_for_user(current_user,'submit')
|
||||||
|
# end
|
||||||
|
# if @news_bulletin_categorys.empty? && params[:action] != "index"
|
||||||
|
# flash[:alert] = t("news.error.no_avilb_cate_for_posting")
|
||||||
|
# redirect_to :action => :index
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
def get_unit_list
|
||||||
|
@unit_list_for_anc = UnitListForAnc.all
|
||||||
|
end
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
module_app = ModuleApp.first(:conditions => {:key => 'news'})
|
module_app = ModuleApp.first(:conditions => {:key => 'news'})
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController
|
class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController
|
||||||
before_filter :for_app_manager,:except => [:index]
|
before_filter :for_app_manager,:except => [:index]
|
||||||
|
include OrbitControllerLib::DivisionForDisable
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@web_link_categorys = WebLinkCategory.all
|
@web_link_categorys = get_categories_for_index("WebLinkCategory")
|
||||||
@web_link_category = WebLinkCategory.new(:display => 'List')
|
@web_link_category = WebLinkCategory.new(:display => 'List')
|
||||||
|
|
||||||
@url = panel_web_resource_back_end_web_link_categorys_path
|
@url = panel_web_resource_back_end_web_link_categorys_path
|
||||||
|
@ -86,12 +87,18 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendCont
|
||||||
# DELETE /web_links/1.xml
|
# DELETE /web_links/1.xml
|
||||||
def destroy
|
def destroy
|
||||||
@web_link_category = WebLinkCategory.find(params[:id])
|
@web_link_category = WebLinkCategory.find(params[:id])
|
||||||
@web_link_category.destroy
|
@web_link_category.disable = @web_link_category.disable ? false : true
|
||||||
|
|
||||||
respond_to do |format|
|
if @web_link_category.save!
|
||||||
format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) }
|
respond_to do |format|
|
||||||
# format.xml { head :ok }
|
format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) }
|
||||||
format.js
|
# format.xml { head :ok }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
else
|
||||||
|
flash[:error] = t("web_link_category.update_failed")
|
||||||
|
format.html { render :action => "index" }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||||
|
include OrbitControllerLib::DivisionForDisable
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
# before_filter :for_app_manager,:except => [:index,:show]
|
# before_filter :for_app_manager,:except => [:index,:show]
|
||||||
before_filter :for_app_sub_manager,:except => [:index]
|
before_filter :for_app_sub_manager,:except => [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
get_categorys(params[:web_link_category_id])
|
get_categorys("WebLinkCategory",params[:web_link_category_id])
|
||||||
|
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
new_filter = params[:new_filter]
|
new_filter = params[:new_filter]
|
||||||
|
|
||||||
|
@ -23,11 +23,14 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||||
elsif new_filter
|
elsif new_filter
|
||||||
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
|
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
|
||||||
end
|
end
|
||||||
|
@web_link_categories = get_categories_for_index("WebLinkCategory")
|
||||||
|
@web_link_category_ids = @web_link_categories.collect{|t| t.id.to_s} + [nil]
|
||||||
|
|
||||||
# @web_links = WebLink.search(params[:category_id])
|
# @web_links = WebLink.search(params[:category_id])
|
||||||
@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
|
#@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
|
||||||
|
@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered("web_link",:web_link_category_id.in => @web_link_category_ids) : get_viewable("web_link",:web_link_category_id.in => @web_link_category_ids)
|
||||||
get_tags
|
|
||||||
|
get_tags
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
@ -51,6 +54,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||||
# GET /web_links/new
|
# GET /web_links/new
|
||||||
# GET /web_links/new.xml
|
# GET /web_links/new.xml
|
||||||
def new
|
def new
|
||||||
|
|
||||||
@web_link = WebLink.new
|
@web_link = WebLink.new
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
|
@ -131,17 +135,31 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_categorys(id = nil)
|
|
||||||
@web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true))
|
|
||||||
|
|
||||||
@web_link_categorys = []
|
# def get_index_categories(id = nil)
|
||||||
if(is_manager? || is_admin?)
|
# @bulletin_categorys = []
|
||||||
@web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true))
|
# if(is_manager? || is_admin?)
|
||||||
elsif is_sub_manager?
|
# @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
|
||||||
@web_link_categorys = WebLinkCategory.authed_for_user(current_user,'edit')
|
# elsif is_sub_manager?
|
||||||
end
|
# @bulletin_categorys = BulletinCategory.all
|
||||||
end
|
# end
|
||||||
|
# @bulletin_categorys
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
# def get_categorys(id = nil)
|
||||||
|
# @web_link_categorys = []
|
||||||
|
# if(is_manager? || is_admin?)
|
||||||
|
# @web_link_categorys = (id ? WebLinkCategory.admin_manager_all.find(id).to_a : WebLinkCategory.admin_manager_all))
|
||||||
|
# elsif is_sub_manager?
|
||||||
|
# @web_link_categorys = WebLinkCategory.all.authed_for_user(current_user,'edit')
|
||||||
|
# end
|
||||||
|
# if @web_link_categorys.empty? && params[:action] != "index"
|
||||||
|
# flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
|
||||||
|
# redirect_to :action => :index
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
|
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
<li><%= link_to t('web_resource.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
|
<li><%= link_to t('web_resource.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
|
||||||
<li><%= link_to show_toggle_archive_btn(web_link_category), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
|
<li><%= link_to show_toggle_archive_btn(web_link_category), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
|
||||||
<li><%= show_web_link_permission_link web_link_category %></li>
|
<li><%= show_web_link_permission_link web_link_category %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
$("#<%= dom_id @web_link_category %>").remove();
|
$("#<%= dom_id @web_link_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@web_link_category) %> ");
|
Reference in New Issue