category disable for backend

This commit is contained in:
Matthew K. Fu JuYuan committed 2012-07-06 18:11:55 +08:00
1 parent c5fdff764e
commit 56caf4b34e
13 files changed
+190 -88

No files matched your search

@@ -51,12 +51,12 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
object_auth
end
def get_categorys(id = nil)
@bulletin_categorys = []
if(is_manager? || is_admin?)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
elsif is_sub_manager?
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
end
end
# def get_categorys(id = nil)
# @bulletin_categorys = []
# if(is_manager? || is_admin?)
# @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
# elsif is_sub_manager?
# @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
# end
# end
end
@@ -3,10 +3,9 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
before_filter :for_app_manager,:except => [:index]
def index
@bulletin_categorys = BulletinCategory.all
@bulletin_categorys = get_categories_for_index("BulletinCategory")
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@bulletin_category = BulletinCategory.new(:display => 'List')
@url = panel_announcement_back_end_bulletin_categorys_path
respond_to do |format|
@@ -108,7 +107,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
# DELETE /bulletins/1
# DELETE /bulletins/1.xml
def destroy
@bulletin_category = BulletinCategory.find(params[:id]).first
@bulletin_category = BulletinCategory.find(params[:id])
@bulletin_category.disable = @bulletin_category.disable ? false : true
if @bulletin_category.save!
@@ -1,16 +1,20 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
layout 'new_admin'
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_app_manager,:only => [:index,:show,]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
def index
# @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc")
get_categorys(params[:bulletin_category_id])
get_categorys('BulletinCategory',params[:bulletin_category_id])
get_tags
@filter = params[:filter]
@@ -35,11 +39,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletins = Bulletin.search(params[:search], params[:category_id])
# @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("bulletin") : get_viewable("bulletin")
@bulletin_categories = BulletinCategory.all
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@bulletin_categories = get_categories_for_index("BulletinCategory")
@bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
@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
@link_url = panel_announcement_back_end_bulletins_path
@@ -327,19 +331,28 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
end
def get_categorys(id = nil)
@bulletin_categorys = []
#@unit_list_for_anc = UnitListForAnc.all
if(is_manager? || is_admin?)
@bulletin_categorys = (id ? BulletinCategory.all.find(id).to_a : BulletinCategory.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_categories_for_index(id = nil)
# @bulletin_categories = []
# if(is_manager? || is_admin?)
# @bulletin_categories = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @bulletin_categories = BulletinCategory.all
# end
# @bulletin_categories
# end
# def get_categorys(id = nil)
# @bulletin_categorys = []
# 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
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@@ -1,10 +1,10 @@
class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager,:except => [: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就好
@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.xml
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
if @news_bulletin_category.save!
@@ -1,16 +1,20 @@
class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :authenticate_user!
# before_filter :for_admin_only,:only => [:]
# 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 :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
# @news_bulletins = NewsBulletin.all
# @news_bulletins = NewsBulletin.desc("postdate desc")
get_categorys(params[:news_bulletin_category_id])
get_categorys("NewsBulletinCategory",params[:news_bulletin_category_id])
get_tags
@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_bulletin") : get_viewable("news_bulletin")
@news_bulletin_categories = NewsBulletinCategory.all
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@news_bulletin_categories = get_categories_for_index("NewsBulletinCategory")
@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
@link_url = panel_news_back_end_news_bulletins_path
@@ -315,20 +322,32 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
protected
def get_categorys(id = nil)
@news_bulletin_categorys = []
@unit_list_for_anc = UnitListForAnc.all
if(is_manager? || is_admin?)
@news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.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_categories_for_index(id = nil)
# @news_bulletin_categories = []
# if(is_manager? || is_admin?)
# @news_bulletin_categories = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @news_bulletin_categories = NewsBulletinCategory.all
# end
# @news_bulletin_categories
# 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
module_app = ModuleApp.first(:conditions => {:key => 'news'})
@@ -1,8 +1,9 @@
class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController
before_filter :for_app_manager,:except => [:index]
include OrbitControllerLib::DivisionForDisable
def index
@web_link_categorys = WebLinkCategory.all
@web_link_categorys = get_categories_for_index("WebLinkCategory")
@web_link_category = WebLinkCategory.new(:display => 'List')
@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
def destroy
@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|
format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) }
# format.xml { head :ok }
format.js
if @web_link_category.save!
respond_to do |format|
format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("web_link_category.update_failed")
format.html { render :action => "index" }
end
end
end
@@ -1,12 +1,12 @@
class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
before_filter :authenticate_user!
# before_filter :for_app_manager,:except => [:index,:show]
before_filter :for_app_sub_manager,:except => [:index]
def index
get_categorys(params[:web_link_category_id])
get_categorys("WebLinkCategory",params[:web_link_category_id])
@filter = params[:filter]
new_filter = params[:new_filter]
@@ -23,11 +23,14 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
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 = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
get_tags
#@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
respond_to do |format|
format.html # index.html.erb
@@ -51,6 +54,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
# GET /web_links/new
# GET /web_links/new.xml
def new
@web_link = WebLink.new
get_categorys
@@ -131,17 +135,31 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
end
protected
def get_categorys(id = nil)
@web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true))
@web_link_categorys = []
if(is_manager? || is_admin?)
@web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true))
elsif is_sub_manager?
@web_link_categorys = WebLinkCategory.authed_for_user(current_user,'edit')
end
end
# def get_index_categories(id = nil)
# @bulletin_categorys = []
# 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
# 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
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
@@ -7,7 +7,7 @@
<div class="quick-edit">
<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 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>
</ul>
</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) %> ");