archive for announcement
This commit is contained in:
		
							parent
							
								
									f7107936d0
								
							
						
					
					
						commit
						ae2cbb728e
					
				|  | @ -75,3 +75,8 @@ | ||||||
| 		<%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %> | 		<%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %> | ||||||
| 	<%# end -%> | 	<%# end -%> | ||||||
| <%# end -%> | <%# end -%> | ||||||
|  | <div class="content"> | ||||||
|  | 	<% flash.each do |key, msg| %> | ||||||
|  |  		<%= content_tag :span, msg, :class => [key, "notice label label-warning"] %> | ||||||
|  |   	<% end%> | ||||||
|  | </div> | ||||||
|  | @ -14,7 +14,7 @@ module  OrbitCoreLib | ||||||
|         query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id) |         query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id) | ||||||
|         query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id) |         query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id) | ||||||
|         result = (query1 + query2).uniq |         result = (query1 + query2).uniq | ||||||
|         result.collect{|t| t.obj_authable} |         result.collect{|t| t.obj_authable}.delete_if{|val| val==nil} | ||||||
|       end |       end | ||||||
|          |          | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -107,13 +107,20 @@ 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]) |     @bulletin_category = BulletinCategory.find(params[:id]).first | ||||||
|     @bulletin_category.destroy |     @bulletin_category.disable = @bulletin_category.disable ? false : true | ||||||
| 
 | 
 | ||||||
|  |     if @bulletin_category.save!  | ||||||
|       respond_to do |format| |       respond_to do |format| | ||||||
|  |         flash[:notice] = t("bulletin_category.update_success") | ||||||
|  |         # flash[:error] +=  @bulletin_category.disable ?  t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false") | ||||||
|         format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) } |         format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) } | ||||||
|         # format.xml  { head :ok } |         # format.xml  { head :ok } | ||||||
|         format.js  |         format.js  | ||||||
|       end |       end | ||||||
|  |     else | ||||||
|  |       flash[:error] = t("bulletin_category.update_failed") | ||||||
|  |       format.html { render :action => "index" } | ||||||
|  |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | ||||||
|   layout 'new_admin' |   layout 'new_admin' | ||||||
|    |    | ||||||
|   before_filter :authenticate_user! |   before_filter :authenticate_user! | ||||||
|  |   before_filter :get_categorys ,:only => [ :new,:edit,:update] | ||||||
| #  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] | ||||||
|  | @ -83,17 +84,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | ||||||
| 	# @bulletin.bulletin_files.build | 	# @bulletin.bulletin_files.build | ||||||
| 	# @bulletin.bulletin_files.new | 	# @bulletin.bulletin_files.new | ||||||
| 
 | 
 | ||||||
| 	if get_categorys.empty? |  | ||||||
| 	  flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") |  | ||||||
|     redirect_to :action => :index |  | ||||||
|   else |  | ||||||
| 	  get_tags | 	  get_tags | ||||||
|       respond_to do |format| |       respond_to do |format| | ||||||
|         format.html # new.html.erb |         format.html # new.html.erb | ||||||
|         format.xml  { render :xml => @bulletin } |         format.xml  { render :xml => @bulletin } | ||||||
|   	end |   	end | ||||||
|   end |   end | ||||||
|   end |  | ||||||
| 
 | 
 | ||||||
|   # GET /bulletins/1/edit |   # GET /bulletins/1/edit | ||||||
|   def edit |   def edit | ||||||
|  | @ -105,7 +101,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | ||||||
|   	 |   	 | ||||||
|     	@link_url = panel_announcement_back_end_bulletin_path(@bulletin) |     	@link_url = panel_announcement_back_end_bulletin_path(@bulletin) | ||||||
|     	 |     	 | ||||||
|     	get_categorys |  | ||||||
|     	get_tags |     	get_tags | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  | @ -268,7 +263,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | ||||||
|   			format.xml  { head :ok } |   			format.xml  { head :ok } | ||||||
|   		  else |   		  else | ||||||
|           get_tags |           get_tags | ||||||
|           get_categorys |            | ||||||
|   			format.html { render :action => "edit" } |   			format.html { render :action => "edit" } | ||||||
|   			format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity } |   			format.xml  { render :xml => @bulletin.errors, :status => :unprocessable_entity } | ||||||
|   		  end |   		  end | ||||||
|  | @ -333,9 +328,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | ||||||
|     @bulletin_categorys = [] |     @bulletin_categorys = [] | ||||||
|     #@unit_list_for_anc = UnitListForAnc.all |     #@unit_list_for_anc = UnitListForAnc.all | ||||||
|     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.available.find(id).to_a : BulletinCategory.available) | ||||||
|     elsif is_sub_manager? |     elsif is_sub_manager? | ||||||
|       @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit') |       @bulletin_categorys = BulletinCategory.available.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 | ||||||
|   end |   end | ||||||
|    |    | ||||||
|  |  | ||||||
|  | @ -13,4 +13,8 @@ include ActionView::Helpers::UrlHelper | ||||||
|      link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa) |      link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |   def show_toggle_archive_btn(bulletin_category) | ||||||
|  |     bulletin_category.disable ?  t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")  | ||||||
|  |   end | ||||||
|  | 
 | ||||||
| end | end | ||||||
|  | @ -14,10 +14,21 @@ class BulletinCategory | ||||||
| 
 | 
 | ||||||
|   field :key |   field :key | ||||||
|   field :display |   field :display | ||||||
|  |   field :disable,type: Boolean,:default => false | ||||||
| 
 | 
 | ||||||
|   has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy |   has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy | ||||||
|    |    | ||||||
|   has_many :bulletins,:dependent => :destroy |   has_many :bulletins | ||||||
|  |    | ||||||
|  |   scope :available,where(disable: false) | ||||||
|  | 
 | ||||||
|  |     def self.find(*args) | ||||||
|  |       if args ==[:all] | ||||||
|  |           unscoped | ||||||
|  |         else | ||||||
|  |           unscoped.find(args)  | ||||||
|  |       end | ||||||
|  |     end | ||||||
| 
 | 
 | ||||||
|   def pp_object |   def pp_object | ||||||
|     i18n_variable[I18n.locale] |     i18n_variable[I18n.locale] | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| 				<ul class="nav nav-pills hide"> | 				<ul class="nav nav-pills hide"> | ||||||
| 					<% if is_admin?%> | 					<% if is_admin?%> | ||||||
| 						<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li> | 						<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li> | ||||||
| 						<li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li> | 						<li><%= link_to show_toggle_archive_btn(bulletin_category) , panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=> "archive_toggle" %></li> | ||||||
| 					<% end %> | 					<% end %> | ||||||
| 					<%if is_manager? || is_admin? %> | 					<%if is_manager? || is_admin? %> | ||||||
| 						<li><%= show_anc_cate_permission_link(bulletin_category) %></li> | 						<li><%= show_anc_cate_permission_link(bulletin_category) %></li> | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| $("#<%= dom_id @bulletin_category %>").remove(); | $("#<%= dom_id @bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@bulletin_category) %>  "); | ||||||
|  | @ -79,6 +79,7 @@ zh_tw: | ||||||
|     fact_check: 公告審核 |     fact_check: 公告審核 | ||||||
|     delete: 刪除 |     delete: 刪除 | ||||||
|     edit: 編輯 |     edit: 編輯 | ||||||
|  | 
 | ||||||
| #    action: 行動 | #    action: 行動 | ||||||
| #    add_language: 新增語言 | #    add_language: 新增語言 | ||||||
| #    admin: 管理 | #    admin: 管理 | ||||||
|  | @ -178,6 +179,10 @@ zh_tw: | ||||||
|   bulletin_category: |   bulletin_category: | ||||||
|     edit: 修改 |     edit: 修改 | ||||||
|     delete: 刪除   |     delete: 刪除   | ||||||
|  |     update_success: 分類更新成功 | ||||||
|  |     update_failed: 分類更新失敗 | ||||||
|  |     disable_change_to_false: 設為停用 | ||||||
|  |     disable_change_to_true:  重新啓用 | ||||||
|      |      | ||||||
| # Chinese (Taiwan) translations for Ruby on Rails | # Chinese (Taiwan) translations for Ruby on Rails | ||||||
| # by tsechingho (http://github.com/tsechingho) | # by tsechingho (http://github.com/tsechingho) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue