Skip to content

Commit

Permalink
Remove hacked resource relation and update column_name
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Jun 13, 2018
1 parent 5774966 commit ec8deec
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/models/miq_schedule.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MiqSchedule < ApplicationRecord
include ReservedMixin
reserve_attribute :resource_id, :big_integer
include DeprecationMixin
deprecate_attribute :towhat, :resource_type

validates :name, :uniqueness => {:scope => [:userid, :towhat]}
validates :name, :description, :towhat, :run_at, :presence => true
Expand All @@ -14,6 +14,7 @@ class MiqSchedule < ApplicationRecord

belongs_to :file_depot
belongs_to :miq_search
belongs_to :resource, :polymorphic => true
belongs_to :zone

scope :in_zone, lambda { |zone_name|
Expand Down Expand Up @@ -42,11 +43,6 @@ class MiqSchedule < ApplicationRecord
default_value_for :enabled, true
default_value_for(:zone_id) { MiqServer.my_server.zone_id }

def resource
# HACK: this should be a real relation, but for now it's using a reserve_attribute for backport reasons
Object.const_get(towhat).find_by(:id => resource_id)
end

def set_start_time_and_prod_default
run_at # Internally this will correct :start_time to UTC
self.prod_default = "system" if SYSTEM_SCHEDULE_CLASSES.include?(towhat.to_s)
Expand Down

0 comments on commit ec8deec

Please sign in to comment.