2015-12-22 11:04:13 +00:00
|
|
|
class AnnouncementSetting
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
|
|
|
|
field :top_limit, type: Integer, :default => 0
|
2016-07-05 11:34:29 +00:00
|
|
|
field :pro_enabled, type: Boolean, :default => false
|
2016-08-05 12:00:34 +00:00
|
|
|
field :approvers, type: Array, :default => []
|
|
|
|
field :email_to, type: Array, :default => ["admins","managers","approvers"]
|
2020-05-15 14:25:58 +00:00
|
|
|
field :is_display_edit_only, type: Boolean, :default => false
|
2020-03-02 10:09:55 +00:00
|
|
|
has_many :anns_status_settings, :autosave => true, :dependent => :destroy
|
|
|
|
accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true
|
2015-12-22 11:04:13 +00:00
|
|
|
def self.check_limit_for_user(user_id, b_id = nil)
|
2015-12-22 11:52:35 +00:00
|
|
|
limit = self.first.top_limit rescue 0
|
2015-12-22 11:04:13 +00:00
|
|
|
return true if limit == 0
|
|
|
|
count = Bulletin.where(:is_top => true, :create_user_id => user_id, :id.ne => b_id).count
|
|
|
|
return count < limit
|
|
|
|
end
|
2016-07-05 11:34:29 +00:00
|
|
|
|
|
|
|
def self.is_pro?
|
2016-07-06 08:43:09 +00:00
|
|
|
self.first.pro_enabled rescue false
|
2016-07-05 11:34:29 +00:00
|
|
|
end
|
2015-12-22 11:04:13 +00:00
|
|
|
end
|