added pro version enabling in annoucment settings

This commit is contained in:
Harry Bomrah 2016-07-05 19:34:29 +08:00
parent b974cb771a
commit bfbececdbf
2 changed files with 11 additions and 2 deletions

View File

@ -146,9 +146,13 @@ class Admin::AnnouncementsController < OrbitAdminController
bulletin = Bulletin.new(bps)
bulletin.create_user_id = current_user.id
bulletin.update_user_id = current_user.id
# if user_can_approve?
if AnnouncementSetting.is_pro?
if user_can_approve?
bulletin.approved = true
# end
end
else
bulletin.approved = true
end
bulletin.save
build_email(bulletin)

View File

@ -3,6 +3,7 @@ class AnnouncementSetting
include Mongoid::Timestamps
field :top_limit, type: Integer, :default => 0
field :pro_enabled, type: Boolean, :default => false
def self.check_limit_for_user(user_id, b_id = nil)
limit = self.first.top_limit rescue 0
@ -10,4 +11,8 @@ class AnnouncementSetting
count = Bulletin.where(:is_top => true, :create_user_id => user_id, :id.ne => b_id).count
return count < limit
end
def self.is_pro?
self.first.pro_enabled
end
end