| Class | Update |
| In: |
app/models/update.rb
|
| Parent: | ActiveRecord::Base |
# File app/models/update.rb, line 27
27: def self.find_done
28: Update.find(:all, :order => 'finished_on ASC', :conditions => ['finished_on is not null'])
29: end
# File app/models/update.rb, line 31
31: def self.find_inprogress
32: Update.find(:all, :order => 'finished_on ASC', :conditions => ['started_on is not null and finished_on is null'])
33: end
TODO validates_presence_of :user, :baseline_process, :wiki
# File app/models/update.rb, line 23
23: def self.find_todo
24: Update.find(:all, :order => 'created_on ASC', :conditions => ['started_on is null'])
25: end
# File app/models/update.rb, line 81
81: def after_create
82: if first_update?
83: Notifier::deliver_site_status(self, "SCHEDULED creation new Wiki #{self.wiki.title} using Baseline Process #{self.baseline_process.title}")
84: else
85: Notifier::deliver_site_status(self, "SCHEDULED update of Wiki #{self.wiki.title} with Baseline Process #{self.baseline_process.title}")
86: end
87: end
# File app/models/update.rb, line 89
89: def after_destroy
90: Notifier::deliver_site_status(self, "CANCELLED update of Wiki #{self.wiki.title} with Baseline Process #{self.baseline_process.title}")
91: end
# File app/models/update.rb, line 35
35: def do_update
36: logger.info("Doing update of #{self.wiki.title} with #{self.baseline_process.title}")
37: if self.first_update?
38: Notifier::deliver_site_status(self, "STARTED creating New Wiki #{self.wiki.title} using Baseline Process #{self.baseline_process.title}")
39: self.wiki.wikify(self)
40: Notifier::deliver_site_status(self, "FINISHED creating new Wiki #{self.wiki.title} using Baseline Process #{self.baseline_process.title}")
41: else
42: Notifier::deliver_site_status(self, "STARTED update of Wiki #{self.wiki.title} with Baseline Process #{self.baseline_process.title}")
43: self.wiki.update_wiki(self)
44: Notifier::deliver_site_status(self, "FINISHED update of Wiki #{self.wiki.title} with Baseline Process #{self.baseline_process.title}")
45: end
46: self.finished_on = Time.now
47: self.save!
48: users = User.find(:all, :conditions => ['notify_immediate=?', 1])
49: unless users.empty?
50: subject = "Wiki #{self.wiki.title} Updated with Baseline Process #{self.baseline_process.title}"
51: introduction = "User #{self.user.name} updated Wiki <a href=\"http://#{self.wiki.url(true)}\">#{self.wiki.title}</a> with Baseline Process #{self.baseline_process.title}."
52: Notifier::deliver_notification(users,subject,introduction, nil)
53: end
54:
55: expire_all_pages
56:
57: # Notify contributors of harvested stuff
58: contributions = Upload.find(:all, :conditions => ['done=? and review_note_send_on is null', 'Y']) +
59: Comment.find(:all, :conditions => ['done=? and review_note_send_on is null and site_id=?', 'Y', self.wiki.id]) +
60: UserVersion.find(:all, :conditions => ['done=? and review_note_send_on is null and wiki_id=?', 'Y', self.wiki.id])
61: contributions.collect{|rec|rec.user}.uniq.each do |u |
62: Notifier::deliver_contributions_processed(u, contributions.collect{|rec|rec if rec.user == u}.compact)
63: end
64:
65: contributions.each do |record|
66: record.review_note_send_on = Time.now
67: record.save!
68: end
69: end
# File app/models/update.rb, line 72
72: def first_update?
73: self.wiki.updates_done.empty? && wiki.updates_inprogress.empty?
74: end