diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 76dc253..98dcae1 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -17,13 +17,24 @@ class Admin::AnnouncementsController < OrbitAdminController @categories = @module_app.categories.enabled @filter_fields = filter_fields(@categories, @tags) @table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified] - - @bulletins = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]) + if AnnouncementSetting.first.is_display_edit_only && !current_user.is_admin? && !current_user.is_manager?(@module_app) + current_user_is_sub_manager = !current_user.is_manager?(@module_app) && (current_user.is_sub_manager?(@module_app) || current_user.is_sub_manager_with_role?(@module_app)) rescue false + if current_user_is_sub_manager + @bulletins = Bulletin.where(:create_user_id=>current_user.id,:title.ne => "",:is_preview.in=>[false,nil]) .order_by(sort) .with_categories(filters("category")) .with_tags(filters("tag")) .with_status(filters("status")) - + else + @bulletins = Bulletin.where(:uid=>nil) + end + else + @bulletins = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]) + .order_by(sort) + .with_categories(filters("category")) + .with_tags(filters("tag")) + .with_status(filters("status")) + end @bulletins = search_data(@bulletins,[:title]).page(params[:page]).per(10) if request.xhr? @@ -102,7 +113,7 @@ class Admin::AnnouncementsController < OrbitAdminController def updatesettings setting = @announcement_setting - ids = params['announcement_setting']['anns_status_settings'].collect do |i,v| + ids = params['announcement_setting']['anns_status_settings'].to_a.collect do |i,v| v['_id'] end.compact AnnsStatusSetting.where(:id.nin=>ids).destroy diff --git a/app/models/announcement_setting.rb b/app/models/announcement_setting.rb index 5e76839..f1c6af1 100644 --- a/app/models/announcement_setting.rb +++ b/app/models/announcement_setting.rb @@ -6,6 +6,7 @@ class AnnouncementSetting field :pro_enabled, type: Boolean, :default => false field :approvers, type: Array, :default => [] field :email_to, type: Array, :default => ["admins","managers","approvers"] + field :is_display_edit_only, type: Boolean, :default => false has_many :anns_status_settings, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true def self.check_limit_for_user(user_id, b_id = nil) diff --git a/app/views/admin/announcements/settings.html.erb b/app/views/admin/announcements/settings.html.erb index cbe030c..d95a3f0 100644 --- a/app/views/admin/announcements/settings.html.erb +++ b/app/views/admin/announcements/settings.html.erb @@ -121,6 +121,12 @@