From bfbececdbf2e9412300d7bb41d12ec5252c831b1 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 5 Jul 2016 19:34:29 +0800 Subject: [PATCH] added pro version enabling in annoucment settings --- app/controllers/admin/announcements_controller.rb | 8 ++++++-- app/models/announcement_setting.rb | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 5f5ca32..b775af6 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -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 + else bulletin.approved = true - # end + end bulletin.save build_email(bulletin) diff --git a/app/models/announcement_setting.rb b/app/models/announcement_setting.rb index 568d7cb..6168304 100644 --- a/app/models/announcement_setting.rb +++ b/app/models/announcement_setting.rb @@ -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 \ No newline at end of file