change external feed entry titles to text
closes #CNVS-17774 Change-Id: I558625ca4827c3dd572a40596b14459d2ae3310c Reviewed-on: https://gerrit.instructure.com/56760 Tested-by: Jenkins Reviewed-by: Dan Minkevitch <dan@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
8a9b6e2961
commit
214f56c114
|
@ -18,7 +18,7 @@
|
|||
|
||||
class ExternalFeedEntry < ActiveRecord::Base
|
||||
include Workflow
|
||||
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :external_feed
|
||||
belongs_to :asset, :polymorphic => true
|
||||
|
@ -26,34 +26,35 @@ class ExternalFeedEntry < ActiveRecord::Base
|
|||
|
||||
before_save :infer_defaults
|
||||
validates_presence_of :external_feed_id, :workflow_state
|
||||
validates_length_of :title, :maximum => maximum_text_length, :allow_nil => true, :allow_blank => true
|
||||
validates_length_of :message, :maximum => maximum_text_length, :allow_nil => true, :allow_blank => true
|
||||
sanitize_field :message, CanvasSanitize::SANITIZE
|
||||
|
||||
attr_accessible :title, :message, :source_name, :source_url, :posted_at, :start_at, :end_at, :user, :url, :uuid, :author_name, :author_url, :author_email, :asset
|
||||
|
||||
|
||||
def infer_defaults
|
||||
self.uuid ||= Digest::MD5.hexdigest("#{title || rand.to_s}#{posted_at.strftime('%Y-%m-%d') rescue 'no-time'}")
|
||||
end
|
||||
protected :infer_defaults
|
||||
|
||||
|
||||
def update_feed_attributes(opts)
|
||||
self.update_attributes(opts)
|
||||
@feed_entry_updated = self.changed?
|
||||
end
|
||||
|
||||
|
||||
def entry_changed?
|
||||
@feed_entry_updated
|
||||
end
|
||||
|
||||
|
||||
workflow do
|
||||
state :active do
|
||||
event :delete_it, :transitions_to => :deleted
|
||||
event :cancel_it, :transitions_to => :cancelled
|
||||
end
|
||||
|
||||
|
||||
state :deleted
|
||||
state :cancelled
|
||||
end
|
||||
|
||||
|
||||
def self.serialization_excludes; [:uuid]; end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class ChangeExternalFeedEntryTitleToText < ActiveRecord::Migration
|
||||
tag :predeploy
|
||||
|
||||
def self.up
|
||||
change_column :external_feed_entries, :title, :text
|
||||
end
|
||||
|
||||
def self.down
|
||||
change_column :external_feed_entries, :title, :string
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue